-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.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
Code
fn main() {
for x in (..4).rev() {
todo!();
}
}
Current output
error[E0599]: `RangeTo<{integer}>` is not an iterator
--> src/main.rs:2:20
|
2 | for x in (..4).rev() {
| ^^^ `RangeTo<{integer}>` is not an iterator
|
::: /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/range.rs:271:1
|
271 | pub struct RangeTo<Idx> {
| ----------------------- doesn't satisfy `RangeTo<{integer}>: Iterator`
|
= note: the following trait bounds were not satisfied:
`RangeTo<{integer}>: Iterator`
which is required by `&mut RangeTo<{integer}>: Iterator`
= note: you might have meant to use a bounded `Range`
Desired output
did you mean?
for x in (0..4).rev() {
Rationale and extra context
The note "you might have meant to use a bounded Range
" is decent but a code suggestion would be better.
Other cases
Also the error is not very helpful for (..4).iter().rev()
.
Rust Version
1.90.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.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.