]> git.lizzy.rs Git - rust.git/blob - tests/ui/assign_ops2.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / assign_ops2.rs
1 #![feature(tool_lints)]
2
3
4 #[allow(unused_assignments)]
5 #[warn(clippy::misrefactored_assign_op, clippy::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 }