diff options
| author | Ralf Jung <post@ralfj.de> | 2022-08-07 10:36:42 -0400 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-08-27 08:53:04 -0400 |
| commit | 4173e971b8c06d00b5bf9fb0133220cb37cf99da (patch) | |
| tree | 08b5566931ea0fa9d772754bce3a8013efed0a7e /compiler/rustc_const_eval/src | |
| parent | 4065b89b1e7287047d7d6c65e7abd7b8ee70bcf0 (diff) | |
| download | rust-4173e971b8c06d00b5bf9fb0133220cb37cf99da.tar.gz rust-4173e971b8c06d00b5bf9fb0133220cb37cf99da.zip | |
remove an ineffective check in const_prop
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/place.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/projection.rs | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 7aa76fe1dae..d56323448ce 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -642,7 +642,7 @@ where // avoid force_allocation. let src = match self.read_immediate_raw(src)? { Ok(src_val) => { - assert!(!src.layout.is_unsized(), "cannot have unsized immediates"); + assert!(!src.layout.is_unsized(), "cannot copy unsized immediates"); assert!( !dest.layout.is_unsized(), "the src is sized, so the dest must also be sized" diff --git a/compiler/rustc_const_eval/src/interpret/projection.rs b/compiler/rustc_const_eval/src/interpret/projection.rs index 742339f2b0a..16ce5bc7175 100644 --- a/compiler/rustc_const_eval/src/interpret/projection.rs +++ b/compiler/rustc_const_eval/src/interpret/projection.rs @@ -100,6 +100,8 @@ where // This makes several assumptions about what layouts we will encounter; we match what // codegen does as good as we can (see `extract_field` in `rustc_codegen_ssa/src/mir/operand.rs`). let field_val: Immediate<_> = match (*base, base.layout.abi) { + // if the entire value is uninit, then so is the field (can happen in ConstProp) + (Immediate::Uninit, _) => Immediate::Uninit, // the field contains no information, can be left uninit _ if field_layout.is_zst() => Immediate::Uninit, // the field covers the entire type @@ -124,6 +126,7 @@ where b_val }) } + // everything else is a bug _ => span_bug!( self.cur_span(), "invalid field access on immediate {}, layout {:#?}", |
