]> git.lizzy.rs Git - rust.git/blob - tests/ui/identity_op.rs
Addition `manual_map` test for `unsafe` blocks
[rust.git] / tests / ui / identity_op.rs
1 const ONE: i64 = 1;
2 const NEG_ONE: i64 = -1;
3 const ZERO: i64 = 0;
4
5 #[allow(
6     clippy::eq_op,
7     clippy::no_effect,
8     clippy::unnecessary_operation,
9     clippy::double_parens
10 )]
11 #[warn(clippy::identity_op)]
12 #[rustfmt::skip]
13 fn main() {
14     let x = 0;
15
16     x + 0;
17     x + (1 - 1);
18     x + 1;
19     0 + x;
20     1 + x;
21     x - ZERO; //no error, as we skip lookups (for now)
22     x | (0);
23     ((ZERO)) | x; //no error, as we skip lookups (for now)
24
25     x * 1;
26     1 * x;
27     x / ONE; //no error, as we skip lookups (for now)
28
29     x / 2; //no false positive
30
31     x & NEG_ONE; //no error, as we skip lookups (for now)
32     -1 & x;
33
34     let u: u8 = 0;
35     u & 255;
36
37     1 << 0; // no error, this case is allowed, see issue 3430
38     42 << 0;
39     1 >> 0;
40     42 >> 0;
41 }