-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve error message for impl Self
#95041
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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
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 commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I'll fix it. |
||
impl Tr for S<Self> {} //~ ERROR cycle detected | ||
//~^ ERROR `Self` is only available in impls, traits, and type definitions | ||
impl Self {} //~ ERROR cycle detected | ||
//~^ ERROR `Self` is only available in impls, traits, and type definitions | ||
impl S<Self> {} //~ ERROR cycle detected | ||
//~^ ERROR `Self` is only available in impls, traits, and type definitions | ||
impl Tr<Self::A> for S {} //~ ERROR cycle detected | ||
|
||
fn main() {} |
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 towith_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 visitsself_ty
unlesscurrently_processing_impl_self_ty
is true. It never causes aSelf 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?