]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/identity_op.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / identity_op.rs
1
2
3
4 const ONE : i64 = 1;
5 const NEG_ONE : i64 = -1;
6 const ZERO : i64 = 0;
7
8 #[allow(eq_op, no_effect, unnecessary_operation, double_parens)]
9 #[warn(identity_op)]
10 fn main() {
11 let x = 0;
12
13 x + 0;
14 x + (1 - 1);
15 x + 1;
16 0 + x;
17 1 + x;
18 x - ZERO; //no error, as we skip lookups (for now)
19 x | (0);
20 ((ZERO)) | x; //no error, as we skip lookups (for now)
21
22 x * 1;
23 1 * x;
24 x / ONE; //no error, as we skip lookups (for now)
25
26 x / 2; //no false positive
27
28 x & NEG_ONE; //no error, as we skip lookups (for now)
29 -1 & x;
30
31 let u : u8 = 0;
32 u & 255;
33 }