]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/explicit_auto_deref.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / explicit_auto_deref.rs
index 453b90f09b33c6ca97df96f09eab77880cae58c0..deedafad153b97ae0edd6d777637516d65c33410 100644 (file)
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![feature(closure_lifetime_binder)]
 #![warn(clippy::explicit_auto_deref)]
 #![allow(
     dead_code,
@@ -242,4 +243,27 @@ fn deref_to_u<U, T: core::ops::Deref<Target = U>>(x: &T) -> &U {
     fn ret_any(x: &Box<dyn std::any::Any>) -> &dyn std::any::Any {
         &**x
     }
+
+    let x = String::new();
+    let _: *const str = &*x;
+
+    struct S7([u32; 1]);
+    impl core::ops::Deref for S7 {
+        type Target = [u32; 1];
+        fn deref(&self) -> &Self::Target {
+            &self.0
+        }
+    }
+    let x = S7([0]);
+    let _: &[u32] = &*x;
+
+    let c1 = |_: &Vec<&u32>| {};
+    let x = &&vec![&1u32];
+    c1(*x);
+    let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> {
+        if b {
+            return *x;
+        }
+        *x
+    };
 }