-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
syntax: Rewrite parsing of impls #46455
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
src/libsyntax/parse/parser.rs
Outdated
} | ||
if !impl_items.is_empty() { | ||
self.span_err(impl_items[0].span, "auto impls cannot have impl items") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add new tests for all this stuff because impls for ..
are going to be removed pretty soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can even do it now, if we do some more #[cfg(stage0)]
stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with a delay-span-bug call
src/librustc_typeck/check/wfcheck.rs
Outdated
fn error_380(tcx: TyCtxt, span: Span) { | ||
span_err!(tcx.sess, span, E0380, | ||
"traits with default impls (`e.g. impl \ | ||
"traits with auto impls (`e.g. impl \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't these just called auto trait
now or something? I thought we landed some such PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -69,6 +62,9 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { | |||
g.attr_name()); | |||
} | |||
|
|||
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => { | |||
// Reported in AST validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delay_span_bug
please
src/libsyntax/parse/parser.rs
Outdated
} | ||
if !impl_items.is_empty() { | ||
self.span_err(impl_items[0].span, "auto impls cannot have impl items") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can even do it now, if we do some more #[cfg(stage0)]
stuff.
This PR is not super urgent, I'll merge it after #46480 lands. |
☔ The latest upstream changes (presumably #46083) made this pull request unmergeable. Please resolve the merge conflicts. |
Properly parse impls for the never type `!` Recover from missing `for` in `impl Trait for Type` Prohibit inherent default impls and default impls of auto traits Change wording in more diagnostics to use "auto traits" Some minor code cleanups in the parser
@bors r=nikomatsakis |
📌 Commit 60c48dd has been approved by |
syntax: Rewrite parsing of impls Properly parse impls for the never type `!` Recover from missing `for` in `impl Trait for Type` Prohibit inherent default impls and default impls of auto traits (#37653 (comment), #37653 (comment)) Change wording in more diagnostics to use "auto traits" Fix some spans in diagnostics Some other minor code cleanups in the parser Disambiguate generics and qualified paths in impls (parse `impl <Type as Trait>::AssocTy { ... }`) Replace the future-compatibility hack from #38268 with actually parsing generic parameters Add a test for #46438
|
||
This will compile: | ||
|
||
```ignore (ignore auto_trait future compatibility warning) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this ignore
can be removed
☀️ Test successful - status-appveyor, status-travis |
Properly parse impls for the never type
!
Recover from missing
for
inimpl Trait for Type
Prohibit inherent default impls and default impls of auto traits (#37653 (comment), #37653 (comment))
Change wording in more diagnostics to use "auto traits"
Fix some spans in diagnostics
Some other minor code cleanups in the parser
Disambiguate generics and qualified paths in impls (parse
impl <Type as Trait>::AssocTy { ... }
)Replace the future-compatibility hack from #38268 with actually parsing generic parameters
Add a test for #46438