Open
Description
The following code triggers the range_plus_one
lint correctly. However the suggestion, if applied explicitly ie by an IDE, removes the braces which causes a compile error.
fn main() {
let from = 5;
let to = 16;
for n in (from..to + 1).rev() {
eprintln!("{}", n);
}
}
--> src/main.rs:17:14
|
17 | for n in (from..to + 1).rev() {
| ^^^^^^^^^^^^^^ help: use: `from..=to`
|
= note: #[warn(range_plus_one)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#range_plus_one
Incorrect suggested code:
fn main() {
let from = 5;
let to = 16;
for n in from..=to.rev() {
eprintln!("{}", n);
}
}