]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/assign_ops2.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / assign_ops2.rs
1
2
3
4 #[allow(unused_assignments)]
5 #[warn(misrefactored_assign_op, assign_op_pattern)]
6 fn main() {
7 let mut a = 5;
8 a += a + 1;
9 a += 1 + a;
10 a -= a - 1;
11 a *= a * 99;
12 a *= 42 * a;
13 a /= a / 2;
14 a %= a % 5;
15 a &= a & 1;
16 a *= a * a;
17 a = a * a * a;
18 a = a * 42 * a;
19 a = a * 2 + a;
20 a -= 1 - a;
21 a /= 5 / a;
22 a %= 42 % a;
23 a <<= 6 << a;
24 }
25
26 // check that we don't lint on op assign impls, because that's just the way to impl them
27
28 use std::ops::{Mul, MulAssign};
29
30 #[derive(Copy, Clone, Debug, PartialEq)]
31 pub struct Wrap(i64);
32
33 impl Mul<i64> for Wrap {
34 type Output = Self;
35
36 fn mul(self, rhs: i64) -> Self {
37 Wrap(self.0 * rhs)
38 }
39 }
40
41 impl MulAssign<i64> for Wrap {
42 fn mul_assign(&mut self, rhs: i64) {
43 *self = *self * rhs
44 }
45 }