-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustc: Don't lint about isize/usize in FFI #28779
Conversation
This lint warning was originally intended to help against misuse of the old Rust `int` and `uint` types in FFI bindings where the Rust `int` was not equal to the C `int`. This confusion no longer exists (as Rust's types are now `isize` and `usize`), and as a result the need for this lint has become much less over time. Additionally, starting with [the RFC for libc][rfc] it's likely that `isize` and `usize` will be quite common in FFI bindings (e.g. they're the definition of `size_t` and `ssize_t` on many platforms). [rfc]: rust-lang/rfcs#1291 This commit disables these lints to instead consider `isize` and `usize` valid types to have in FFI signatures.
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
r? @nrc |
cc @briansmith, #28096 |
Great. Although I'd figured out how to change the lint implementation easy enough, I was struggling to figure out how to update the tests. Thanks for taking this over. |
No problem! Thanks again for proposing the change :) |
@bors: r+ |
📌 Commit bd6758a has been approved by |
This lint warning was originally intended to help against misuse of the old Rust `int` and `uint` types in FFI bindings where the Rust `int` was not equal to the C `int`. This confusion no longer exists (as Rust's types are now `isize` and `usize`), and as a result the need for this lint has become much less over time. Additionally, starting with [the RFC for libc][rfc] it's likely that `isize` and `usize` will be quite common in FFI bindings (e.g. they're the definition of `size_t` and `ssize_t` on many platforms). [rfc]: rust-lang/rfcs#1291 This commit disables these lints to instead consider `isize` and `usize` valid types to have in FFI signatures.
Nominating for a beta backport, I think this will be an instrumental part of rust-lang/rfcs#1291 and I think the impact is pretty low. |
@rust-lang/lang I have no opinion about backporting this to beta; I certainly don't object, but I also don't think its the end of the world if we end up waiting a release cycle for this change to the lint. |
I wouldn't normally want to backport this, but the patch is small, and so if @alexcrichton is in favor I'm ok with it. |
This lint warning was originally intended to help against misuse of the old Rust
int
anduint
types in FFI bindings where the Rustint
was not equal to theC
int
. This confusion no longer exists (as Rust's types are nowisize
andusize
), and as a result the need for this lint has become much less over time.Additionally, starting with the RFC for libc it's likely that
isize
andusize
will be quite common in FFI bindings (e.g. they're the definition ofsize_t
andssize_t
on many platforms).This commit disables these lints to instead consider
isize
andusize
validtypes to have in FFI signatures.