1 #![warn(clippy::redundant_clone)]
3 use std::ffi::OsString;
7 let _ = ["lorem", "ipsum"].join(" ").to_string();
9 let s = String::from("foo");
12 let s = String::from("foo");
13 let _ = s.to_string();
15 let s = String::from("foo");
18 let _ = Path::new("/a/b/").join("c").to_owned();
20 let _ = Path::new("/a/b/").join("c").to_path_buf();
22 let _ = OsString::new().to_owned();
24 let _ = OsString::new().to_os_string();
26 // Check that lint level works
27 #[allow(clippy::redundant_clone)]
28 let _ = String::new().to_string();
30 let tup = (String::from("foo"),);
31 let _ = tup.0.clone();
33 let tup_ref = &(String::from("foo"),);
34 let _s = tup_ref.0.clone(); // this `.clone()` cannot be removed
39 fn with_branch(a: Alpha, b: bool) -> (Alpha, Alpha) {
41 (a.clone(), a.clone())
51 impl Drop for TypeWithDrop {
55 fn cannot_move_from_type_with_drop() -> String {
56 let s = TypeWithDrop { x: String::new() };
57 s.x.clone() // removing this `clone()` summons E0509