-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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
Given the following code:
let arr = &[0,1,2,3];
for i in 0..arr.len().rev() {
// ...
}
The current output is:
error[E0599]: the method `rev` exists for type `usize`, but its trait bounds were not satisfied
--> src/main.rs:5:25
|
5 | for i in 0..arr.len().rev() {
| ^^^ method cannot be called on `usize` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`usize: Iterator`
which is required by `&mut usize: Iterator
Ideally the output should look like:
// Minimal fix: remove misleading message:
Omit "the method rev exists for type usize."
// Amazing fix:
|
5 | for i in 0..arr.len().rev() {
| ^^^ method cannot be called on `usize` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`usize: Iterator`
which is required by `&mut usize: Iterator
= hint: (0..arr.len()) implements `Iterator`, perhaps you are missing parentheses?
hellow554, TheWastl and estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.