X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fui%2Fdereference.rs;h=25e1c29e7fa5ff4c45755bcdb34b5b709c53adb5;hb=b6d43305502f15d3c3e1a49f488eedc5ce330b4f;hp=5de201fb22f0b6e56f7d4cef0723906b50efae2e;hpb=c1132434a7cf580a09d08a274bbfd2e776b324f8;p=rust.git diff --git a/tests/ui/dereference.rs b/tests/ui/dereference.rs index 5de201fb22f..25e1c29e7fa 100644 --- a/tests/ui/dereference.rs +++ b/tests/ui/dereference.rs @@ -1,3 +1,5 @@ +// run-rustfix + #![allow(unused_variables, clippy::many_single_char_names, clippy::clone_double_ref)] #![warn(clippy::explicit_deref_method)] @@ -59,4 +61,19 @@ macro_rules! expr_deref { let opt_a = Some(a); let b = opt_a.unwrap().deref(); + + // The struct does not implement Deref trait + #[derive(Copy, Clone)] + struct NoLint(u32); + impl NoLint { + pub fn deref(self) -> u32 { + self.0 + } + pub fn deref_mut(self) -> u32 { + self.0 + } + } + let no_lint = NoLint(42); + let b = no_lint.deref(); + let b = no_lint.deref_mut(); }