- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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
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.
Heliozoa and syvb
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.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.