@@ -73,7 +73,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
73
73
}
74
74
75
75
fn has_type_flags ( & self , flags : TypeFlags ) -> bool {
76
- self . visit_with ( & mut HasTypeFlagsVisitor { flags } ) . is_break ( )
76
+ self . visit_with ( & mut HasTypeFlagsVisitor { flags } ) . break_value ( ) == Some ( FoundFlags )
77
77
}
78
78
fn has_projections ( & self ) -> bool {
79
79
self . has_type_flags ( TypeFlags :: HAS_PROJECTION )
@@ -901,32 +901,49 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
901
901
}
902
902
}
903
903
904
+ #[ derive( Debug , PartialEq , Eq , Copy , Clone ) ]
905
+ struct FoundFlags ;
906
+
904
907
// FIXME: Optimize for checking for infer flags
905
908
struct HasTypeFlagsVisitor {
906
909
flags : ty:: TypeFlags ,
907
910
}
908
911
909
912
impl < ' tcx > TypeVisitor < ' tcx > for HasTypeFlagsVisitor {
913
+ type BreakTy = FoundFlags ;
914
+
910
915
fn visit_ty ( & mut self , t : Ty < ' _ > ) -> ControlFlow < Self :: BreakTy > {
911
916
debug ! (
912
917
"HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}" ,
913
918
t,
914
919
t. flags( ) ,
915
920
self . flags
916
921
) ;
917
- if t. flags ( ) . intersects ( self . flags ) { ControlFlow :: BREAK } else { ControlFlow :: CONTINUE }
922
+ if t. flags ( ) . intersects ( self . flags ) {
923
+ ControlFlow :: Break ( FoundFlags )
924
+ } else {
925
+ ControlFlow :: CONTINUE
926
+ }
918
927
}
919
928
920
929
fn visit_region ( & mut self , r : ty:: Region < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
921
930
let flags = r. type_flags ( ) ;
922
931
debug ! ( "HasTypeFlagsVisitor: r={:?} r.flags={:?} self.flags={:?}" , r, flags, self . flags) ;
923
- if flags. intersects ( self . flags ) { ControlFlow :: BREAK } else { ControlFlow :: CONTINUE }
932
+ if flags. intersects ( self . flags ) {
933
+ ControlFlow :: Break ( FoundFlags )
934
+ } else {
935
+ ControlFlow :: CONTINUE
936
+ }
924
937
}
925
938
926
939
fn visit_const ( & mut self , c : & ' tcx ty:: Const < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
927
940
let flags = FlagComputation :: for_const ( c) ;
928
941
debug ! ( "HasTypeFlagsVisitor: c={:?} c.flags={:?} self.flags={:?}" , c, flags, self . flags) ;
929
- if flags. intersects ( self . flags ) { ControlFlow :: BREAK } else { ControlFlow :: CONTINUE }
942
+ if flags. intersects ( self . flags ) {
943
+ ControlFlow :: Break ( FoundFlags )
944
+ } else {
945
+ ControlFlow :: CONTINUE
946
+ }
930
947
}
931
948
932
949
fn visit_predicate ( & mut self , predicate : ty:: Predicate < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
@@ -935,7 +952,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor {
935
952
predicate, predicate. inner. flags, self . flags
936
953
) ;
937
954
if predicate. inner . flags . intersects ( self . flags ) {
938
- ControlFlow :: BREAK
955
+ ControlFlow :: Break ( FoundFlags )
939
956
} else {
940
957
ControlFlow :: CONTINUE
941
958
}
0 commit comments