Skip to content

Commit e7441cf

Browse files
authored
Rollup merge of rust-lang#98219 - eggyal:gatsubstcollector-without-folding, r=jackh726
Skip late bound regions in GATSubstCollector rust-lang#93227 liberated late bound regions when collecting GAT substs in wfcheck. It should simply skip late bound regions instead. r? `@compiler-errors`
2 parents ebef4ab + c51f508 commit e7441cf

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

compiler/rustc_typeck/src/check/wfcheck.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>(
490490
// The bounds we that we would require from `to_check`
491491
let mut bounds = FxHashSet::default();
492492

493-
let (regions, types) = GATSubstCollector::visit(tcx, gat_def_id.to_def_id(), to_check);
493+
let (regions, types) = GATSubstCollector::visit(gat_def_id.to_def_id(), to_check);
494494

495495
// If both regions and types are empty, then this GAT isn't in the
496496
// 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>(
664664
/// the two vectors, `regions` and `types` (depending on their kind). For each
665665
/// parameter `Pi` also track the index `i`.
666666
struct GATSubstCollector<'tcx> {
667-
tcx: TyCtxt<'tcx>,
668667
gat: DefId,
669668
// Which region appears and which parameter index its substituted for
670669
regions: FxHashSet<(ty::Region<'tcx>, usize)>,
@@ -674,16 +673,11 @@ struct GATSubstCollector<'tcx> {
674673

675674
impl<'tcx> GATSubstCollector<'tcx> {
676675
fn visit<T: TypeFoldable<'tcx>>(
677-
tcx: TyCtxt<'tcx>,
678676
gat: DefId,
679677
t: T,
680678
) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) {
681-
let mut visitor = GATSubstCollector {
682-
tcx,
683-
gat,
684-
regions: FxHashSet::default(),
685-
types: FxHashSet::default(),
686-
};
679+
let mut visitor =
680+
GATSubstCollector { gat, regions: FxHashSet::default(), types: FxHashSet::default() };
687681
t.visit_with(&mut visitor);
688682
(visitor.regions, visitor.types)
689683
}
@@ -692,19 +686,12 @@ impl<'tcx> GATSubstCollector<'tcx> {
692686
impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
693687
type BreakTy = !;
694688

695-
fn visit_binder<T: TypeFoldable<'tcx>>(
696-
&mut self,
697-
t: &ty::Binder<'tcx, T>,
698-
) -> ControlFlow<Self::BreakTy> {
699-
self.tcx.liberate_late_bound_regions(self.gat, t.clone()).visit_with(self)
700-
}
701-
702689
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
703690
match t.kind() {
704691
ty::Projection(p) if p.item_def_id == self.gat => {
705692
for (idx, subst) in p.substs.iter().enumerate() {
706693
match subst.unpack() {
707-
GenericArgKind::Lifetime(lt) => {
694+
GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => {
708695
self.regions.insert((lt, idx));
709696
}
710697
GenericArgKind::Type(t) => {

0 commit comments

Comments
 (0)