lint on more incorrect usages of core::ffi::c_void - #159986
lint on more incorrect usages of core::ffi::c_void#159986Jules-Bertholet wants to merge 5 commits into
core::ffi::c_void#159986Conversation
|
cc @rust-lang/miri |
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
Also, fix false negatives in `c_void_returns`.
33e8e23 to
2949956
Compare
|
The lint should probably also complain about |
core::ffi::c_void as an &/&mut referentcore::ffi::c_void
Also, fix another false negative in `c_void_returns`.
Added another lint for this |
|
Added a third lint, against |
|
Idea (not sure if this is feasible): If we do anything that asks for the size of c_void, emit a warning unless it's for a pointer offset operation |
We can emit a warning regardless, with a note to just use byte_add for offset operations. (Is that what people are using size_of for..?) |
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
60a14e5 to
2d23dd9
Compare
|
Added a fourth lint to check for incorrect usage of |
This comment has been minimized.
This comment has been minimized.
Also, extend `c_void_references` to lint on references to `c_void` in MIR.
2d23dd9 to
bf41d85
Compare
core::ffi::c_voidhas size 1 and a highly non-trivial validity invariant. It should only ever be used behind a raw pointer. However, people mess this up all the time.c_void_references: Lint against&or&mutreferences toc_void. This is a widespread mistake, e.g. here in Miri, here across GitHub.c_void_statics: Lint againststatics andconsts of typec_void. Examples of this mistake across GitHubc_void_parameters: Lint against usage ofc_voidas a function parameter type. Examples of this mistake across GitHubc_void_values: Lint against usage ofc_voidby value in MIR.Also fixes false negatives in the pre-exisiting
c_void_returns. Like that lint, these new lints are warn-by-default, but should eventually be upgraded to deny.See also #159935
@rustbot label T-lang needs-fcp A-FFI