diff options
| author | bors <bors@rust-lang.org> | 2024-03-08 12:16:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-08 12:16:42 +0000 |
| commit | 42825768b103c28b10ce0407749acb21d32abeec (patch) | |
| tree | b6709875ee680b2fbac6253b91c8f2b8f044a6a1 /compiler | |
| parent | 1b2c53a15dba7962cfc284c3b6d61a0341ffa27a (diff) | |
| parent | ace436743fff6dcfd21d8194acdd43a94c1611ec (diff) | |
| download | rust-42825768b103c28b10ce0407749acb21d32abeec.tar.gz rust-42825768b103c28b10ce0407749acb21d32abeec.zip | |
Auto merge of #122078 - gurry:121443-ice-layout-is-sized-alt, r=oli-obk
Check that return type is WF in typeck Ensures that non-WF types do not pass typeck and then later ICE in MIR/const eval Fixes #121443
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/lib.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 70ddd6b2f4c..d86b4912c89 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -61,7 +61,7 @@ use rustc_hir::{HirIdMap, Node}; use rustc_hir_analysis::astconv::AstConv; use rustc_hir_analysis::check::check_abi; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; -use rustc_infer::traits::ObligationInspector; +use rustc_infer::traits::{ObligationCauseCode, ObligationInspector, WellFormedLoc}; use rustc_middle::query::Providers; use rustc_middle::traits; use rustc_middle::ty::{self, Ty, TyCtxt}; @@ -253,6 +253,10 @@ fn typeck_with_fallback<'tcx>( let expected_type = expected_type.unwrap_or_else(fallback); let expected_type = fcx.normalize(body.value.span, expected_type); + + let wf_code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id))); + fcx.register_wf_obligation(expected_type.into(), body.value.span, wf_code); + fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized); // Gather locals in statics (because of block expressions). |
