diff options
| author | msizanoen <msizanoen@qtmlabs.xyz> | 2023-09-03 15:58:21 +0700 |
|---|---|---|
| committer | msizanoen <msizanoen@qtmlabs.xyz> | 2023-09-19 12:06:33 +0200 |
| commit | 751ecde0640f1d079515964e72e2646e82cb25f4 (patch) | |
| tree | 2f04ddbee8e786e5505cd3f099a3520fa63e0daf /compiler/rustc_middle/src | |
| parent | ae9c330629f1fb03a636cb8af367fead024793db (diff) | |
rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member
This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115481.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 9a0e72d7b64..8b425ce0267 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1118,6 +1118,10 @@ where fn is_unit(this: TyAndLayout<'tcx>) -> bool { matches!(this.ty.kind(), ty::Tuple(list) if list.len() == 0) } + + fn is_transparent(this: TyAndLayout<'tcx>) -> bool { + matches!(this.ty.kind(), ty::Adt(def, _) if def.repr().transparent()) + } } /// Calculates whether a function's ABI can unwind or not. |
