@@ -4,7 +4,7 @@ use clippy_utils::source::snippet_with_applicability;
4
4
use clippy_utils:: sugg:: Sugg ;
5
5
use rustc_data_structures:: fx:: FxHashSet ;
6
6
use rustc_errors:: Applicability ;
7
- use rustc_hir:: { self as hir, AmbigArg , HirId , intravisit} ;
7
+ use rustc_hir:: { self as hir, AmbigArg , BorrowKind , Expr , ExprKind , HirId , Mutability , TyKind , intravisit} ;
8
8
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
9
9
use rustc_middle:: ty;
10
10
use rustc_session:: impl_lint_pass;
@@ -42,10 +42,10 @@ impl<'tcx> LateLintPass<'tcx> for MutMut {
42
42
}
43
43
44
44
fn check_ty ( & mut self , cx : & LateContext < ' tcx > , ty : & ' tcx hir:: Ty < ' _ , AmbigArg > ) {
45
- if let hir :: TyKind :: Ref ( _, mty) = ty. kind
46
- && mty. mutbl == hir :: Mutability :: Mut
47
- && let hir :: TyKind :: Ref ( _, mty2) = mty. ty . kind
48
- && mty2. mutbl == hir :: Mutability :: Mut
45
+ if let TyKind :: Ref ( _, mty) = ty. kind
46
+ && mty. mutbl == Mutability :: Mut
47
+ && let TyKind :: Ref ( _, mty2) = mty. ty . kind
48
+ && mty2. mutbl == Mutability :: Mut
49
49
&& !ty. span . in_external_macro ( cx. sess ( ) . source_map ( ) )
50
50
{
51
51
// we have 2+ `&mut`s, e.g., `&mut &mut &mut x`
@@ -76,7 +76,7 @@ pub struct MutVisitor<'a, 'tcx> {
76
76
}
77
77
78
78
impl < ' tcx > intravisit:: Visitor < ' tcx > for MutVisitor < ' _ , ' tcx > {
79
- fn visit_expr ( & mut self , expr : & ' tcx hir :: Expr < ' _ > ) {
79
+ fn visit_expr ( & mut self , expr : & ' tcx Expr < ' _ > ) {
80
80
if expr. span . in_external_macro ( self . cx . sess ( ) . source_map ( ) ) {
81
81
return ;
82
82
}
@@ -90,8 +90,8 @@ impl<'tcx> intravisit::Visitor<'tcx> for MutVisitor<'_, 'tcx> {
90
90
// Let's ignore the generated code.
91
91
intravisit:: walk_expr ( self , arg) ;
92
92
intravisit:: walk_expr ( self , body) ;
93
- } else if let hir :: ExprKind :: AddrOf ( hir :: BorrowKind :: Ref , hir :: Mutability :: Mut , e) = expr. kind {
94
- if let hir :: ExprKind :: AddrOf ( hir :: BorrowKind :: Ref , hir :: Mutability :: Mut , _) = e. kind {
93
+ } else if let ExprKind :: AddrOf ( BorrowKind :: Ref , Mutability :: Mut , e) = expr. kind {
94
+ if let ExprKind :: AddrOf ( BorrowKind :: Ref , Mutability :: Mut , _) = e. kind {
95
95
if !expr. span . eq_ctxt ( e. span ) {
96
96
return ;
97
97
}
@@ -107,7 +107,7 @@ impl<'tcx> intravisit::Visitor<'tcx> for MutVisitor<'_, 'tcx> {
107
107
diag. span_suggestion ( expr. span , "remove the extra `&mut`" , sugg, applicability) ;
108
108
} ,
109
109
) ;
110
- } else if let ty:: Ref ( _, ty, hir :: Mutability :: Mut ) = self . cx . typeck_results ( ) . expr_ty ( e) . kind ( )
110
+ } else if let ty:: Ref ( _, ty, Mutability :: Mut ) = self . cx . typeck_results ( ) . expr_ty ( e) . kind ( )
111
111
&& ty. peel_refs ( ) . is_sized ( self . cx . tcx , self . cx . typing_env ( ) )
112
112
{
113
113
let mut applicability = Applicability :: MaybeIncorrect ;
0 commit comments