]> git.lizzy.rs Git - rust.git/commitdiff
Add needless_borrowed_ref example.
authorBenoît CORTIER <benoit.cortier@fried-world.eu>
Thu, 29 Jun 2017 11:46:07 +0000 (13:46 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 21 Aug 2017 12:00:32 +0000 (14:00 +0200)
clippy_tests/examples/needless_borrowed_ref.rs [new file with mode: 0644]
clippy_tests/examples/needless_borrowed_ref.stderr [new file with mode: 0644]

diff --git a/clippy_tests/examples/needless_borrowed_ref.rs b/clippy_tests/examples/needless_borrowed_ref.rs
new file mode 100644 (file)
index 0000000..105a1fa
--- /dev/null
@@ -0,0 +1,9 @@
+#![feature(plugin)]
+#![plugin(clippy)]
+
+#[warn(needless_borrowed_reference)]
+fn main() {
+    let mut v = Vec::<String>::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 (file)
index 0000000..658318a
--- /dev/null
@@ -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