diff options
| author | Alan Egerton <eggyal@gmail.com> | 2022-06-18 04:11:47 +0100 |
|---|---|---|
| committer | Alan Egerton <eggyal@gmail.com> | 2022-06-18 04:49:07 +0100 |
| commit | c51f5081f08dacdf498115c30fa7edb19a0bb5a0 (patch) | |
| tree | d3cd9f04bd430dee712fc3d19d2136997011ee36 | |
| parent | aaf100597cc6986d5ebd005d58a9394dd6edef4d (diff) | |
| download | rust-c51f5081f08dacdf498115c30fa7edb19a0bb5a0.tar.gz rust-c51f5081f08dacdf498115c30fa7edb19a0bb5a0.zip | |
Skip late bound regions in GATSubstCollector
#93227 liberated late bound regions when collecting GAT substs in wfcheck. It should simply skip late bound regions instead. r? @compiler-errors
| -rw-r--r-- | compiler/rustc_typeck/src/check/wfcheck.rs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 2db5f5d4071..75340d35d40 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<T: TypeFoldable<'tcx>>( - 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<T: TypeFoldable<'tcx>>( - &mut self, - t: &ty::Binder<'tcx, T>, - ) -> ControlFlow<Self::BreakTy> { - self.tcx.liberate_late_bound_regions(self.gat, t.clone()).visit_with(self) - } - fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> { 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) => { |
