]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/range_contains.fixed
Rollup merge of #78476 - RalfJung:btree-alias, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / range_contains.fixed
1 // run-rustfix
2
3 #[warn(clippy::manual_range_contains)]
4 #[allow(unused)]
5 #[allow(clippy::no_effect)]
6 #[allow(clippy::short_circuit_statement)]
7 #[allow(clippy::unnecessary_operation)]
8 fn main() {
9     let x = 9_u32;
10
11     // order shouldn't matter
12     (8..12).contains(&x);
13     (21..42).contains(&x);
14     (1..100).contains(&x);
15
16     // also with inclusive ranges
17     (9..=99).contains(&x);
18     (1..=33).contains(&x);
19     (1..=999).contains(&x);
20
21     // and the outside
22     !(8..12).contains(&x);
23     !(21..42).contains(&x);
24     !(1..100).contains(&x);
25
26     // also with the outside of inclusive ranges
27     !(9..=99).contains(&x);
28     !(1..=33).contains(&x);
29     !(1..=999).contains(&x);
30
31     // not a range.contains
32     x > 8 && x < 12; // lower bound not inclusive
33     x < 8 && x <= 12; // same direction
34     x >= 12 && 12 >= x; // same bounds
35     x < 8 && x > 12; // wrong direction
36
37     x <= 8 || x >= 12;
38     x >= 8 || x >= 12;
39     x < 12 || 12 < x;
40     x >= 8 || x <= 12;
41 }