]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/deref_addrof.fixed
Rollup merge of #92849 - flip1995:clippyup, r=Manishearth
[rust.git] / tests / ui / deref_addrof.fixed
index 9e5b51d6d5e6d5da7344e0bdc33bacb163882010..2f489deb1ee1f5910b3acd8038c5de8ac531c877 100644 (file)
@@ -1,4 +1,6 @@
 // run-rustfix
+#![allow(clippy::return_self_not_must_use)]
+#![warn(clippy::deref_addrof)]
 
 fn get_number() -> usize {
     10
@@ -8,9 +10,8 @@ fn get_reference(n: &usize) -> &usize {
     n
 }
 
-#[allow(clippy::many_single_char_names, clippy::double_parens)]
+#[allow(clippy::double_parens)]
 #[allow(unused_variables, unused_parens)]
-#[warn(clippy::deref_addrof)]
 fn main() {
     let a = 10;
     let aref = &a;
@@ -36,4 +37,32 @@ fn main() {
     let b = &a;
 
     let b = *aref;
+
+    let _ = unsafe { *core::ptr::addr_of!(a) };
+}
+
+#[rustfmt::skip]
+macro_rules! m {
+    ($visitor: expr) => {
+        $visitor
+    };
+}
+
+#[rustfmt::skip]
+macro_rules! m_mut {
+    ($visitor: expr) => {
+        $visitor
+    };
+}
+
+#[derive(Copy, Clone)]
+pub struct S;
+impl S {
+    pub fn f(&self) -> &Self {
+        m!(self)
+    }
+    #[allow(unused_mut)] // mut will be unused, once the macro is fixed
+    pub fn f_mut(mut self) -> Self {
+        m_mut!(self)
+    }
 }