Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upother-reprs: Null-pointer-optimized enums are FFI safe unless repr(C) #13
Conversation
This comment has been minimized.
This comment has been minimized.
|
Actually the more I read the code, it looks like the improper_ctypes lint considers it FFI-safe to have an enum with But the nomicon is claiming that "tagged unions ... are never FFI safe." Should this text be fixed, or is "tagged union" intended to mean something other than an enum with data? |
This comment has been minimized.
This comment has been minimized.
ubsan
commented
Apr 30, 2017
|
They aren't yet FFI-safe, but they should probably be made so. |
This comment has been minimized.
This comment has been minimized.
|
Enums are tagged unions, so this feels a bit weird, I would phrase it as something like "adds the tag back in" or something, dunno. |
This comment has been minimized.
This comment has been minimized.
|
This is way too much information to squish into a single-sentence aside. To be clear, |
This comment has been minimized.
This comment has been minimized.
ubsan
commented
May 17, 2017
•
|
@Gankro I have used it in the past. It's useful for passing ownership to and from C (you return a |
geofft
force-pushed the
geofft:null
branch
from
caaea4d
to
7753a3c
May 20, 2017
This comment has been minimized.
This comment has been minimized.
@ubsan What needs to be done to make this happen? In particular, if they're not yet FFI-safe, then it seems to me that the improper_ctypes lint should be fixed to align with the current state of things.
FWIW the improper_ctypes lint currently warms about both I've pushed some slightly longer text that phrases this as |
This comment has been minimized.
This comment has been minimized.
ubsan
commented
May 21, 2017
•
|
@geofft basically, define the layout of
to be
or something of that order |
This comment has been minimized.
This comment has been minimized.
|
I suspect that's what its representation is right now - what needs to be done process-wise to formalize this? Would this be an RFC or something? |
This comment has been minimized.
This comment has been minimized.
ubsan
commented
May 22, 2017
|
@geofft not sure. Probably an RFC, but also I'd like to note that the representation of the specific union members isn't specified, so you'd have to figure that out as well. |
steveklabnik
merged commit 95e43bc
into
rust-lang-nursery:master
May 26, 2017
1 check passed
This comment has been minimized.
This comment has been minimized.
|
Thanks! |
geofft commentedApr 18, 2017
See also the improper_ctypes lint, specifically is_repr_nullable_ptr in
src/librustc_lint/types.rs.