]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/assign_ops2.rs
iterate List by value
[rust.git] / tests / ui / assign_ops2.rs
index 821f6a1a9bf3be8314104a9724c6e016122d4f5d..4703a8c77778857405266a60d5f20977e1bc59ef 100644 (file)
@@ -1,8 +1,5 @@
-
-
-
 #[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;
@@ -14,6 +11,9 @@ fn main() {
     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;
@@ -40,3 +40,16 @@ fn mul_assign(&mut self, rhs: i64) {
         *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);
+}