@@ -312,7 +312,7 @@ fn check_gat_where_clauses(
312
312
// of the function signature. In our example, the GAT in the return
313
313
// type is `<Self as LendingIterator>::Item<'a>`, so 'a and Self are arguments.
314
314
let ( regions, types) =
315
- GATSubstCollector :: visit ( trait_item. def_id . to_def_id ( ) , sig. output ( ) ) ;
315
+ GATSubstCollector :: visit ( tcx , trait_item. def_id . to_def_id ( ) , sig. output ( ) ) ;
316
316
317
317
// If both regions and types are empty, then this GAT isn't in the
318
318
// return type, and we shouldn't try to do clause analysis
@@ -602,6 +602,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
602
602
/// the two vectors, `regions` and `types` (depending on their kind). For each
603
603
/// parameter `Pi` also track the index `i`.
604
604
struct GATSubstCollector < ' tcx > {
605
+ tcx : TyCtxt < ' tcx > ,
605
606
gat : DefId ,
606
607
// Which region appears and which parameter index its subsituted for
607
608
regions : FxHashSet < ( ty:: Region < ' tcx > , usize ) > ,
@@ -611,11 +612,16 @@ struct GATSubstCollector<'tcx> {
611
612
612
613
impl < ' tcx > GATSubstCollector < ' tcx > {
613
614
fn visit < T : TypeFoldable < ' tcx > > (
615
+ tcx : TyCtxt < ' tcx > ,
614
616
gat : DefId ,
615
617
t : T ,
616
618
) -> ( FxHashSet < ( ty:: Region < ' tcx > , usize ) > , FxHashSet < ( Ty < ' tcx > , usize ) > ) {
617
- let mut visitor =
618
- GATSubstCollector { gat, regions : FxHashSet :: default ( ) , types : FxHashSet :: default ( ) } ;
619
+ let mut visitor = GATSubstCollector {
620
+ tcx,
621
+ gat,
622
+ regions : FxHashSet :: default ( ) ,
623
+ types : FxHashSet :: default ( ) ,
624
+ } ;
619
625
t. visit_with ( & mut visitor) ;
620
626
( visitor. regions , visitor. types )
621
627
}
@@ -624,6 +630,13 @@ impl<'tcx> GATSubstCollector<'tcx> {
624
630
impl < ' tcx > TypeVisitor < ' tcx > for GATSubstCollector < ' tcx > {
625
631
type BreakTy = !;
626
632
633
+ fn visit_binder < T : TypeFoldable < ' tcx > > (
634
+ & mut self ,
635
+ t : & ty:: Binder < ' tcx , T > ,
636
+ ) -> ControlFlow < Self :: BreakTy > {
637
+ self . tcx . liberate_late_bound_regions ( self . gat , t. clone ( ) ) . visit_with ( self )
638
+ }
639
+
627
640
fn visit_ty ( & mut self , t : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
628
641
match t. kind ( ) {
629
642
ty:: Projection ( p) if p. item_def_id == self . gat => {
0 commit comments