]> git.lizzy.rs Git - rust.git/blob - tests/ui/neg_multiply.fixed
Don't lint `if_same_then_else` with `if let` conditions
[rust.git] / tests / ui / neg_multiply.fixed
1 // run-rustfix
2 #![warn(clippy::neg_multiply)]
3 #![allow(clippy::no_effect, clippy::unnecessary_operation, clippy::precedence)]
4 #![allow(unused)]
5
6 use std::ops::Mul;
7
8 struct X;
9
10 impl Mul<isize> for X {
11     type Output = X;
12
13     fn mul(self, _r: isize) -> Self {
14         self
15     }
16 }
17
18 impl Mul<X> for isize {
19     type Output = X;
20
21     fn mul(self, _r: X) -> X {
22         X
23     }
24 }
25
26 fn main() {
27     let x = 0;
28
29     -x;
30
31     -x;
32
33     100 + -x;
34
35     -(100 + x);
36
37     -17;
38
39     0xcafe | -0xff00;
40
41     -1 * -1; // should be ok
42
43     X * -1; // should be ok
44     -1 * X; // should also be ok
45 }