Skip to content

Commit 0b58d9d

Browse files
committed
correct bug in the "has escaping regions" visitor
Existing code could overlook types/substitutions that are embedded in (e.g.) an unevaluated constant.
1 parent 25d04f8 commit 0b58d9d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/librustc/ty/fold.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -911,13 +911,15 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
911911
}
912912

913913
fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> bool {
914-
if let ty::Const {
915-
val: ConstValue::Infer(ty::InferConst::Canonical(debruijn, _)),
916-
..
917-
} = *ct {
918-
debruijn >= self.outer_index
919-
} else {
920-
false
914+
// we don't have a `visit_infer_const` callback, so we have to
915+
// hook in here to catch this case (annoying...), but
916+
// otherwise we do want to remember to visit the rest of the
917+
// const, as it has types/regions embedded in a lot of other
918+
// places.
919+
match ct.val {
920+
ConstValue::Infer(ty::InferConst::Canonical(debruijn, _))
921+
if debruijn >= self.outer_index => true,
922+
_ => ct.super_visit_with(self),
921923
}
922924
}
923925
}

0 commit comments

Comments
 (0)