Deny unsafe_op_in_unsafe_fn in crates containing unsafe code#15327
Closed
duksh wants to merge 1 commit into
Closed
Deny unsafe_op_in_unsafe_fn in crates containing unsafe code#15327duksh wants to merge 1 commit into
duksh wants to merge 1 commit into
Conversation
Requires every unsafe operation inside an unsafe fn to be wrapped in an explicit unsafe block, complementing the existing clippy::undocumented_unsafe_blocks deny so each such block also carries a SAFETY comment. The codebase already complies; this prevents silent regressions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DWoMomNAcBM3e8duJrb2do
Member
|
I believe this warning is already on by default in the rust 2024 edition, so there's no need to explicitly enable it. |
Contributor
Author
|
In edition 2024 it's warn-by-default, agreed — but the workspace is currently edition 2021 (MSRV 1.83, and the 2024 edition needs 1.85), where this lint is allow-by-default, so it's not active today. The explicit deny covers the gap until the edition bump; happy to close if that bump is imminent. |
Member
|
MSRV bump is in #15174, so I think we'll just get this for free then, thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
unsafe_op_in_unsafe_fnto the existing#![deny(...)]in the four crates that contain unsafe code.Every unsafe operation inside an
unsafe fnmust now sit in an explicitunsafeblock, which — combined with the already-deniedclippy::undocumented_unsafe_blocks— means each one also carries aSAFETYcomment.The codebase already complies (zero violations;
cargo check --locked --workspace, cargo fmt --check,and clippy all clean), so this only prevents silent regressions.