improper_ctypes
is many clippy lints in 1~2 rustc lints
#116963
Labels
A-clippy
Area: Clippy
A-diagnostics
Area: Messages for errors, warnings, and lints
A-FFI
Area: Foreign function interface (FFI)
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
C-cleanup
Category: PRs that clean code up or issues documenting cleanup.
L-improper_ctypes
Lint: improper_ctypes
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
In general, rustc lints are held to a standard of "low false positives". Sometimes they may be opinionated (e.g. all the style lints), but they should generally at least be correct about what they are linting on. Unfortunately, the
improper_ctypes
lint is a grab-bag of opinions, but few of them necessarily reflect the actuality of what safe FFI looks like, partly because Rust's in-compiler understanding of C ABIs is actually fairly lacking. They are over-conservative approximations, which must often be responded to with liberal usage ofallow(improper_ctypes)
.In other words, it's a clippy lint. Probably multiple (it's already split into
improper_ctypes_definitions
, for instance).This is not a new concern, considering:
improper_ctypes
firing on recursive non-local containment? #116831improper_ctypes
lint triggers on valid#[repr(transparent)]
types #115457improper_ctypes
fails to trigger on invalidrepr(transparent)
types #116959improper_ctypes
lint should cover "C" abi function pointer types. #95683I'm not the only one who has suggested extensively refactoring it:
Perhaps the more niche cases that it warns on should be moved to clippy and allowed to bake for... a while. This, admittedly, would be the first case that I know of for casting a lint down instead of lifting it up, but it may be justified.
The text was updated successfully, but these errors were encountered: