]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/unnecessary_clone.rs
iterate List by value
[rust.git] / tests / ui / unnecessary_clone.rs
index 6dff8d87bae0df29acfe224711372217a6193176..f1cc5b564c1dca66329e21bf9b3c02cc22c7ce4d 100644 (file)
@@ -13,6 +13,10 @@ impl SomeTrait for SomeImpl {}
 
 fn main() {}
 
+fn is_ascii(ch: char) -> bool {
+    ch.is_ascii()
+}
+
 fn clone_on_copy() {
     42.clone();
 
@@ -27,6 +31,11 @@ fn clone_on_copy() {
     let mut x = 43;
     let _ = &x.clone(); // ok, getting a ref
     'a'.clone().make_ascii_uppercase(); // ok, clone and then mutate
+    is_ascii('z'.clone());
+
+    // Issue #5436
+    let mut vec = Vec::new();
+    vec.push(42.clone());
 }
 
 fn clone_on_ref_ptr() {
@@ -100,4 +109,9 @@ fn go1() {
         let _: E = a.clone();
         let _: E = *****a;
     }
+
+    fn check(mut encoded: &[u8]) {
+        let _ = &mut encoded.clone();
+        let _ = &encoded.clone();
+    }
 }