Skip to content

Commit a46d2e6

Browse files
committed
remember all the nested types while we loop
see https://rust-lang.zulipchat.com/#narrow/channel/25732
1 parent eaeaec2 commit a46d2e6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clippy_lints/src/mut_mut.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ impl<'tcx> LateLintPass<'tcx> for MutMut {
5454
if self.seen_tys.contains(&ty.hir_id) {
5555
return;
5656
}
57-
self.seen_tys.insert(mty.ty.hir_id);
5857

5958
// if there is an even longer chain, like `&mut &mut &mut x`, suggest peeling off
6059
// all extra ones at once
6160
let (mut t, mut t2) = (mty.ty, mty2.ty);
6261
let mut many_muts = false;
6362
loop {
63+
// this should allow us to remember all the nested types, so that the `contains`
64+
// above fails faster
65+
self.seen_tys.insert(t.hir_id);
6466
if let TyKind::Ref(_, next) = t2.kind
6567
&& next.mutbl == Mutability::Mut
6668
{

0 commit comments

Comments
 (0)