diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-17 12:32:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-17 12:32:48 +0200 |
| commit | bb77336c0a6708bdebcbf3a1df19b258919b582e (patch) | |
| tree | dc1dae203452c6d167b38fbde200457fbe50129e | |
| parent | 0491fdad6f0c039dcfbf6543be6397df763cb8ab (diff) | |
| parent | 5798555812228600a27fa3d3b2c20b422c6d97c7 (diff) | |
| download | rust-bb77336c0a6708bdebcbf3a1df19b258919b582e.tar.gz rust-bb77336c0a6708bdebcbf3a1df19b258919b582e.zip | |
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.
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index d563e35f910..c8557d172ed 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -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 {}", |
