Convert adt_sized_constraint to early-binder, use list
This commit is contained in:
parent
abd3637e42
commit
8696fa71b3
@ -706,7 +706,7 @@ rustc_queries! {
|
|||||||
separate_provide_extern
|
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) }
|
desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -572,8 +572,8 @@ 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>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
|
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||||
ty::EarlyBinder::bind(tcx.adt_sized_constraint(self.did()))
|
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) => {
|
ty::Adt(def, args) => {
|
||||||
let sized_crit = def.sized_constraint(ecx.tcx());
|
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 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
|
|||||||
Where(
|
Where(
|
||||||
obligation
|
obligation
|
||||||
.predicate
|
.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);
|
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
|
||||||
.iter_instantiated_copied(tcx, args)
|
.iter_instantiated(tcx, args)
|
||||||
.flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
|
.flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
|
||||||
.collect()
|
.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
|
/// - a tuple of type parameters or projections, if there are multiple
|
||||||
/// such.
|
/// such.
|
||||||
/// - an Error, if a type is infinitely sized
|
/// - 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 let Some(def_id) = def_id.as_local() {
|
||||||
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
|
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);
|
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);
|
debug!("adt_sized_constraint: {:?} => {:?}", def, result);
|
||||||
|
|
||||||
result
|
ty::EarlyBinder::bind(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// See `ParamEnv` struct definition for details.
|
/// See `ParamEnv` struct definition for details.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user