File tree 4 files changed +15
-32
lines changed
4 files changed +15
-32
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ impl<'tcx> TyCtxt<'tcx> {
20
20
where
21
21
T : TypeFoldable < TyCtxt < ' tcx > > ,
22
22
{
23
- // If there's nothing to erase avoid performing the query at all
24
- if !value. has_type_flags ( TypeFlags :: HAS_LATE_BOUND | TypeFlags :: HAS_FREE_REGIONS ) {
23
+ // If there's nothing to erase or anonymize, avoid performing the query at all
24
+ if !value. has_type_flags ( TypeFlags :: HAS_BINDER_VARS | TypeFlags :: HAS_FREE_REGIONS ) {
25
25
return value;
26
26
}
27
27
debug ! ( "erase_regions({:?})" , value) ;
Original file line number Diff line number Diff line change @@ -34,26 +34,6 @@ impl FlagComputation {
34
34
result. flags
35
35
}
36
36
37
- pub fn bound_var_flags ( vars : & ty:: List < ty:: BoundVariableKind > ) -> FlagComputation {
38
- let mut computation = FlagComputation :: new ( ) ;
39
-
40
- for bv in vars {
41
- match bv {
42
- ty:: BoundVariableKind :: Ty ( _) => {
43
- computation. flags |= TypeFlags :: HAS_TY_LATE_BOUND ;
44
- }
45
- ty:: BoundVariableKind :: Region ( _) => {
46
- computation. flags |= TypeFlags :: HAS_RE_LATE_BOUND ;
47
- }
48
- ty:: BoundVariableKind :: Const => {
49
- computation. flags |= TypeFlags :: HAS_CT_LATE_BOUND ;
50
- }
51
- }
52
- }
53
-
54
- computation
55
- }
56
-
57
37
fn add_flags ( & mut self , flags : TypeFlags ) {
58
38
self . flags = self . flags | flags;
59
39
}
@@ -77,7 +57,11 @@ impl FlagComputation {
77
57
where
78
58
F : FnOnce ( & mut Self , T ) ,
79
59
{
80
- let mut computation = FlagComputation :: bound_var_flags ( value. bound_vars ( ) ) ;
60
+ let mut computation = FlagComputation :: new ( ) ;
61
+
62
+ if !value. bound_vars ( ) . is_empty ( ) {
63
+ computation. add_flags ( TypeFlags :: HAS_BINDER_VARS ) ;
64
+ }
81
65
82
66
f ( & mut computation, value. skip_binder ( ) ) ;
83
67
Original file line number Diff line number Diff line change @@ -494,15 +494,11 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for HasTypeFlagsVisitor {
494
494
& mut self ,
495
495
t : & Binder < ' tcx , T > ,
496
496
) -> ControlFlow < Self :: BreakTy > {
497
- // If we're looking for any of the HAS_*_LATE_BOUND flags, we need to
498
- // additionally consider the bound vars on the binder itself, even if
499
- // the contents of a the binder (e.g. a `TraitRef`) doesn't reference
500
- // the bound vars.
501
- if self . flags . intersects ( TypeFlags :: HAS_LATE_BOUND ) {
502
- let bound_var_flags = FlagComputation :: bound_var_flags ( t. bound_vars ( ) ) ;
503
- if bound_var_flags. flags . intersects ( self . flags ) {
504
- return ControlFlow :: Break ( FoundFlags ) ;
505
- }
497
+ // If we're looking for the HAS_BINDER_VARS flag, check if the
498
+ // binder has vars. This won't be present in the binder's bound
499
+ // value, so we need to check here too.
500
+ if self . flags . intersects ( TypeFlags :: HAS_BINDER_VARS ) && !t. bound_vars ( ) . is_empty ( ) {
501
+ return ControlFlow :: Break ( FoundFlags ) ;
506
502
}
507
503
508
504
t. super_visit_with ( self )
Original file line number Diff line number Diff line change @@ -115,5 +115,8 @@ bitflags! {
115
115
116
116
/// Does this have `Coroutine` or `CoroutineWitness`?
117
117
const HAS_TY_COROUTINE = 1 << 23 ;
118
+
119
+ /// Does this have any binders with bound vars (e.g. that need to be anonymized)?
120
+ const HAS_BINDER_VARS = 1 << 24 ;
118
121
}
119
122
}
You can’t perform that action at this time.
0 commit comments