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:
Matthias Krüger 2022-08-17 12:32:48 +02:00 committed by GitHub
commit bb77336c0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {}",