diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index ad85ac71fc886..7931215389575 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -490,7 +490,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>( // The bounds we that we would require from `to_check` let mut bounds = FxHashSet::default(); - let (regions, types) = GATSubstCollector::visit(tcx, gat_def_id.to_def_id(), to_check); + let (regions, types) = GATSubstCollector::visit(gat_def_id.to_def_id(), to_check); // If both regions and types are empty, then this GAT isn't in the // set of types we are checking, and we shouldn't try to do clause analysis @@ -664,7 +664,6 @@ fn resolve_regions_with_wf_tys<'tcx>( /// the two vectors, `regions` and `types` (depending on their kind). For each /// parameter `Pi` also track the index `i`. struct GATSubstCollector<'tcx> { - tcx: TyCtxt<'tcx>, gat: DefId, // Which region appears and which parameter index its substituted for regions: FxHashSet<(ty::Region<'tcx>, usize)>, @@ -674,16 +673,11 @@ struct GATSubstCollector<'tcx> { impl<'tcx> GATSubstCollector<'tcx> { fn visit>( - tcx: TyCtxt<'tcx>, gat: DefId, t: T, ) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) { - let mut visitor = GATSubstCollector { - tcx, - gat, - regions: FxHashSet::default(), - types: FxHashSet::default(), - }; + let mut visitor = + GATSubstCollector { gat, regions: FxHashSet::default(), types: FxHashSet::default() }; t.visit_with(&mut visitor); (visitor.regions, visitor.types) } @@ -692,19 +686,12 @@ impl<'tcx> GATSubstCollector<'tcx> { impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> { type BreakTy = !; - fn visit_binder>( - &mut self, - t: &ty::Binder<'tcx, T>, - ) -> ControlFlow { - self.tcx.liberate_late_bound_regions(self.gat, t.clone()).visit_with(self) - } - fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { match t.kind() { ty::Projection(p) if p.item_def_id == self.gat => { for (idx, subst) in p.substs.iter().enumerate() { match subst.unpack() { - GenericArgKind::Lifetime(lt) => { + GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => { self.regions.insert((lt, idx)); } GenericArgKind::Type(t) => {