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