Skip to content
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 of ptr::NonNull in FFI #49220

Closed
kornelski opened this Issue Mar 20, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@kornelski
Copy link
Contributor

kornelski commented Mar 20, 2018

I think it would be interesting to use ptr::NonNull to explicitly document FFI arguments that aren't allowed to be NULL, so that e.g.:

extern "C" fn call_me_from_c(without_nulls: ptr::NonNull<c_char>)

could be an implementation for:

void call_me_from_c(char *without_nulls) __attribute__((nonnull));

However, ptr::NonNull doesn't have #[repr(transparent)], so I'm not sure if that is sound. Whether it's supposed to be used this way or not, it may be worth explicitly documenting it. Currently its docs don't say anything about FFI compatibility.

@mattico

This comment has been minimized.

Copy link
Contributor

mattico commented Mar 21, 2018

cc #27730

@RReverser

This comment has been minimized.

Copy link
Contributor

RReverser commented Aug 2, 2018

NonNull has repr(transparent) now, so I assume this can be closed?

@kornelski kornelski closed this Aug 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.