]> git.lizzy.rs Git - rust.git/blob - tests/ui/modulo_one.rs
Addition `manual_map` test for `unsafe` blocks
[rust.git] / tests / ui / modulo_one.rs
1 #![warn(clippy::modulo_one)]
2 #![allow(clippy::no_effect, clippy::unnecessary_operation)]
3
4 static STATIC_ONE: usize = 2 - 1;
5 static STATIC_NEG_ONE: i64 = 1 - 2;
6
7 fn main() {
8     10 % 1;
9     10 % -1;
10     10 % 2;
11     i32::MIN % (-1); // also caught by rustc
12
13     const ONE: u32 = 1 * 1;
14     const NEG_ONE: i64 = 1 - 2;
15     const INT_MIN: i64 = i64::MIN;
16
17     2 % ONE;
18     5 % STATIC_ONE; // NOT caught by lint
19     2 % NEG_ONE;
20     5 % STATIC_NEG_ONE; // NOT caught by lint
21     INT_MIN % NEG_ONE; // also caught by rustc
22     INT_MIN % STATIC_NEG_ONE; // ONLY caught by rustc
23 }