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