-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement RFC #18 #14479
Implement RFC #18 #14479
Conversation
As of RFC 18, struct layout is undefined. Opting into a C-compatible struct layout is now down with #[repr(C)]. For consistency, specifying a packed layout is now also down with #[repr(packed)]. Both can be specified. [breaking-change]
@@ -544,7 +544,7 @@ mod imp { | |||
static IMAGE_FILE_MACHINE_IA64: libc::DWORD = 0x0200; | |||
static IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664; | |||
|
|||
#[packed] | |||
#[repr(packed)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be C, packed
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, stupid cfg'd code!
@alexcrichton at this point I'd rather just overhaul the ctypes lint to be more precise, and done after trans. Right now it handwaves away things like generic structs. I feel like:
should be a warning where T is not |
At minimum you may want to deal with pointer types to structs, as those are probably the most common way of dealing with FFI structs. A fancier lint could come later. |
Closing due to inactivity, but feel free to reopen with a rebase! |
Desugar async fn completely fix rust-lang#14479
Closes #14309.
Extends the ctypes lint to warn when a struct not annotated with
#[repr(C)] is used in an FFI function.