-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve error message for impl Self
#95041
Improve error message for impl Self
#95041
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
let prev = replace( | ||
&mut this.diagnostic_metadata.currently_processing_impl_self_ty, | ||
true, | ||
); | ||
this.visit_ty(self_type); |
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.
What happens if we visit self_type
outside of the call to with_self_rib(res,
?
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.
If we do, visit_ty
just visits self_ty
unless currently_processing_impl_self_ty
is true. It never causes a Self is only available in impls, traits, and type definitions
error.
In reference to #93971 (review), should I improve this error to report it right away?
You may also want to draw inspiration from #93971 which attempted to fix ICEs of similar variety. |
use `replace`
f8e8467
to
5a155f6
Compare
@@ -12,9 +12,13 @@ impl Tr for S where S<Self>: Copy {} // OK | |||
impl Tr for S where Self::A: Copy {} // OK | |||
|
|||
impl Tr for Self {} //~ ERROR cycle detected | |||
//~^ ERROR `Self` is only available in impls, traits, and type definitions |
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.
We should emit a single diagnostic for these, not multiple. I could see
Self
is only available in impls, traits, and type definitions
being a “help”, but I think it being a singular error makes more sense.
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.
Ok. I'll fix it.
☔ The latest upstream changes (presumably #95779) made this pull request unmergeable. Please resolve the merge conflicts. |
closes #65784