mut_mut
: Delay macro check
This commit is contained in:
parent
c22608823f
commit
139dad8849
@ -35,33 +35,18 @@ impl<'tcx> LateLintPass<'tcx> for MutMut {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'_>) {
|
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx hir::Ty<'_>) {
|
||||||
if in_external_macro(cx.sess(), ty.span) {
|
if let hir::TyKind::Ref(_, mty) = ty.kind
|
||||||
return;
|
&& mty.mutbl == hir::Mutability::Mut
|
||||||
}
|
&& let hir::TyKind::Ref(_, mty) = mty.ty.kind
|
||||||
|
&& mty.mutbl == hir::Mutability::Mut
|
||||||
if let hir::TyKind::Ref(
|
&& !in_external_macro(cx.sess(), ty.span)
|
||||||
_,
|
|
||||||
hir::MutTy {
|
|
||||||
ty: pty,
|
|
||||||
mutbl: hir::Mutability::Mut,
|
|
||||||
},
|
|
||||||
) = ty.kind
|
|
||||||
{
|
{
|
||||||
if let hir::TyKind::Ref(
|
span_lint(
|
||||||
_,
|
cx,
|
||||||
hir::MutTy {
|
MUT_MUT,
|
||||||
mutbl: hir::Mutability::Mut,
|
ty.span,
|
||||||
..
|
"generally you want to avoid `&mut &mut _` if possible",
|
||||||
},
|
);
|
||||||
) = pty.kind
|
|
||||||
{
|
|
||||||
span_lint(
|
|
||||||
cx,
|
|
||||||
MUT_MUT,
|
|
||||||
ty.span,
|
|
||||||
"generally you want to avoid `&mut &mut _` if possible",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user