]> git.lizzy.rs Git - rust.git/commitdiff
Improve needless_borrowed_ref lint doc.
authorBenoît CORTIER <benoit.cortier@fried-world.eu>
Mon, 26 Jun 2017 12:42:24 +0000 (14:42 +0200)
committerBenoît CORTIER <benoit.cortier@fried-world.eu>
Mon, 26 Jun 2017 12:42:24 +0000 (14:42 +0200)
clippy_lints/src/needless_borrowed_ref.rs

index 5eadf0116f0c5cb3970f425494fd86df0b57a248..dd6f1f22bd6b0bfd6bb3536985733999ebc96b96 100644 (file)
@@ -1,4 +1,4 @@
-//! Checks for useless borrowed references in clojures.
+//! Checks for useless borrowed references.
 //!
 //! This lint is **warn** by default
 
@@ -7,9 +7,9 @@
 use rustc::ty;
 use utils::{span_lint, in_macro};
 
-/// **What it does:** Checks for useless borrowed references in clojures.
+/// **What it does:** Checks for useless borrowed references.
 ///
-/// **Why is this bad?** TODO
+/// **Why is this bad?** It is completely useless and make the code look more complex than it actually is.
 ///
 /// **Known problems:** None.
 ///
@@ -18,7 +18,8 @@
 ///     let mut v = Vec::<String>::new();
 ///     let _ = v.iter_mut().filter(|&ref a| a.is_empty());
 /// ```
-/// It could just be |a| a.is_empty()
+/// This clojure takes a reference on something that has been matched as a reference and de-referenced.
+/// As such, it could just be |a| a.is_empty()
 declare_lint! {
     pub NEEDLESS_BORROWED_REFERENCE,
     Warn,
@@ -50,7 +51,7 @@ fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
             // This is an immutable reference.
             tam.mutbl == MutImmutable,
         ], {
-            span_lint(cx, NEEDLESS_BORROWED_REFERENCE, pat.span, "this pattern takes a needless borrowed reference")
+            span_lint(cx, NEEDLESS_BORROWED_REFERENCE, pat.span, "this pattern takes a reference on something that is being de-referenced")
         }}
     }
 }