Skip to content

Clarify pitfalls of references and NonNull in FFI #67234

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
gnzlbg opened this issue Dec 11, 2019 · 0 comments
Open

Clarify pitfalls of references and NonNull in FFI #67234

gnzlbg opened this issue Dec 11, 2019 · 0 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-FFI Area: Foreign function interface (FFI) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Dec 11, 2019

Add a note like the one in this commit to the documentation of references and nonnull: fafa489

Something like what that commit does for Box<T>:

//!  **Important.** At least at present, you should avoid using
//! `Box<T>` types for functions that are defined in C but invoked
//! from Rust. In those cases, you should directly mirror the C types
//! as closely as possible. Using types like `Box<T>` where the C
//! definition is just using `T*` can lead to undefined behavior, as
//! described in [rust-lang/unsafe-code-guidelines#198][ucg#198].

but replacing Box<T> with the reference types and NonNull<T>.

@jonas-schievink jonas-schievink added A-FFI Area: Foreign function interface (FFI) C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Dec 11, 2019
@jonas-schievink jonas-schievink added the T-lang Relevant to the language team label Mar 6, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-FFI Area: Foreign function interface (FFI) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team
Projects
None yet
Development

No branches or pull requests

2 participants