2 #![warn(clippy::identity_op)]
7 clippy::unnecessary_operation,
10 clippy::uninlined_format_args
13 use std::fmt::Write as _;
16 const NEG_ONE: i64 = -1;
21 impl std::ops::Shl<i32> for A {
23 fn shl(mut self, other: i32) -> Self {
24 let _ = write!(self.0, "{}", other);
32 impl core::ops::Mul<Meter> for u8 {
34 fn mul(self, _: Meter) -> Length {
48 x - ZERO; //no error, as we skip lookups (for now)
50 ((ZERO)) | x; //no error, as we skip lookups (for now)
54 x / ONE; //no error, as we skip lookups (for now)
56 x / 2; //no false positive
58 x & NEG_ONE; //no error, as we skip lookups (for now)
64 1 << 0; // no error, this case is allowed, see issue 3430
71 let mut a = A(String::new());
72 let b = a << 0; // no error: non-integer
74 1 * Meter; // no error: non-integer
81 (x + 1) % 3; // no error
88 (if b { 1 } else { 2 });
89 (if b { 1 } else { 2 }) + if b { 3 } else { 4 };
90 (match a { 0 => 10, _ => 20 });
91 (match a { 0 => 10, _ => 20 }) + match a { 0 => 30, _ => 40 };
92 (if b { 1 } else { 2 }) + match a { 0 => 30, _ => 40 };
93 (match a { 0 => 10, _ => 20 }) + if b { 3 } else { 4 };
94 (if b { 1 } else { 2 });
98 (loop { let mut c = 0; if c == 10 { break c; } c += 1; }) + { a * 2 };
104 f(if b { 1 } else { 2 } + 3);
105 const _: i32 = { 2 * 4 } + 3;
106 const _: i32 = { 1 + 2 * 3 } + 3;
117 pub fn decide(a: bool, b: bool) -> u32 {
118 (if a { 1 } else { 2 }) + if b { 3 } else { 5 }