-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-trait-systemArea: Trait systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.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
I wrote the following trait: trait Area : Sized { fn f(a : Area) -> Area; }
. What I meant (I've now discovered) was trait Area : Sized { fn f(a : Self) -> Self; }
. However, it isn't easy to get "to that point".
Reading the pages linked to from the compiler warning, and the rust book, I didn't find anything which discussed what using the name of a trait inside the trait means -- in particular (and this was I believe the source of my confusion), it isn't like C++ where, while defining template<typename T> vector { ... }
, we use vector
to refer to the type we are currently defining.
I'm not suggesting a change of behaviour, but I wonder if this could be a common enough bug to say "did you mean Self?"
leonardo-m, Torrencem and estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-trait-systemArea: Trait systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.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.