X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Ftests%2Fui%2Fint_plus_one.rs;fp=src%2Ftools%2Fclippy%2Ftests%2Fui%2Fint_plus_one.rs;h=0755a0c79d2801eb50e1f372fd4ff1aaf71d8f69;hb=a33a295584b7f296fedf3a50990e6b12210adf59;hp=0000000000000000000000000000000000000000;hpb=9c18a685fcfe68770bcd6ddb2059847f28403b69;p=rustc.git 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 index 0000000000..0755a0c79d --- /dev/null +++ b/src/tools/clippy/tests/ui/int_plus_one.rs @@ -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 +}