diff options
| author | bors <bors@rust-lang.org> | 2023-08-30 11:55:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-30 11:55:48 +0000 |
| commit | 26089ba0a2d9dab8381ccb0d7b99e704bc5cb3ed (patch) | |
| tree | 51e5a68491ceb506daffe00f9263437a1793fef0 /compiler/rustc_mir_transform/src | |
| parent | 61efe9d2981b87ec7f2800d62f98c594de151713 (diff) | |
| parent | 6d1ce9bd131d16166000f232cca00bc446bc9e35 (diff) | |
| download | rust-26089ba0a2d9dab8381ccb0d7b99e704bc5cb3ed.tar.gz rust-26089ba0a2d9dab8381ccb0d7b99e704bc5cb3ed.zip | |
Auto merge of #114483 - RalfJung:unsized-fields, r=oli-obk
interpret: fix projecting into an unsized field of a local See the new Miri testcase that didn't work before. r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/const_prop.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_mir_transform/src/const_prop_lint.rs | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index a793b384d81..0aaa3f75c82 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -376,6 +376,16 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { ) .expect("failed to push initial stack frame"); + for local in body.local_decls.indices() { + // Mark everything initially live. + // This is somewhat dicey since some of them might be unsized and it is incoherent to + // mark those as live... We rely on `local_to_place`/`local_to_op` in the interpreter + // stopping us before those unsized immediates can cause issues deeper in the + // interpreter. + ecx.frame_mut().locals[local].value = + LocalValue::Live(interpret::Operand::Immediate(Immediate::Uninit)); + } + ConstPropagator { ecx, tcx, param_env, local_decls: &dummy_body.local_decls } } diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index 755b3985791..dec79ddf58c 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -206,6 +206,16 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { ) .expect("failed to push initial stack frame"); + for local in body.local_decls.indices() { + // Mark everything initially live. + // This is somewhat dicey since some of them might be unsized and it is incoherent to + // mark those as live... We rely on `local_to_place`/`local_to_op` in the interpreter + // stopping us before those unsized immediates can cause issues deeper in the + // interpreter. + ecx.frame_mut().locals[local].value = + LocalValue::Live(interpret::Operand::Immediate(Immediate::Uninit)); + } + ConstPropagator { ecx, tcx, |
