Use TypeVisitor::BreakTy
in HasEscapingVarsVisitor
This commit is contained in:
parent
29b140a1c3
commit
44f7d8fcf6
@ -818,6 +818,9 @@ where
|
|||||||
value.fold_with(&mut Shifter::new(tcx, amount))
|
value.fold_with(&mut Shifter::new(tcx, amount))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
|
struct FoundEscapingVars;
|
||||||
|
|
||||||
/// An "escaping var" is a bound var whose binder is not part of `t`. A bound var can be a
|
/// An "escaping var" is a bound var whose binder is not part of `t`. A bound var can be a
|
||||||
/// bound region or a bound type.
|
/// bound region or a bound type.
|
||||||
///
|
///
|
||||||
@ -849,6 +852,8 @@ struct HasEscapingVarsVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||||
|
type BreakTy = FoundEscapingVars;
|
||||||
|
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
||||||
self.outer_index.shift_in(1);
|
self.outer_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
@ -863,7 +868,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
|||||||
// `outer_exclusive_binder` is always 1 higher than the
|
// `outer_exclusive_binder` is always 1 higher than the
|
||||||
// content in `t`). Therefore, `t` has some escaping vars.
|
// content in `t`). Therefore, `t` has some escaping vars.
|
||||||
if t.outer_exclusive_binder > self.outer_index {
|
if t.outer_exclusive_binder > self.outer_index {
|
||||||
ControlFlow::BREAK
|
ControlFlow::Break(FoundEscapingVars)
|
||||||
} else {
|
} else {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
@ -874,7 +879,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
|||||||
// of outer index, then it escapes the binders we have
|
// of outer index, then it escapes the binders we have
|
||||||
// visited.
|
// visited.
|
||||||
if r.bound_at_or_above_binder(self.outer_index) {
|
if r.bound_at_or_above_binder(self.outer_index) {
|
||||||
ControlFlow::BREAK
|
ControlFlow::Break(FoundEscapingVars)
|
||||||
} else {
|
} else {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
@ -887,14 +892,16 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
|||||||
// const, as it has types/regions embedded in a lot of other
|
// const, as it has types/regions embedded in a lot of other
|
||||||
// places.
|
// places.
|
||||||
match ct.val {
|
match ct.val {
|
||||||
ty::ConstKind::Bound(debruijn, _) if debruijn >= self.outer_index => ControlFlow::BREAK,
|
ty::ConstKind::Bound(debruijn, _) if debruijn >= self.outer_index => {
|
||||||
|
ControlFlow::Break(FoundEscapingVars)
|
||||||
|
}
|
||||||
_ => ct.super_visit_with(self),
|
_ => ct.super_visit_with(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
|
fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||||
if predicate.inner.outer_exclusive_binder > self.outer_index {
|
if predicate.inner.outer_exclusive_binder > self.outer_index {
|
||||||
ControlFlow::BREAK
|
ControlFlow::Break(FoundEscapingVars)
|
||||||
} else {
|
} else {
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user