]> git.lizzy.rs Git - rust.git/blob - tests/ui/modulo_arithmetic_integral_const.rs
Auto merge of #7338 - camsteffen:shadow, r=llogic
[rust.git] / tests / ui / modulo_arithmetic_integral_const.rs
1 #![warn(clippy::modulo_arithmetic)]
2 #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::modulo_one)]
3
4 fn main() {
5     // Lint when both sides are const and of the opposite sign
6     -1 % 2;
7     1 % -2;
8     (1 - 2) % (1 + 2);
9     (1 + 2) % (1 - 2);
10     35 * (7 - 4 * 2) % (-500 * -600);
11
12     -1i8 % 2i8;
13     1i8 % -2i8;
14     -1i16 % 2i16;
15     1i16 % -2i16;
16     -1i32 % 2i32;
17     1i32 % -2i32;
18     -1i64 % 2i64;
19     1i64 % -2i64;
20     -1i128 % 2i128;
21     1i128 % -2i128;
22     -1isize % 2isize;
23     1isize % -2isize;
24
25     // No lint when both sides are const and of the same sign
26     1 % 2;
27     -1 % -2;
28     (1 + 2) % (-1 + 2);
29     (-1 - 2) % (1 - 2);
30
31     1u8 % 2u8;
32     1u16 % 2u16;
33     1u32 % 2u32;
34     1u64 % 2u64;
35     1u128 % 2u128;
36     1usize % 2usize;
37 }