]> git.lizzy.rs Git - rust.git/blob - tests/ui/neg_multiply.rs
Auto merge of #4478 - tsurai:master, r=flip1995
[rust.git] / tests / ui / neg_multiply.rs
1 #![warn(clippy::neg_multiply)]
2 #![allow(clippy::no_effect, clippy::unnecessary_operation)]
3
4 use std::ops::Mul;
5
6 struct X;
7
8 impl Mul<isize> for X {
9     type Output = X;
10
11     fn mul(self, _r: isize) -> Self {
12         self
13     }
14 }
15
16 impl Mul<X> for isize {
17     type Output = X;
18
19     fn mul(self, _r: X) -> X {
20         X
21     }
22 }
23
24 fn main() {
25     let x = 0;
26
27     x * -1;
28
29     -1 * x;
30
31     -1 * -1; // should be ok
32
33     X * -1; // should be ok
34     -1 * X; // should also be ok
35 }