Closed
Description
Given the following code:
trait StringExt {
fn ext(&self);
}
impl StringExt for String {
fn ext(&self) {
<Self as str>::trim(self);
// str::trim(self); - this works
}
}
The current output is:
error[E0576]: cannot find method or associated constant `trim` in `str`
--> src/lib.rs:6:24
|
6 | <Self as str>::trim(self);
| ^^^^ not found in `str`
For more information about this error, try `rustc --explain E0576`.
However, str
is not a trait, therefore the fully-qualified trait syntax should be simply invalid in this case - therefore, the error would better say the real problem ("str
is not a trait"), probably with the help message suggesting the commented-out line.
Initially found in this SO question.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.