diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-05-04 00:17:25 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-04 00:17:25 +0530 |
| commit | 8b7080b15bc2846ba547a9086ae1b3df8a69d2d1 (patch) | |
| tree | 30ad5a23b4ce36aa48562bb34e432a0e017afaae /compiler/rustc_const_eval/src/interpret | |
| parent | 0228994cdf6dbf59450f64c0bf983ac9fbb1cfc4 (diff) | |
| parent | 6fcf165586364dc3feff57f3aa4eb4f637a6d4d5 (diff) | |
| download | rust-8b7080b15bc2846ba547a9086ae1b3df8a69d2d1.tar.gz rust-8b7080b15bc2846ba547a9086ae1b3df8a69d2d1.zip | |
Rollup merge of #110943 - RalfJung:interpret-unsized-arg-ice, r=oli-obk
interpret: fail more gracefully on uninit unsized locals r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/68538
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 5310ef0bb3e..a7f66071fe2 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -245,6 +245,12 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> { impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> { pub fn len(&self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> { if self.layout.is_unsized() { + if matches!(self.op, Operand::Immediate(Immediate::Uninit)) { + // Uninit unsized places shouldn't occur. In the interpreter we have them + // temporarily for unsized arguments before their value is put in; in ConstProp they + // remain uninit and this code can actually be reached. + throw_inval!(UninitUnsizedLocal); + } // There are no unsized immediates. self.assert_mem_place().len(cx) } else { |
