diff options
| author | Lukas Markeffsky <@> | 2024-03-13 23:33:45 +0100 |
|---|---|---|
| committer | Lukas Markeffsky <@> | 2024-03-14 21:28:47 +0100 |
| commit | 8ad94111adb790723a7db2e7449204b5f68e9c48 (patch) | |
| tree | fed38688370152c6b3f8b969e0fea6180411f8eb /compiler/rustc_middle/src | |
| parent | 0e7e1bfdbc52931d03e40438a74b400276e46bbd (diff) | |
| download | rust-8ad94111adb790723a7db2e7449204b5f68e9c48.tar.gz rust-8ad94111adb790723a7db2e7449204b5f68e9c48.zip | |
clean up ADT sized constraint computation
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/adt.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 865299e15c8..c73dc7cd281 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -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( diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 36050792adc..a7144316769 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -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 } } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 11065b2a382..7ff0b8dac4c 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -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, |
