]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/modulo_one.rs
1 #![warn(clippy::modulo_one)]
2 #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::identity_op)]
4 static STATIC_ONE
: usize = 2 - 1;
5 static STATIC_NEG_ONE
: i64 = 1 - 2;
9 //~^ ERROR: any number modulo 1 will be 0
10 //~| NOTE: `-D clippy::modulo-one` implied by `-D warnings`
12 //~^ ERROR: any number modulo -1 will panic/overflow or result in 0
14 // also caught by rustc
16 //~^ ERROR: this operation will panic at runtime
17 //~| NOTE: `#[deny(unconditional_panic)]` on by default
18 //~| ERROR: any number modulo -1 will panic/overflow or result in 0
20 const ONE
: u32 = 1 * 1;
21 const NEG_ONE
: i64 = 1 - 2;
22 const INT_MIN
: i64 = i64::MIN
;
25 //~^ ERROR: any number modulo 1 will be 0
29 //~^ ERROR: any number modulo -1 will panic/overflow or result in 0
32 // also caught by rustc
34 //~^ ERROR: this operation will panic at runtime
35 //~| ERROR: any number modulo -1 will panic/overflow or result in 0
36 // ONLY caught by rustc
37 INT_MIN
% STATIC_NEG_ONE
;
38 //~^ ERROR: this operation will panic at runtime