Skip to content

Commit 2f0dcfb

Browse files
committed
Simplify write_value_to_ptr
1 parent 129b914 commit 2f0dcfb

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,20 +1622,13 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
16221622
}
16231623
Value::ByVal(primval) => {
16241624
let size = self.type_size(dest_ty)?.expect("dest type must be sized");
1625-
// TODO: This fn gets called with sizes like 0 and 6, which cannot be a primitive type
1626-
// and hence is not supported by write_primval.
1627-
// (E.g. in the arrays.rs testcase.) That seems to only happen for Undef though,
1628-
// so we special-case that here.
1629-
match primval {
1630-
PrimVal::Undef => {
1631-
self.memory.mark_definedness(dest, size, false)?;
1632-
}
1633-
_ => {
1634-
// TODO: Do we need signedness?
1635-
self.memory.write_primval(dest.to_ptr()?, primval, size, false)?;
1636-
}
1625+
if size == 0 {
1626+
assert!(primval.is_undef());
1627+
Ok(())
1628+
} else {
1629+
// TODO: Do we need signedness?
1630+
self.memory.write_primval(dest.to_ptr()?, primval, size, false)
16371631
}
1638-
Ok(())
16391632
}
16401633
Value::ByValPair(a, b) => self.write_pair_to_ptr(a, b, dest.to_ptr()?, dest_ty),
16411634
}

0 commit comments

Comments
 (0)