]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/needless_borrowed_ref.rs
4 #[warn(needless_borrowed_reference)]
5 #[allow(unused_variables)]
7 let mut v
= Vec
::<String
>::new();
8 let _
= v
.iter_mut().filter(|&ref a
| a
.is_empty());
12 let thingy
= Some(&var
);
13 if let Some(&ref v
) = thingy
{
18 let thingy2
= Some(&mut var2
);
19 if let Some(&mut ref mut v
) = thingy2
{
20 // ^ should *not* be linted
21 // v is borrowed as mutable.
24 if let Some(&mut ref v
) = thingy2
{
25 // ^ should *not* be linted
26 // here, v is borrowed as immutable.
38 #[allow(unused_variables)]
40 fn foo(a
: &Animal
, b
: &Animal
) {
42 (&Animal
::Cat(v
), &ref k
) | (&ref k
, &Animal
::Cat(v
)) => (), // lifetime mismatch error if there is no '&ref'
43 // ^ and ^ should *not* be linted
44 (&Animal
::Dog(ref a
), &Animal
::Dog(_
)) => ()
45 // ^ should *not* be linted