Skip to content

Commit 3fa7411

Browse files
committed
librustc_codegen_llvm: Use repr(transparent) for bitflags over repr(C) (#61306)
In order to make sure that Rust's bitflags types are passed the same way in the Rust ABI as they are in the C ABI, we need to use the attribute repr(transparent) over the repr(C) attribute for the single-field bitflags structs in in order to prevent ABI mismatches. Thanks to Michael Karcher for finding this bug.
1 parent 0dc9e9c commit 3fa7411

File tree

1 file changed

+2
-2
lines changed
  • src/librustc_codegen_llvm/llvm

1 file changed

+2
-2
lines changed

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ pub mod debuginfo {
564564

565565
// These values **must** match with LLVMRustDIFlags!!
566566
bitflags! {
567-
#[repr(C)]
567+
#[repr(transparent)]
568568
#[derive(Default)]
569569
pub struct DIFlags: ::libc::uint32_t {
570570
const FlagZero = 0;
@@ -593,7 +593,7 @@ pub mod debuginfo {
593593

594594
// These values **must** match with LLVMRustDISPFlags!!
595595
bitflags! {
596-
#[repr(C)]
596+
#[repr(transparent)]
597597
#[derive(Default)]
598598
pub struct DISPFlags: ::libc::uint32_t {
599599
const SPFlagZero = 0;

0 commit comments

Comments
 (0)