3 #[warn(clippy::needless_borrowed_reference)]
4 #[allow(unused_variables)]
6 let mut v = Vec::<String>::new();
7 let _ = v.iter_mut().filter(|&ref a| a.is_empty());
11 let thingy = Some(&var);
12 if let Some(&ref v) = thingy {
17 let thingy2 = Some(&mut var2);
18 if let Some(&mut ref mut v) = thingy2 {
19 // ^ should **not** be linted
20 // v is borrowed as mutable.
23 if let Some(&mut ref v) = thingy2 {
24 // ^ should **not** be linted
25 // here, v is borrowed as immutable.
37 #[allow(unused_variables)]
39 fn foo(a: &Animal, b: &Animal) {
41 (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref'
42 // ^ and ^ should **not** be linted
43 (&Animal::Dog(ref a), &Animal::Dog(_)) => (), // ^ should **not** be linted