-
Notifications
You must be signed in to change notification settings - Fork 391
native-lib: allow passing structs as arguments #4466
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
base: master
Are you sure you want to change the base?
Conversation
ca18991
to
4e6a464
Compare
|
||
fn main() { | ||
let pass_me = PassMe { value: 42, other_value: 1337 }; | ||
unsafe { pass_struct(pass_me) }; //~ ERROR: Undefined Behavior: passing a non-#[repr(C)] struct over FFI |
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.
Is this correct? I think it's UB, but maybe if the user intentionally sets #[allow(improper_ctypes)]
we might just want to report this as unsupported instead of UB?
1faf540
to
e9670f0
Compare
Think this is ready for review. I split off a bunch of the new code this introduces into a different file to not pollute @rustbot ready |
7cd63db
to
532a735
Compare
Seems like there's some trouble here, nvm. @rustbot author |
Reminder, once the PR becomes ready for a review, use |
809f60e
to
edfa595
Compare
Should be fixed. Also bumped the libffi version since apparently there was a soundness issue that got resolved since the previous version we were on; that wasn't the cause of my test failures, but it's probably smart to include it anyways. There's a couple @rustbot ready |
802f48b
to
685a17c
Compare
Blocked on #4456 currently to make rebasing easier when that lands.This allows passing arbitrary structs as arguments to native code; receiving a struct as a return value is not yet implemented. Also includes a couple of tests.I figured the review queue looked a bit too empty :D