@@ -818,6 +818,9 @@ where
818
818
value. fold_with ( & mut Shifter :: new ( tcx, amount) )
819
819
}
820
820
821
+ #[ derive( Debug , PartialEq , Eq , Copy , Clone ) ]
822
+ struct FoundEscapingVars ;
823
+
821
824
/// An "escaping var" is a bound var whose binder is not part of `t`. A bound var can be a
822
825
/// bound region or a bound type.
823
826
///
@@ -849,6 +852,8 @@ struct HasEscapingVarsVisitor {
849
852
}
850
853
851
854
impl < ' tcx > TypeVisitor < ' tcx > for HasEscapingVarsVisitor {
855
+ type BreakTy = FoundEscapingVars ;
856
+
852
857
fn visit_binder < T : TypeFoldable < ' tcx > > ( & mut self , t : & Binder < T > ) -> ControlFlow < Self :: BreakTy > {
853
858
self . outer_index . shift_in ( 1 ) ;
854
859
let result = t. super_visit_with ( self ) ;
@@ -863,7 +868,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
863
868
// `outer_exclusive_binder` is always 1 higher than the
864
869
// content in `t`). Therefore, `t` has some escaping vars.
865
870
if t. outer_exclusive_binder > self . outer_index {
866
- ControlFlow :: BREAK
871
+ ControlFlow :: Break ( FoundEscapingVars )
867
872
} else {
868
873
ControlFlow :: CONTINUE
869
874
}
@@ -874,7 +879,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
874
879
// of outer index, then it escapes the binders we have
875
880
// visited.
876
881
if r. bound_at_or_above_binder ( self . outer_index ) {
877
- ControlFlow :: BREAK
882
+ ControlFlow :: Break ( FoundEscapingVars )
878
883
} else {
879
884
ControlFlow :: CONTINUE
880
885
}
@@ -887,14 +892,16 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
887
892
// const, as it has types/regions embedded in a lot of other
888
893
// places.
889
894
match ct. val {
890
- ty:: ConstKind :: Bound ( debruijn, _) if debruijn >= self . outer_index => ControlFlow :: BREAK ,
895
+ ty:: ConstKind :: Bound ( debruijn, _) if debruijn >= self . outer_index => {
896
+ ControlFlow :: Break ( FoundEscapingVars )
897
+ }
891
898
_ => ct. super_visit_with ( self ) ,
892
899
}
893
900
}
894
901
895
902
fn visit_predicate ( & mut self , predicate : ty:: Predicate < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
896
903
if predicate. inner . outer_exclusive_binder > self . outer_index {
897
- ControlFlow :: BREAK
904
+ ControlFlow :: Break ( FoundEscapingVars )
898
905
} else {
899
906
ControlFlow :: CONTINUE
900
907
}
0 commit comments