X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fui%2Fredundant_clone.fixed;h=f5da703cd1dea5e9d524f8c2950ec629525faec2;hb=f6d1f368db9e726fde825dc2525cdec07673b416;hp=ec309109ed52b485d015f5309c87fe93264776ed;hpb=f2f2a005b4efd3e44ac6a02ea2b9660d28401679;p=rust.git diff --git a/tests/ui/redundant_clone.fixed b/tests/ui/redundant_clone.fixed index ec309109ed5..f5da703cd1d 100644 --- a/tests/ui/redundant_clone.fixed +++ b/tests/ui/redundant_clone.fixed @@ -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(_: &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()); +}