Convert adt_sized_constraint to early-binder, use list
This commit is contained in:
parent
abd3637e42
commit
8696fa71b3
@ -706,7 +706,7 @@
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query adt_sized_constraint(key: DefId) -> &'tcx [Ty<'tcx>] {
|
||||
query adt_sized_constraint(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||
desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
|
@ -572,8 +572,8 @@ pub fn destructor(self, tcx: TyCtxt<'tcx>) -> Option<Destructor> {
|
||||
///
|
||||
/// Due to normalization being eager, this applies even if
|
||||
/// the associated type is behind a pointer (e.g., issue #31299).
|
||||
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
|
||||
ty::EarlyBinder::bind(tcx.adt_sized_constraint(self.did()))
|
||||
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||
tcx.adt_sized_constraint(self.did())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
|
||||
|
||||
ty::Adt(def, args) => {
|
||||
let sized_crit = def.sized_constraint(ecx.tcx());
|
||||
Ok(sized_crit.iter_instantiated_copied(ecx.tcx(), args).collect())
|
||||
Ok(sized_crit.iter_instantiated(ecx.tcx(), args).collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2099,7 +2099,7 @@ fn sized_conditions(
|
||||
Where(
|
||||
obligation
|
||||
.predicate
|
||||
.rebind(sized_crit.iter_instantiated_copied(self.tcx(), args).collect()),
|
||||
.rebind(sized_crit.iter_instantiated(self.tcx(), args).collect()),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ fn sized_constraint_for_ty<'tcx>(
|
||||
let adt_tys = adt.sized_constraint(tcx);
|
||||
debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys);
|
||||
adt_tys
|
||||
.iter_instantiated_copied(tcx, args)
|
||||
.iter_instantiated(tcx, args)
|
||||
.flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
|
||||
.collect()
|
||||
}
|
||||
@ -92,10 +92,13 @@ fn defaultness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Defaultness {
|
||||
/// - a tuple of type parameters or projections, if there are multiple
|
||||
/// such.
|
||||
/// - an Error, if a type is infinitely sized
|
||||
fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
|
||||
fn adt_sized_constraint<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
def_id: DefId,
|
||||
) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||
if let Some(def_id) = def_id.as_local() {
|
||||
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
|
||||
return tcx.mk_type_list(&[Ty::new_misc_error(tcx)]);
|
||||
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_misc_error(tcx)]));
|
||||
}
|
||||
}
|
||||
let def = tcx.adt_def(def_id);
|
||||
@ -107,7 +110,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
|
||||
|
||||
debug!("adt_sized_constraint: {:?} => {:?}", def, result);
|
||||
|
||||
result
|
||||
ty::EarlyBinder::bind(result)
|
||||
}
|
||||
|
||||
/// See `ParamEnv` struct definition for details.
|
||||
|
Loading…
Reference in New Issue
Block a user