]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/mut_reference.rs
Give more corrected code examples in doc
[rust.git] / clippy_lints / src / mut_reference.rs
index 2d70b65bb1ee597a76816c6f2cd4184802dee019..58a8e1a1064ae7603f46bce495a4a76c70afaff7 100644 (file)
@@ -1,12 +1,12 @@
 use crate::utils::span_lint;
-use rustc::ty::subst::Subst;
-use rustc::ty::{self, Ty};
-use rustc_hir::*;
+use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability};
 use rustc_lint::{LateContext, LateLintPass};
+use rustc_middle::ty::subst::Subst;
+use rustc_middle::ty::{self, Ty};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
 declare_clippy_lint! {
-    /// **What it does:** Detects giving a mutable reference to a function that only
+    /// **What it does:** Detects passing a mutable reference to a function that only
     /// requires an immutable reference.
     ///
     /// **Why is this bad?** The immutable reference rules out all other references
     ///
     /// **Example:**
     /// ```ignore
+    /// // Bad
     /// my_vec.push(&mut value)
+    ///
+    /// // Good
+    /// my_vec.push(&value)
     /// ```
     pub UNNECESSARY_MUT_PASSED,
     style,
@@ -34,7 +38,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) {
                         cx,
                         arguments,
                         cx.tables.expr_ty(fn_expr),
-                        &print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)),
+                        &rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false)),
                     );
                 }
             },