1 #![allow(unused_variables, clippy::many_single_char_names, clippy::clone_double_ref)]
2 #![warn(clippy::explicit_deref_method)]
4 use std::ops::{Deref, DerefMut};
7 let a: &mut String = &mut String::from("foo");
9 // these should require linting
10 let b: &str = a.deref();
12 let b: &mut str = a.deref_mut();
14 let b: String = a.deref().clone();
16 let b: usize = a.deref_mut().len();
18 let b: &usize = &a.deref().len();
20 // only first deref should get linted here
21 let b: &str = a.deref().deref();
23 // both derefs should get linted here
24 let b: String = format!("{}, {}", a.deref(), a.deref());
26 // these should not require linting
30 let b: &mut str = &mut *a;
32 macro_rules! expr_deref {
37 let b: &str = expr_deref!(a);