diff --git a/clippy_tests/examples/needless_borrowed_ref.rs b/clippy_tests/examples/needless_borrowed_ref.rs new file mode 100644 index 00000000000..105a1fa48d4 --- /dev/null +++ b/clippy_tests/examples/needless_borrowed_ref.rs @@ -0,0 +1,9 @@ +#![feature(plugin)] +#![plugin(clippy)] + +#[warn(needless_borrowed_reference)] +fn main() { + let mut v = Vec::::new(); + let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +} + diff --git a/clippy_tests/examples/needless_borrowed_ref.stderr b/clippy_tests/examples/needless_borrowed_ref.stderr new file mode 100644 index 00000000000..658318a3c6a --- /dev/null +++ b/clippy_tests/examples/needless_borrowed_ref.stderr @@ -0,0 +1,8 @@ +warning: this pattern takes a reference on something that is being de-referenced + --> needless_borrowed_ref.rs:7:35 + | +7 | let _ = v.iter_mut().filter(|&ref a| a.is_empty()); + | ^^^^^ + | + = note: #[warn(needless_borrowed_reference)] on by default + = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#needless_borrowed_reference