• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![allow(clippy::uninlined_format_args)]
2 
3 #[allow(unused_assignments)]
4 #[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
main()5 fn main() {
6     let mut a = 5;
7     a += a + 1;
8     a += 1 + a;
9     a -= a - 1;
10     a *= a * 99;
11     a *= 42 * a;
12     a /= a / 2;
13     a %= a % 5;
14     a &= a & 1;
15     a *= a * a;
16     a = a * a * a;
17     a = a * 42 * a;
18     a = a * 2 + a;
19     a -= 1 - a;
20     a /= 5 / a;
21     a %= 42 % a;
22     a <<= 6 << a;
23 }
24 
25 // check that we don't lint on op assign impls, because that's just the way to impl them
26 
27 use std::ops::{Mul, MulAssign};
28 
29 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
30 pub struct Wrap(i64);
31 
32 impl Mul<i64> for Wrap {
33     type Output = Self;
34 
mul(self, rhs: i64) -> Self35     fn mul(self, rhs: i64) -> Self {
36         Wrap(self.0 * rhs)
37     }
38 }
39 
40 impl MulAssign<i64> for Wrap {
mul_assign(&mut self, rhs: i64)41     fn mul_assign(&mut self, rhs: i64) {
42         *self = *self * rhs
43     }
44 }
45 
cow_add_assign()46 fn cow_add_assign() {
47     use std::borrow::Cow;
48     let mut buf = Cow::Owned(String::from("bar"));
49     let cows = Cow::Borrowed("foo");
50 
51     // this can be linted
52     buf = buf + cows.clone();
53 
54     // this should not as cow<str> Add is not commutative
55     buf = cows + buf;
56     println!("{}", buf);
57 }
58