]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/mut_mut.rs
Last PR adjustments
[rust.git] / clippy_lints / src / mut_mut.rs
index cb16f00047a394b06b147151fd0244f9bde86274..bc90e131b7f3be65b1ff008599796c50d5da7f7f 100644 (file)
@@ -68,13 +68,15 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
                     expr.span,
                     "generally you want to avoid `&mut &mut _` if possible",
                 );
-            } else if let ty::Ref(_, _, hir::Mutability::Mut) = self.cx.typeck_results().expr_ty(e).kind() {
-                span_lint(
-                    self.cx,
-                    MUT_MUT,
-                    expr.span,
-                    "this expression mutably borrows a mutable reference. Consider reborrowing",
-                );
+            } else if let ty::Ref(_, ty, hir::Mutability::Mut) = self.cx.typeck_results().expr_ty(e).kind() {
+                if ty.peel_refs().is_sized(self.cx.tcx, self.cx.param_env) {
+                    span_lint(
+                        self.cx,
+                        MUT_MUT,
+                        expr.span,
+                        "this expression mutably borrows a mutable reference. Consider reborrowing",
+                    );
+                }
             }
         }
     }