-
-
-
#[allow(unused_assignments)]
-#[warn(misrefactored_assign_op)]
+#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
fn main() {
let mut a = 5;
a += a + 1;
a %= a % 5;
a &= a & 1;
a *= a * a;
+ a = a * a * a;
+ a = a * 42 * a;
+ a = a * 2 + a;
a -= 1 - a;
a /= 5 / a;
a %= 42 % a;
*self = *self * rhs
}
}
+
+fn cow_add_assign() {
+ use std::borrow::Cow;
+ let mut buf = Cow::Owned(String::from("bar"));
+ let cows = Cow::Borrowed("foo");
+
+ // this can be linted
+ buf = buf + cows.clone();
+
+ // this should not as cow<str> Add is not commutative
+ buf = cows + buf;
+ println!("{}", buf);
+}