]> git.lizzy.rs Git - rust.git/blob - tests/ui/identity_op.rs
rustup and compile-fail -> ui test move
[rust.git] / tests / ui / identity_op.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
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 #[deny(identity_op)]
10 fn main() {
11     let x = 0;
12
13     x + 0;        //~ERROR the operation is ineffective
14     x + (1 - 1);  //~ERROR the operation is ineffective
15     x + 1;
16     0 + x;        //~ERROR the operation is ineffective
17     1 + x;
18     x - ZERO;     //no error, as we skip lookups (for now)
19     x | (0);      //~ERROR the operation is ineffective
20     ((ZERO)) | x; //no error, as we skip lookups (for now)
21
22     x * 1;        //~ERROR the operation is ineffective
23     1 * x;        //~ERROR the operation is ineffective
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;       //~ERROR the operation is ineffective
30 }