-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Rust types in FFI lint #12608
Comments
We do not need this for 1.0. But it will be useful. Assigning P-high for now. |
@alexcrichton We now have the |
In theory |
To pass |
I think most of this has been addressed by #26583:
There is already a separate issue for checking So I think this issue can be closed, if any of the three points above should be changed I would propose opening separate issues for them. |
Sounds good to me! |
Right now we have a lint mode which warns about the usage of rust types in
extern
blocks. This makes sure that by default you don't pass rust types into C functions. What we don't have is a lint going the other way which makes sure that C can't get Rust types from Rust. I believe that we need to expand the FFI lint to crawlextern
functions as well asextern
blocks.The exact types which should be allowed is a little questionable. Some things that would be nice to have a defined ABI/FFI for would, but may currently not be working:
Option<&T>
andOption<~T>
. See Nullable-pointerOption
s aren't FFI-compatible with the base pointer types. #11303, but this is currently broken. Do we want to commit to this ABI and say that it's valid to use to interface with C?~T
and&T
, are these valid FFI types? The rust type system guarantees they are never null, but there's no guarantee that C handed you something that's not null.&str
- should this be valid to pass in/out? This would require something along the lines ofrust.h
To be conservative, we could only allow primitives (minus
int
anduint
) plus*T
, but this is quite limiting and makes FFI a little more difficult.Nominating.
The text was updated successfully, but these errors were encountered: