mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
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.
This commit is contained in:
commit
bb77336c0a
@ -534,7 +534,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
let mut non_zst_field = None;
|
||||
for i in 0..receiver.layout.fields.count() {
|
||||
let field = self.operand_field(&receiver, i)?;
|
||||
if !field.layout.is_zst() {
|
||||
let zst =
|
||||
field.layout.is_zst() && field.layout.align.abi.bytes() == 1;
|
||||
if !zst {
|
||||
assert!(
|
||||
non_zst_field.is_none(),
|
||||
"multiple non-ZST fields in dyn receiver type {}",
|
||||
|
Loading…
Reference in New Issue
Block a user