1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #[warn(clippy::needless_borrowed_reference)]
11 #[allow(unused_variables)]
13 let mut v = Vec::<String>::new();
14 let _ = v.iter_mut().filter(|&ref a| a.is_empty());
18 let thingy = Some(&var);
19 if let Some(&ref v) = thingy {
24 let thingy2 = Some(&mut var2);
25 if let Some(&mut ref mut v) = thingy2 {
26 // ^ should *not* be linted
27 // v is borrowed as mutable.
30 if let Some(&mut ref v) = thingy2 {
31 // ^ should *not* be linted
32 // here, v is borrowed as immutable.
44 #[allow(unused_variables)]
46 fn foo(a: &Animal, b: &Animal) {
48 (&Animal::Cat(v), &ref k) | (&ref k, &Animal::Cat(v)) => (), // lifetime mismatch error if there is no '&ref'
49 // ^ and ^ should *not* be linted
50 (&Animal::Dog(ref a), &Animal::Dog(_)) => (), // ^ should *not* be linted