]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/int_plus_one.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / int_plus_one.rs
diff --git a/src/tools/clippy/tests/ui/int_plus_one.rs b/src/tools/clippy/tests/ui/int_plus_one.rs
new file mode 100644 (file)
index 0000000..0755a0c
--- /dev/null
@@ -0,0 +1,17 @@
+// run-rustfix
+
+#[allow(clippy::no_effect, clippy::unnecessary_operation)]
+#[warn(clippy::int_plus_one)]
+fn main() {
+    let x = 1i32;
+    let y = 0i32;
+
+    let _ = x >= y + 1;
+    let _ = y + 1 <= x;
+
+    let _ = x - 1 >= y;
+    let _ = y <= x - 1;
+
+    let _ = x > y; // should be ok
+    let _ = y < x; // should be ok
+}