Closed
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?"
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Trait systemCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.