This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +47
-32
lines changed
tests/ui/late-bound-lifetimes Expand file tree Collapse file tree 5 files changed +47
-32
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,8 @@ impl<'tcx> TyCtxt<'tcx> {
2020 where
2121 T : TypeFoldable < TyCtxt < ' tcx > > ,
2222 {
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 ) {
2525 return value;
2626 }
2727 debug ! ( "erase_regions({:?})" , value) ;
Original file line number Diff line number Diff line change @@ -34,26 +34,6 @@ impl FlagComputation {
3434 result. flags
3535 }
3636
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-
5737 fn add_flags ( & mut self , flags : TypeFlags ) {
5838 self . flags = self . flags | flags;
5939 }
@@ -77,7 +57,11 @@ impl FlagComputation {
7757 where
7858 F : FnOnce ( & mut Self , T ) ,
7959 {
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+ }
8165
8266 f ( & mut computation, value. skip_binder ( ) ) ;
8367
Original file line number Diff line number Diff line change @@ -494,15 +494,11 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for HasTypeFlagsVisitor {
494494 & mut self ,
495495 t : & Binder < ' tcx , T > ,
496496 ) -> 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 ) ;
506502 }
507503
508504 t. super_visit_with ( self )
Original file line number Diff line number Diff line change @@ -115,5 +115,8 @@ bitflags! {
115115
116116 /// Does this have `Coroutine` or `CoroutineWitness`?
117117 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 ;
118121 }
119122}
Original file line number Diff line number Diff line change 1+ // check-pass
2+
3+ trait Foo {
4+ type Assoc ;
5+
6+ fn do_it ( _: & Self :: Assoc )
7+ where
8+ for < ' a > Self : Baz < ' a > ;
9+ }
10+
11+ trait Baz < ' a > : Foo { }
12+
13+ impl Foo for ( ) {
14+ type Assoc = Inherent ;
15+
16+ // Ensure that the `for<'a> Self: Baz<'a>` predicate, which has
17+ // a supertrait `for<'a> Self: Foo`, does not cause us to fail
18+ // to normalize `Self::Assoc`.
19+ fn do_it ( x : & Self :: Assoc )
20+ where
21+ for < ' a > Self : Baz < ' a > ,
22+ {
23+ x. inherent ( ) ;
24+ }
25+ }
26+
27+ struct Inherent ;
28+ impl Inherent {
29+ fn inherent ( & self ) { }
30+ }
31+
32+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments