-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.P-mediumMedium priorityMedium priority
Description
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 crawl extern
functions as well as extern
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
and uint
) plus *T
, but this is quite limiting and makes FFI a little more difficult.
Nominating.
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.P-mediumMedium priorityMedium priority