-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Suppose you have the following reduced code example:
impl Self {
}
This gives you the error message:
error[E0391]: cycle detected when processing `<impl at src/lib.rs:1:1: 3:2>`
--> src/lib.rs:1:6
|
1 | impl Self {
| ^^^^
|
= note: ...which again requires processing `<impl at src/lib.rs:1:1: 3:2>`, completing the cycle
note: cycle used when collecting item types in top-level module
--> src/lib.rs:1:1
|
1 | impl Self {
| ^^^^^^^^^
This is confusing because there isn't actually any obvious cycle (unless you know things about compilers). E0391 actually describes itself with an example like this:
trait FirstTrait : SecondTrait {
}
trait SecondTrait : FirstTrait {
}
This looks nothing like the original code example.
We should probably detect this case and provide a more useful message that indicates that Self
is a special keyword that can be used within the impl block, but not as the type of the impl block itself.
Ixrecpetrochenkov
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.