-
Notifications
You must be signed in to change notification settings - Fork 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
Use Rust union types #2056
base: main
Are you sure you want to change the base?
Use Rust union types #2056
Conversation
r? @Amanieu (rust-highfive has picked a reviewer for you, use r? to override) |
Also I had to ignore |
Unfortunately I believe this is a breaking change, which means we can't actually do this until we bump the crate version to 1.0. cc @JohnTitor |
I'm aware that it is a breaking change and that's not a problem for me to wait until a new major version for this to be merged. |
☔ The latest upstream changes (presumably #1975) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm unsure how to find out what's wrong with sigval on emscripten... |
Btw, I noted (when I originally opened this PR) that the following fields may also be wroth considering turning into unions:
|
I also don't know. I'll mark this as review as a reminder that I need to take a look at this. @rustbot review
Feel free to submit another PR! |
This needs another rebase, feel free to just leave Regarding traits: don't add For @rustbot author |
@@ -212,33 +212,17 @@ s! { | |||
} | |||
|
|||
s_no_extra_traits! { | |||
// FIXME: This is actually a union. | |||
pub struct fpreg_t { | |||
pub union fpreg_t { |
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.
@@ -159,7 +159,7 @@ s! { | |||
pub ifa_flags: ::c_uint, | |||
pub ifa_addr: *mut ::sockaddr, | |||
pub ifa_netmask: *mut ::sockaddr, | |||
pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union | |||
pub ifa_ifu: __c_anonymous_ifa_ifu, |
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.
pub data: epoll_data, | ||
} | ||
|
||
pub union epoll_data { |
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.
@@ -213,6 +208,23 @@ s! { | |||
} | |||
} | |||
|
|||
s_no_extra_traits! { | |||
pub union sigval { |
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.
@@ -1046,6 +1048,16 @@ s_no_extra_traits! { | |||
pub struct pthread_cond_t { | |||
size: [u8; ::__SIZEOF_PTHREAD_COND_T], | |||
} | |||
|
|||
pub union sigval { |
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.
@@ -470,7 +472,7 @@ s! { | |||
pub ifa_flags: ::c_uint, | |||
pub ifa_addr: *mut ::sockaddr, | |||
pub ifa_netmask: *mut ::sockaddr, | |||
pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union | |||
pub ifa_ifu: __c_anonymous_ifa_ifu, |
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.
pub data: epoll_data, | ||
} | ||
|
||
pub union epoll_data { |
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.
https://cs.opensource.google/fuchsia/fuchsia/+/main:third_party/llvm-libc/src/include/llvm-libc-types/struct_epoll_data.h;l=12;drc=b47f6213560e67982d8b9d01a78daeb6ec361a5b, https://cs.opensource.google/fuchsia/fuchsia/+/main:third_party/android/platform/bionic/libc/include/bits/epoll_event.h;l=48;drc=dd6763a6c677687ad06727af037ed9a7b018c773
These changes overall look good to me assuming the traits get figured out. I left comments with sources just to make sure I double checked everything here. #4176 landed so you can remove all debug implementations. If anything else complains about missing traits, just implement the body Comment |
For #1020
Replace some types with unions now that rustc supports them.
I also found
sigevent.sigev_notify_thread_id
,siginfo_t.__data
andsigaction.sa_sigaction
that I think should be unions, but I wasn't sure.