2020-05-10 22:52:33 +00:00
|
|
|
#![warn(clippy::reversed_empty_ranges)]
|
2022-10-02 19:13:22 +00:00
|
|
|
#![allow(clippy::uninlined_format_args)]
|
2020-05-10 22:52:33 +00:00
|
|
|
|
|
|
|
const ANSWER: i32 = 42;
|
|
|
|
|
|
|
|
fn main() {
|
2020-05-23 20:07:03 +00:00
|
|
|
// These should be linted:
|
|
|
|
|
2020-05-10 22:52:33 +00:00
|
|
|
(21..=42).rev().for_each(|x| println!("{}", x));
|
|
|
|
let _ = (21..ANSWER).rev().filter(|x| x % 2 == 0).take(10).collect::<Vec<_>>();
|
|
|
|
|
|
|
|
for _ in (-42..=-21).rev() {}
|
|
|
|
for _ in (21u32..42u32).rev() {}
|
|
|
|
|
|
|
|
// These should be ignored as they are not empty ranges:
|
|
|
|
|
|
|
|
(21..=42).for_each(|x| println!("{}", x));
|
|
|
|
(21..42).for_each(|x| println!("{}", x));
|
|
|
|
|
2020-06-07 18:38:28 +00:00
|
|
|
let arr = [1, 2, 3, 4, 5];
|
2020-05-10 22:52:33 +00:00
|
|
|
let _ = &arr[1..=3];
|
|
|
|
let _ = &arr[1..3];
|
|
|
|
|
|
|
|
for _ in 21..=42 {}
|
|
|
|
for _ in 21..42 {}
|
2020-06-07 18:38:28 +00:00
|
|
|
|
|
|
|
// This range is empty but should be ignored, see issue #5689
|
|
|
|
let _ = &arr[0..0];
|
2020-05-10 22:52:33 +00:00
|
|
|
}
|