]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/identity_op.rs
iterate List by value
[rust.git] / tests / ui / identity_op.rs
index ae8c66faa416c42bd28af0f7e72291421bc8d71e..ceaacaaf6bd706618ecac1133af2b63d9d261595 100644 (file)
@@ -1,12 +1,15 @@
-#![feature(tool_lints)]
-
-
-const ONE : i64 = 1;
-const NEG_ONE : i64 = -1;
-const ZERO : i64 = 0;
-
-#[allow(clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::double_parens)]
+const ONE: i64 = 1;
+const NEG_ONE: i64 = -1;
+const ZERO: i64 = 0;
+
+#[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,19 +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;
+    let u: u8 = 0;
     u & 255;
+
+    1 << 0; // no error, this case is allowed, see issue 3430
+    42 << 0;
+    1 >> 0;
+    42 >> 0;
 }