1
Fork 0

Change sized_constraints to return EarlyBinder

This commit is contained in:
Jack Huey 2022-08-03 00:14:24 -04:00
parent e21624dc80
commit 96a69dce2c
4 changed files with 10 additions and 5 deletions

View file

@ -563,7 +563,7 @@ impl<'tcx> AdtDef<'tcx> {
/// ///
/// Due to normalization being eager, this applies even if /// Due to normalization being eager, this applies even if
/// the associated type is behind a pointer (e.g., issue #31299). /// the associated type is behind a pointer (e.g., issue #31299).
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> &'tcx [Ty<'tcx>] { pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
tcx.adt_sized_constraint(self.did()).0 ty::EarlyBinder(tcx.adt_sized_constraint(self.did()).0)
} }
} }

View file

@ -2191,7 +2191,7 @@ impl<'tcx> Ty<'tcx> {
ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)), ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
ty::Adt(def, _substs) => def.sized_constraint(tcx).is_empty(), ty::Adt(def, _substs) => def.sized_constraint(tcx).0.is_empty(),
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false, ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,

View file

@ -1883,7 +1883,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let sized_crit = def.sized_constraint(self.tcx()); let sized_crit = def.sized_constraint(self.tcx());
// (*) binder moved here // (*) binder moved here
Where(obligation.predicate.rebind({ Where(obligation.predicate.rebind({
sized_crit.iter().map(|ty| EarlyBinder(*ty).subst(self.tcx(), substs)).collect() sized_crit
.0
.iter()
.map(|ty| sized_crit.rebind(*ty).subst(self.tcx(), substs))
.collect()
})) }))
} }

View file

@ -33,8 +33,9 @@ fn sized_constraint_for_ty<'tcx>(
let adt_tys = adt.sized_constraint(tcx); let adt_tys = adt.sized_constraint(tcx);
debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys); debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys);
adt_tys adt_tys
.0
.iter() .iter()
.map(|ty| EarlyBinder(*ty).subst(tcx, substs)) .map(|ty| adt_tys.rebind(*ty).subst(tcx, substs))
.flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty)) .flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
.collect() .collect()
} }