diff --git a/tests/ui/needless_borrow.rs b/tests/ui/needless_borrow.rs index 1fc36c0be..27ee4d1f6 100644 --- a/tests/ui/needless_borrow.rs +++ b/tests/ui/needless_borrow.rs @@ -18,6 +18,15 @@ fn main() { let vec_val = g(&vec); // should not error, because `&Vec` derefs to `&[T]` h(&"foo"); // should not error, because the `&&str` is required, due to `&Trait` if let Some(ref cake) = Some(&5) {} + let garbl = match 42 { + 44 => &a, + 45 => { + println!("foo"); + &&a // FIXME: this should lint, too + }, + 46 => &&a, + _ => panic!(), + }; } fn f(y: &T) -> T { diff --git a/tests/ui/needless_borrow.stderr b/tests/ui/needless_borrow.stderr index a5d549c98..eab79e63b 100644 --- a/tests/ui/needless_borrow.stderr +++ b/tests/ui/needless_borrow.stderr @@ -19,13 +19,21 @@ error: this pattern creates a reference to a reference | = note: #[deny(needless_borrow)] implied by #[deny(clippy)] -warning: this pattern creates a reference to a reference - --> $DIR/needless_borrow.rs:41:31 +error: this expression borrows a reference that is immediately dereferenced by the compiler + --> $DIR/needless_borrow.rs:27:15 | -41 | let _ = v.iter().filter(|&ref a| a.is_empty()); +27 | 46 => &&a, + | ^^^ + | + = note: #[deny(needless_borrow)] implied by #[deny(clippy)] + +warning: this pattern creates a reference to a reference + --> $DIR/needless_borrow.rs:50:31 + | +50 | let _ = v.iter().filter(|&ref a| a.is_empty()); | ^^^^^ | = note: #[warn(needless_borrow)] on by default -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors