Closed
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.