Skip to content

Commit e68cf16

Browse files
Address review comments
Co-authored-by: Ralf Jung <post@ralfj.de>
1 parent e2ee4b8 commit e68cf16

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

compiler/rustc_abi/src/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
500500
return Err(LayoutCalculatorError::EmptyUnion);
501501
};
502502

503+
// We also need to check for a `repr(transparent)` wrapper around `repr(C)`
503504
let repr_c =
504505
repr.c() || (repr.transparent() && only_variant.iter().any(|field| field.repr_c));
505506

@@ -1489,6 +1490,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
14891490
unadjusted_abi_align
14901491
};
14911492

1493+
// We also need to check for a `repr(transparent)` wrapper around `repr(C)`
14921494
let repr_c = repr.c() || (repr.transparent() && fields.iter().any(|field| field.repr_c));
14931495

14941496
let seed = field_seed.wrapping_add(repr.field_shuffle_seed);

compiler/rustc_target/src/callconv/x86_win64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ where
4949
};
5050

5151
// Windows ABIs do not talk about ZST since such types do not exist in MSVC.
52-
// However, clang and gcc allow ZST is their windows-gnu targets, and pass them by pointer indierction.
52+
// However, clang and gcc allow ZST in their windows-gnu targets, and pass them by pointer indirection.
5353
// We follow that for `repr(C)` ZSTs (and `repr(transparent)` wrappers around them),
5454
// but `repr(Rust)` ones are always ignored (ensuring that `()` matches C `void`).
5555

tests/codegen-llvm/abi-win64-zst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ extern "sysv64" fn ret_c_maybezst_sysv64() -> CMaybeZst {
138138
CMaybeZst
139139
}
140140

141-
// For `extern "C"` functions, ZST are ignored on Linux put reted on Windows.
141+
// For `extern "C"` functions, ZST are ignored on Linux but returned via pointer on Windows.
142142

143143
// linux: define void @ret_c_maybezst_c()
144144
// windows-msvc: define void @ret_c_maybezst_c(ptr {{[^,]*}})

0 commit comments

Comments
 (0)