Don’t recommend empty enums for opaque types#44
Don’t recommend empty enums for opaque types#44SimonSapin wants to merge 2 commits intorust-lang:masterfrom
Conversation
|
CC @skade |
|
I literally didn't know this chapter was added?? |
|
@gankro It seems to be imported from the Book’s first edition: https://doc.rust-lang.org/book/first-edition/ffi.html |
src/ffi.md
Outdated
| pub enum Foo {} | ||
| pub enum Bar {} | ||
| #[repr(C)] pub struct Foo { private: [u8; 0] } | ||
| #[repr(C)] pub struct Bar { private: [u8; 0] } |
There was a problem hiding this comment.
I think this should be _priv: to avoid unused field warnings, and to match stdlib style.
I also don't really understand the point of repr(C) here? Silencing the lint?
There was a problem hiding this comment.
Yes, rustc warns without it. Same with [u8; 0] over ().
|
(heading to work) we should explain what each of the 3 weird things in this type accomplish, if we don't already. |
|
Given that empty types have been recommended here previously, and may still be recommended in various blogs posts or so out there, maybe there should be an explicit section explaining that empty enums should NOT be used? |
|
ping @SimonSapin what do we want to do about this |
|
I opened #82 to address the remaining concerns. |
|
Oops, sorry I let this slip through the cracks. Thanks Ralf for taking over. #82 looks good so let’s close for that one. |
Fix #29