]> git.proxmox.com Git - rustc.git/blobdiff - src/tools/clippy/tests/ui/redundant_clone.fixed
New upstream version 1.53.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / redundant_clone.fixed
index ec309109ed52b485d015f5309c87fe93264776ed..f5da703cd1dea5e9d524f8c2950ec629525faec2 100644 (file)
@@ -54,6 +54,7 @@ fn main() {
     not_consumed();
     issue_5405();
     manually_drop();
+    clone_then_move_cloned();
 }
 
 #[derive(Clone)]
@@ -182,3 +183,26 @@ fn manually_drop() {
         Arc::from_raw(p);
     }
 }
+
+fn clone_then_move_cloned() {
+    // issue #5973
+    let x = Some(String::new());
+    // ok, x is moved while the clone is in use.
+    assert_eq!(x.clone(), None, "not equal {}", x.unwrap());
+
+    // issue #5595
+    fn foo<F: Fn()>(_: &Alpha, _: F) {}
+    let x = Alpha;
+    // ok, data is moved while the clone is in use.
+    foo(&x.clone(), move || {
+        let _ = x;
+    });
+
+    // issue #6998
+    struct S(String);
+    impl S {
+        fn m(&mut self) {}
+    }
+    let mut x = S(String::new());
+    x.0.clone().chars().for_each(|_| x.m());
+}