Skip to content
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

Closed

Conversation

TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Mar 17, 2022

closes #65784

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 17, 2022
@rust-highfive
Copy link
Collaborator

r? @nagisa

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 17, 2022
let prev = replace(
&mut this.diagnostic_metadata.currently_processing_impl_self_ty,
true,
);
this.visit_ty(self_type);
Copy link
Contributor

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,?

Copy link
Member Author

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?

@compiler-errors
Copy link
Member

You may also want to draw inspiration from #93971 which attempted to fix ICEs of similar variety.

@TaKO8Ki TaKO8Ki force-pushed the Improve-error-message-for-impl-Self branch from f8e8467 to 5a155f6 Compare March 18, 2022 07:05
@@ -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
Copy link
Member

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.

Copy link
Member Author

@TaKO8Ki TaKO8Ki Mar 22, 2022

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.

@nagisa nagisa added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2022
@bors
Copy link
Contributor

bors commented Apr 17, 2022

☔ The latest upstream changes (presumably #95779) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon
Copy link
Member

@TaKO8Ki
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this.
Note: if you do please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github.
Thanks for your contribution.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Nov 27, 2022
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message for impl Self
8 participants