]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/map_clone.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / map_clone.rs
index 2fe078b2752663fd5dcf45e559a1eec475ac2596..b6987336834b84dec65af32aba776a0facbd0150 100644 (file)
@@ -1,9 +1,11 @@
 // run-rustfix
-#![warn(clippy::all, clippy::pedantic)]
-#![allow(clippy::iter_cloned_collect)]
-#![allow(clippy::clone_on_copy, clippy::redundant_clone)]
-#![allow(clippy::missing_docs_in_private_items)]
-#![allow(clippy::redundant_closure_for_method_calls)]
+#![warn(clippy::map_clone)]
+#![allow(
+    clippy::clone_on_copy,
+    clippy::iter_cloned_collect,
+    clippy::many_single_char_names,
+    clippy::redundant_clone
+)]
 
 fn main() {
     let _: Vec<i8> = vec![5_i8; 6].iter().map(|x| *x).collect();
@@ -33,4 +35,29 @@ fn main() {
         let v: Vec<Rc<u32>> = vec![Rc::new(0_u32)];
         let _: Vec<u32> = v.into_iter().map(|x| *x).collect();
     }
+
+    // Issue #5524 mutable references
+    {
+        let mut c = 42;
+        let v = vec![&mut c];
+        let _: Vec<u32> = v.into_iter().map(|x| *x).collect();
+        let mut d = 21;
+        let v = vec![&mut d];
+        let _: Vec<u32> = v.into_iter().map(|&mut x| x).collect();
+    }
+
+    // Issue #6299
+    {
+        let mut aa = 5;
+        let mut bb = 3;
+        let items = vec![&mut aa, &mut bb];
+        let _: Vec<_> = items.into_iter().map(|x| x.clone()).collect();
+    }
+
+    // Issue #6239 deref coercion and clone deref
+    {
+        use std::cell::RefCell;
+
+        let _ = Some(RefCell::new(String::new()).borrow()).map(|s| s.clone());
+    }
 }