lint on core::ffi::c_void as a return type#156379
Conversation
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
why is deny by default? what about things like bindgen that generates bindgings from c code? |
|
You're never meant to have a value of type in fact I expect that UB arises from the internal implementation details if you have a |
|
I'd suggest
|
|
I believe that every single one of those cases that are defining a All the cases that are declaring a Additionally, the here is an example of a case where miri can detect the UB, but this is rarely possible. |
|
As I noted earlier, I agree this pattern is incorrect. My concern is primarily about ecosystem impact - a GitHub search returns over 1,000 instances of this pattern, including in production codebases from organizations like Microsoft and Azure. Making this |
|
Reminder, once the PR becomes ready for a review, use |
|
Looks reasonable. We'd like to start with warn at first, and ramp up to deny after a couple of releases. @rfcbot merge lang |
|
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rustbot reroll |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@mati865 Rebased. |
|
@bors r+ |
lint on `core::ffi::c_void` as a return type Fixes rust-lang#100972. This PR introduces a new ~deny-by-default~ warn-by-default lint `c_void_returns` that fires on usage of `core::ffi::c_void` as a return type. This is never correct, and is a potential stumbling block for users coming from C.
…uwer Rollup of 7 pull requests Successful merges: - #156379 (lint on `core::ffi::c_void` as a return type) - #157347 (Implement `Box::as_non_null()`.) - #157650 (rustc_target: Add OpenEmbedded/Yocto Linux base targets) - #158569 ([rustdoc] Fix handling of inlining of `no_inline` of foreign items) - #158573 (stabilize `feature(atomic_from_mut)`) - #158614 (Fix error message when rejecting implicit stage != 2 in CI) - #158616 (Remove dependency from `rustc_metadata` on `rustc_incremental`)
Rollup merge of #156379 - euclio:c-void-returns, r=mati865 lint on `core::ffi::c_void` as a return type Fixes #100972. This PR introduces a new ~deny-by-default~ warn-by-default lint `c_void_returns` that fires on usage of `core::ffi::c_void` as a return type. This is never correct, and is a potential stumbling block for users coming from C.
…uwer Rollup of 7 pull requests Successful merges: - rust-lang/rust#156379 (lint on `core::ffi::c_void` as a return type) - rust-lang/rust#157347 (Implement `Box::as_non_null()`.) - rust-lang/rust#157650 (rustc_target: Add OpenEmbedded/Yocto Linux base targets) - rust-lang/rust#158569 ([rustdoc] Fix handling of inlining of `no_inline` of foreign items) - rust-lang/rust#158573 (stabilize `feature(atomic_from_mut)`) - rust-lang/rust#158614 (Fix error message when rejecting implicit stage != 2 in CI) - rust-lang/rust#158616 (Remove dependency from `rustc_metadata` on `rustc_incremental`)
View all comments
Fixes #100972.
This PR introduces a new
deny-by-defaultwarn-by-default lintc_void_returnsthat fires on usage ofcore::ffi::c_voidas a return type. This is never correct, and is a potential stumbling block for users coming from C.