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