Skip to content

Commit 139dad8

Browse files
committed
mut_mut: Delay macro check
1 parent c226088 commit 139dad8

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

clippy_lints/src/mut_mut.rs

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,18 @@ impl<'tcx> LateLintPass<'tcx> for MutMut {
3535
}
3636

3737
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'_>) {
38-
if in_external_macro(cx.sess(), ty.span) {
39-
return;
40-
}
41-
42-
if let hir::TyKind::Ref(
43-
_,
44-
hir::MutTy {
45-
ty: pty,
46-
mutbl: hir::Mutability::Mut,
47-
},
48-
) = ty.kind
38+
if let hir::TyKind::Ref(_, mty) = ty.kind
39+
&& mty.mutbl == hir::Mutability::Mut
40+
&& let hir::TyKind::Ref(_, mty) = mty.ty.kind
41+
&& mty.mutbl == hir::Mutability::Mut
42+
&& !in_external_macro(cx.sess(), ty.span)
4943
{
50-
if let hir::TyKind::Ref(
51-
_,
52-
hir::MutTy {
53-
mutbl: hir::Mutability::Mut,
54-
..
55-
},
56-
) = pty.kind
57-
{
58-
span_lint(
59-
cx,
60-
MUT_MUT,
61-
ty.span,
62-
"generally you want to avoid `&mut &mut _` if possible",
63-
);
64-
}
44+
span_lint(
45+
cx,
46+
MUT_MUT,
47+
ty.span,
48+
"generally you want to avoid `&mut &mut _` if possible",
49+
);
6550
}
6651
}
6752
}

0 commit comments

Comments
 (0)