Skip to content

Commit bb77336

Browse files
authored
Rollup merge of #99972 - RalfJung:1zst, r=lcnr
interpret: only consider 1-ZST when searching for receiver `repr(transparent)` currently entirely rejects ZST with alignment larger than 1 (which is odd, arguably [this](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=02870f29396fa948c3123cb53d869ad1) should be accepted), so this should be safe. And if it ever isn't safe then that is very likely a bug elsewhere in the compiler.
2 parents 0491fda + 5798555 commit bb77336

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/rustc_const_eval/src/interpret/terminator.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
534534
let mut non_zst_field = None;
535535
for i in 0..receiver.layout.fields.count() {
536536
let field = self.operand_field(&receiver, i)?;
537-
if !field.layout.is_zst() {
537+
let zst =
538+
field.layout.is_zst() && field.layout.align.abi.bytes() == 1;
539+
if !zst {
538540
assert!(
539541
non_zst_field.is_none(),
540542
"multiple non-ZST fields in dyn receiver type {}",

0 commit comments

Comments
 (0)