]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/assign_ops2.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / assign_ops2.rs
index c3f5083bb1f9428f626c128e76e2a6c978e12aa8..24d0d77a20dacc6f8b39971445ecf53afc5c3acb 100644 (file)
@@ -1,5 +1,11 @@
-#![feature(tool_lints)]
-
+// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
 
 #[allow(unused_assignments)]
 #[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
@@ -43,3 +49,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);
+}