]> git.lizzy.rs Git - rust.git/blob - tests/ui/assign_ops2.rs
Merge pull request #2367 from etaoins/inline-fn-without-body-lint
[rust.git] / tests / ui / assign_ops2.rs
1
2
3
4 #[allow(unused_assignments)]
5 #[warn(misrefactored_assign_op)]
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 -= 1 - a;
17     a /= 5 / a;
18     a %= 42 % a;
19     a <<= 6 << a;
20 }
21
22 // check that we don't lint on op assign impls, because that's just the way to impl them
23
24 use std::ops::{Mul, MulAssign};
25
26 #[derive(Copy, Clone, Debug, PartialEq)]
27 pub struct Wrap(i64);
28
29 impl Mul<i64> for Wrap {
30     type Output = Self;
31
32     fn mul(self, rhs: i64) -> Self {
33         Wrap(self.0 * rhs)
34     }
35 }
36
37 impl MulAssign<i64> for Wrap {
38     fn mul_assign(&mut self, rhs: i64) {
39         *self = *self * rhs
40     }
41 }