clean up ADT sized constraint computation
This commit is contained in:
@@ -703,8 +703,8 @@ rustc_queries! {
|
||||
separate_provide_extern
|
||||
}
|
||||
|
||||
query adt_sized_constraint(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||
desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
|
||||
query adt_sized_constraint(key: DefId) -> Option<ty::EarlyBinder<Ty<'tcx>>> {
|
||||
desc { |tcx| "computing `Sized` constraint for `{}`", tcx.def_path_str(key) }
|
||||
}
|
||||
|
||||
query adt_dtorck_constraint(
|
||||
|
||||
@@ -590,10 +590,10 @@ impl<'tcx> AdtDef<'tcx> {
|
||||
tcx.adt_destructor(self.did())
|
||||
}
|
||||
|
||||
/// Returns a list of types such that `Self: Sized` if and only if that
|
||||
/// type is `Sized`, or `ty::Error` if this type has a recursive layout.
|
||||
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||
tcx.adt_sized_constraint(self.did())
|
||||
/// Returns a type such that `Self: Sized` if and only if that type is `Sized`,
|
||||
/// or `None` if the type is always sized.
|
||||
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> Option<ty::EarlyBinder<Ty<'tcx>>> {
|
||||
if self.is_struct() { tcx.adt_sized_constraint(self.did()) } else { None }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2490,7 +2490,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
|
||||
ty::Tuple(tys) => tys.iter().all(|ty| ty.is_trivially_sized(tcx)),
|
||||
|
||||
ty::Adt(def, _args) => def.sized_constraint(tcx).skip_binder().is_empty(),
|
||||
ty::Adt(def, _args) => def.sized_constraint(tcx).is_none(),
|
||||
|
||||
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) | ty::Bound(..) => false,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user