Skip to content

Deny unsafe_op_in_unsafe_fn in crates containing unsafe code#15327

Closed
duksh wants to merge 1 commit into
pyca:mainfrom
duksh:claude/upstream-unsafe-op-lint
Closed

Deny unsafe_op_in_unsafe_fn in crates containing unsafe code#15327
duksh wants to merge 1 commit into
pyca:mainfrom
duksh:claude/upstream-unsafe-op-lint

Conversation

@duksh

@duksh duksh commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Adds unsafe_op_in_unsafe_fn to the existing #![deny(...)] in the four crates that contain unsafe code.

Every unsafe operation inside an unsafe fn must now sit in an explicit unsafe block, which — combined with the already-denied clippy::undocumented_unsafe_blocks — means each one also carries a SAFETY comment.

The codebase already complies (zero violations; cargo check --locked --workspace, cargo fmt --check, and clippy all clean), so this only prevents silent regressions.

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
@alex

alex commented Jul 25, 2026

Copy link
Copy Markdown
Member

I believe this warning is already on by default in the rust 2024 edition, so there's no need to explicitly enable it.

@duksh

duksh commented Jul 25, 2026

Copy link
Copy Markdown
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.

@alex

alex commented Jul 25, 2026

Copy link
Copy Markdown
Member

MSRV bump is in #15174, so I think we'll just get this for free then, thanks.

@duksh duksh closed this Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants