]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/neg_multiply.rs
Auto merge of #97944 - nikic:freebsd-update, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / tests / ui / neg_multiply.rs
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 * -1;
30
31     -1 * x;
32
33     100 + x * -1;
34
35     (100 + x) * -1;
36
37     -1 * 17;
38
39     0xcafe | 0xff00 * -1;
40
41     -1 * -1; // should be ok
42
43     X * -1; // should be ok
44     -1 * X; // should also be ok
45 }