1
Fork 0

Rollup merge of #114314 - compiler-errors:sized-crit, r=lcnr

Tweaks to `adt_sized_constraint`

fixes a comment, but also some other nits.

r? lcnr
This commit is contained in:
Matthias Krüger 2023-08-02 06:22:49 +02:00 committed by GitHub
commit 3d29ce7484
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 25 deletions

View file

@ -706,7 +706,7 @@ rustc_queries! {
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) }
}

View file

@ -562,18 +562,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 `TyErr` if this type is recursive.
///
/// Oddly enough, checking that the sized-constraint is `Sized` is
/// actually more expressive than checking all members:
/// the `Sized` trait is inductive, so an associated type that references
/// `Self` would prevent its containing ADT from being `Sized`.
///
/// 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()))
/// 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())
}
}