Trying to create a trait object with associated functions should have a better explanation #61973
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-trait-system
Area: Trait system
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
When trying to use associated functions and trait objects we get the following type of errors:
There are two possible cases for intent:
self
in a trait objectIn the former case, the explanation leaves a lot to be desired: what is a
receiver
? Why are we calling it amethod
when it's really afunction
in this case? Maybe we forgot to haveself
as the first argument? Should we be suggesting adding it? Why aren't we pointing at the trait fn definition nor the impl?For the second case, I believe if we can detect it it'd be great, because we could customize the help text to suggest adding
&self
in a confident manner, as we wouldn't have to care about lifetime issues.The text was updated successfully, but these errors were encountered: