Improve error message for impl Self#95041
Conversation
|
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
compiler/rustc_resolve/src/late.rs
Outdated
There was a problem hiding this comment.
What happens if we visit self_type outside of the call to with_self_rib(res,?
There was a problem hiding this comment.
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
| 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.
We should emit a single diagnostic for these, not multiple. I could see
Selfis only available in impls, traits, and type definitions
being a “help”, but I think it being a singular error makes more sense.
|
☔ The latest upstream changes (presumably #95779) made this pull request unmergeable. Please resolve the merge conflicts. |
closes #65784