]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/neg_multiply.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / neg_multiply.rs
1
2
3
4 #![warn(neg_multiply)]
5 #![allow(no_effect, unnecessary_operation)]
6
7 use std::ops::Mul;
8
9 struct X;
10
11 impl Mul<isize> for X {
12 type Output = X;
13
14 fn mul(self, _r: isize) -> Self {
15 self
16 }
17 }
18
19 impl Mul<X> for isize {
20 type Output = X;
21
22 fn mul(self, _r: X) -> X {
23 X
24 }
25 }
26
27 fn main() {
28 let x = 0;
29
30 x * -1;
31
32 -1 * x;
33
34 -1 * -1; // should be ok
35
36 X * -1; // should be ok
37 -1 * X; // should also be ok
38 }