]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/identity_op.rs
iterate List by value
[rust.git] / tests / ui / identity_op.rs
index ea68ec3e1abc06121f97a32b93c498310958f0c3..ceaacaaf6bd706618ecac1133af2b63d9d261595 100644 (file)
@@ -1,12 +1,15 @@
-#![feature(plugin)]
-#![plugin(clippy)]
+const ONE: i64 = 1;
+const NEG_ONE: i64 = -1;
+const ZERO: i64 = 0;
 
-const ONE : i64 = 1;
-const NEG_ONE : i64 = -1;
-const ZERO : i64 = 0;
-
-#[allow(eq_op, no_effect, unnecessary_operation, double_parens)]
-#[deny(identity_op)]
+#[allow(
+    clippy::eq_op,
+    clippy::no_effect,
+    clippy::unnecessary_operation,
+    clippy::double_parens
+)]
+#[warn(clippy::identity_op)]
+#[rustfmt::skip]
 fn main() {
     let x = 0;
 
@@ -15,16 +18,24 @@ fn main() {
     x + 1;
     0 + x;
     1 + x;
-    x - ZERO;     //no error, as we skip lookups (for now)
+    x - ZERO; //no error, as we skip lookups (for now)
     x | (0);
     ((ZERO)) | x; //no error, as we skip lookups (for now)
 
     x * 1;
     1 * x;
-    x / ONE;      //no error, as we skip lookups (for now)
+    x / ONE; //no error, as we skip lookups (for now)
 
-    x / 2;        //no false positive
+    x / 2; //no false positive
 
-    x & NEG_ONE;  //no error, as we skip lookups (for now)
+    x & NEG_ONE; //no error, as we skip lookups (for now)
     -1 & x;
+
+    let u: u8 = 0;
+    u & 255;
+
+    1 << 0; // no error, this case is allowed, see issue 3430
+    42 << 0;
+    1 >> 0;
+    42 >> 0;
 }