@@ -848,16 +848,18 @@ impl<'tcx> ctxt<'tcx> {
848
848
// recursing over the type itself.
849
849
bitflags ! {
850
850
flags TypeFlags : u32 {
851
- const NO_TYPE_FLAGS = 0b0 ,
852
- const HAS_PARAMS = 0b1 ,
853
- const HAS_SELF = 0b10 ,
854
- const HAS_TY_INFER = 0b100 ,
855
- const HAS_RE_INFER = 0b1000 ,
856
- const HAS_RE_LATE_BOUND = 0b10000 ,
857
- const HAS_REGIONS = 0b100000 ,
858
- const HAS_TY_ERR = 0b1000000 ,
859
- const HAS_PROJECTION = 0b10000000 ,
860
- const NEEDS_SUBST = HAS_PARAMS . bits | HAS_SELF . bits | HAS_REGIONS . bits,
851
+ const NO_TYPE_FLAGS = 0 ,
852
+ const HAS_PARAMS = 1 << 0 ,
853
+ const HAS_SELF = 1 << 1 ,
854
+ const HAS_TY_INFER = 1 << 2 ,
855
+ const HAS_RE_INFER = 1 << 3 ,
856
+ const HAS_RE_LATE_BOUND = 1 << 4 ,
857
+ const HAS_REGIONS = 1 << 5 ,
858
+ const HAS_TY_ERR = 1 << 6 ,
859
+ const HAS_PROJECTION = 1 << 7 ,
860
+ const NEEDS_SUBST = TypeFlags :: HAS_PARAMS . bits |
861
+ TypeFlags :: HAS_SELF . bits |
862
+ TypeFlags :: HAS_REGIONS . bits,
861
863
}
862
864
}
863
865
@@ -890,8 +892,8 @@ macro_rules! sty_debug_print {
890
892
ty:: ty_err => /* unimportant */ continue ,
891
893
$( ty:: $variant( ..) => & mut $variant, ) *
892
894
} ;
893
- let region = t. flags. intersects( ty:: HAS_RE_INFER ) ;
894
- let ty = t. flags. intersects( ty:: HAS_TY_INFER ) ;
895
+ let region = t. flags. intersects( ty:: TypeFlags :: HAS_RE_INFER ) ;
896
+ let ty = t. flags. intersects( ty:: TypeFlags :: HAS_TY_INFER ) ;
895
897
896
898
variant. total += 1 ;
897
899
total. total += 1 ;
@@ -993,23 +995,23 @@ impl<'tcx> Borrow<sty<'tcx>> for InternedTy<'tcx> {
993
995
}
994
996
995
997
pub fn type_has_params ( ty : Ty ) -> bool {
996
- ty. flags . intersects ( HAS_PARAMS )
998
+ ty. flags . intersects ( TypeFlags :: HAS_PARAMS )
997
999
}
998
1000
pub fn type_has_self ( ty : Ty ) -> bool {
999
- ty. flags . intersects ( HAS_SELF )
1001
+ ty. flags . intersects ( TypeFlags :: HAS_SELF )
1000
1002
}
1001
1003
pub fn type_has_ty_infer ( ty : Ty ) -> bool {
1002
- ty. flags . intersects ( HAS_TY_INFER )
1004
+ ty. flags . intersects ( TypeFlags :: HAS_TY_INFER )
1003
1005
}
1004
1006
pub fn type_needs_infer ( ty : Ty ) -> bool {
1005
- ty. flags . intersects ( HAS_TY_INFER | HAS_RE_INFER )
1007
+ ty. flags . intersects ( TypeFlags :: HAS_TY_INFER | TypeFlags :: HAS_RE_INFER )
1006
1008
}
1007
1009
pub fn type_has_projection ( ty : Ty ) -> bool {
1008
- ty. flags . intersects ( HAS_PROJECTION )
1010
+ ty. flags . intersects ( TypeFlags :: HAS_PROJECTION )
1009
1011
}
1010
1012
1011
1013
pub fn type_has_late_bound_regions ( ty : Ty ) -> bool {
1012
- ty. flags . intersects ( HAS_RE_LATE_BOUND )
1014
+ ty. flags . intersects ( TypeFlags :: HAS_RE_LATE_BOUND )
1013
1015
}
1014
1016
1015
1017
/// An "escaping region" is a bound region whose binder is not part of `t`.
@@ -2810,7 +2812,7 @@ struct FlagComputation {
2810
2812
2811
2813
impl FlagComputation {
2812
2814
fn new ( ) -> FlagComputation {
2813
- FlagComputation { flags : NO_TYPE_FLAGS , depth : 0 }
2815
+ FlagComputation { flags : TypeFlags :: NO_TYPE_FLAGS , depth : 0 }
2814
2816
}
2815
2817
2816
2818
fn for_sty ( st : & sty ) -> FlagComputation {
@@ -2855,20 +2857,20 @@ impl FlagComputation {
2855
2857
2856
2858
// You might think that we could just return ty_err for
2857
2859
// any type containing ty_err as a component, and get
2858
- // rid of the HAS_TY_ERR flag -- likewise for ty_bot (with
2860
+ // rid of the TypeFlags:: HAS_TY_ERR flag -- likewise for ty_bot (with
2859
2861
// the exception of function types that return bot).
2860
2862
// But doing so caused sporadic memory corruption, and
2861
2863
// neither I (tjc) nor nmatsakis could figure out why,
2862
2864
// so we're doing it this way.
2863
2865
& ty_err => {
2864
- self . add_flags ( HAS_TY_ERR )
2866
+ self . add_flags ( TypeFlags :: HAS_TY_ERR )
2865
2867
}
2866
2868
2867
2869
& ty_param( ref p) => {
2868
2870
if p. space == subst:: SelfSpace {
2869
- self . add_flags ( HAS_SELF ) ;
2871
+ self . add_flags ( TypeFlags :: HAS_SELF ) ;
2870
2872
} else {
2871
- self . add_flags ( HAS_PARAMS ) ;
2873
+ self . add_flags ( TypeFlags :: HAS_PARAMS ) ;
2872
2874
}
2873
2875
}
2874
2876
@@ -2877,15 +2879,15 @@ impl FlagComputation {
2877
2879
}
2878
2880
2879
2881
& ty_infer( _) => {
2880
- self . add_flags ( HAS_TY_INFER )
2882
+ self . add_flags ( TypeFlags :: HAS_TY_INFER )
2881
2883
}
2882
2884
2883
2885
& ty_enum( _, substs) | & ty_struct( _, substs) => {
2884
2886
self . add_substs ( substs) ;
2885
2887
}
2886
2888
2887
2889
& ty_projection( ref data) => {
2888
- self . add_flags ( HAS_PROJECTION ) ;
2890
+ self . add_flags ( TypeFlags :: HAS_PROJECTION ) ;
2889
2891
self . add_projection_ty ( data) ;
2890
2892
}
2891
2893
@@ -2949,11 +2951,11 @@ impl FlagComputation {
2949
2951
}
2950
2952
2951
2953
fn add_region ( & mut self , r : Region ) {
2952
- self . add_flags ( HAS_REGIONS ) ;
2954
+ self . add_flags ( TypeFlags :: HAS_REGIONS ) ;
2953
2955
match r {
2954
- ty:: ReInfer ( _) => { self . add_flags ( HAS_RE_INFER ) ; }
2956
+ ty:: ReInfer ( _) => { self . add_flags ( TypeFlags :: HAS_RE_INFER ) ; }
2955
2957
ty:: ReLateBound ( debruijn, _) => {
2956
- self . add_flags ( HAS_RE_LATE_BOUND ) ;
2958
+ self . add_flags ( TypeFlags :: HAS_RE_LATE_BOUND ) ;
2957
2959
self . add_depth ( debruijn. depth ) ;
2958
2960
}
2959
2961
_ => { }
@@ -3307,11 +3309,11 @@ pub fn type_is_nil(ty: Ty) -> bool {
3307
3309
}
3308
3310
3309
3311
pub fn type_is_error ( ty : Ty ) -> bool {
3310
- ty. flags . intersects ( HAS_TY_ERR )
3312
+ ty. flags . intersects ( TypeFlags :: HAS_TY_ERR )
3311
3313
}
3312
3314
3313
3315
pub fn type_needs_subst ( ty : Ty ) -> bool {
3314
- ty. flags . intersects ( NEEDS_SUBST )
3316
+ ty. flags . intersects ( TypeFlags :: NEEDS_SUBST )
3315
3317
}
3316
3318
3317
3319
pub fn trait_ref_contains_error ( tref : & ty:: TraitRef ) -> bool {
0 commit comments