Skip to content

Commit 730098b

Browse files
committed
avoid allocating for ZST
1 parent ad009ae commit 730098b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
261261
}
262262

263263
pub fn uninit_operand(&mut self, layout: TyLayout<'tcx>) -> EvalResult<'tcx, Operand> {
264-
// FIXME: Aren't we supposed to also be immediate for a ZST?
265264
// This decides which types we will use the Immediate optimization for, and hence should
266265
// match what `try_read_value` and `eval_place_to_op` support.
266+
if layout.is_zst() {
267+
return Ok(Operand::Immediate(Value::Scalar(ScalarMaybeUndef::Undef)));
268+
}
269+
267270
Ok(match layout.abi {
268271
layout::Abi::Scalar(..) =>
269272
Operand::Immediate(Value::Scalar(ScalarMaybeUndef::Undef)),

0 commit comments

Comments
 (0)