rust-clippy/tests/ui/reversed_empty_ranges_loops_fixable.fixed
Yuri Astrakhan eb3970285b fallout: fix tests to allow uninlined_format_args
In order to switch `clippy::uninlined_format_args` from pedantic to
style, all existing tests must not raise a warning. I did not want to
change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

changelog: none
2022-10-02 15:13:22 -04:00

58 lines
1.1 KiB
Rust

// run-rustfix
#![warn(clippy::reversed_empty_ranges)]
#![allow(clippy::uninlined_format_args)]
fn main() {
const MAX_LEN: usize = 42;
for i in (0..10).rev() {
println!("{}", i);
}
for i in (0..=10).rev() {
println!("{}", i);
}
for i in (0..MAX_LEN).rev() {
println!("{}", i);
}
for i in 5..=5 {
// not an error, this is the range with only one element “5”
println!("{}", i);
}
for i in 0..10 {
// not an error, the start index is less than the end index
println!("{}", i);
}
for i in -10..0 {
// not an error
println!("{}", i);
}
for i in (0..10).rev().map(|x| x * 2) {
println!("{}", i);
}
// testing that the empty range lint folds constants
for i in (5 + 4..10).rev() {
println!("{}", i);
}
for i in ((3 - 1)..(5 + 2)).rev() {
println!("{}", i);
}
for i in (2 * 2)..(2 * 3) {
// no error, 4..6 is fine
println!("{}", i);
}
let x = 42;
for i in x..10 {
// no error, not constant-foldable
println!("{}", i);
}
}