From cdc95ba39d664c6ca354c9e31153070cd37aad16 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 24 Jul 2026 04:09:09 +0000 Subject: [PATCH] Deny unsafe_op_in_unsafe_fn in crates containing unsafe code 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 Claude-Session: https://claude.ai/code/session_01DWoMomNAcBM3e8duJrb2do --- src/rust/cryptography-cffi/src/lib.rs | 6 +++++- src/rust/cryptography-keepalive/src/lib.rs | 6 +++++- src/rust/cryptography-openssl/src/lib.rs | 6 +++++- src/rust/src/lib.rs | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/rust/cryptography-cffi/src/lib.rs b/src/rust/cryptography-cffi/src/lib.rs index a54dcafa57d7..c4ec798d9de1 100644 --- a/src/rust/cryptography-cffi/src/lib.rs +++ b/src/rust/cryptography-cffi/src/lib.rs @@ -2,7 +2,11 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. -#![deny(rust_2018_idioms, clippy::undocumented_unsafe_blocks)] +#![deny( + rust_2018_idioms, + unsafe_op_in_unsafe_fn, + clippy::undocumented_unsafe_blocks +)] #[cfg(python_implementation = "PyPy")] extern "C" { diff --git a/src/rust/cryptography-keepalive/src/lib.rs b/src/rust/cryptography-keepalive/src/lib.rs index c55d439547ef..c81420062893 100644 --- a/src/rust/cryptography-keepalive/src/lib.rs +++ b/src/rust/cryptography-keepalive/src/lib.rs @@ -2,7 +2,11 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. -#![deny(rust_2018_idioms, clippy::undocumented_unsafe_blocks)] +#![deny( + rust_2018_idioms, + unsafe_op_in_unsafe_fn, + clippy::undocumented_unsafe_blocks +)] use std::cell::UnsafeCell; use std::ops::Deref; diff --git a/src/rust/cryptography-openssl/src/lib.rs b/src/rust/cryptography-openssl/src/lib.rs index 744459f063c3..06877711d8de 100644 --- a/src/rust/cryptography-openssl/src/lib.rs +++ b/src/rust/cryptography-openssl/src/lib.rs @@ -2,7 +2,11 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. -#![deny(rust_2018_idioms, clippy::undocumented_unsafe_blocks)] +#![deny( + rust_2018_idioms, + unsafe_op_in_unsafe_fn, + clippy::undocumented_unsafe_blocks +)] #[cfg(any(CRYPTOGRAPHY_IS_BORINGSSL, CRYPTOGRAPHY_IS_AWSLC))] pub mod aead; diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index c7bcb3827201..35fcd6c33b4b 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -2,7 +2,11 @@ // 2.0, and the BSD License. See the LICENSE file in the root of this repository // for complete details. -#![deny(rust_2018_idioms, clippy::undocumented_unsafe_blocks)] +#![deny( + rust_2018_idioms, + unsafe_op_in_unsafe_fn, + clippy::undocumented_unsafe_blocks +)] #![allow(unknown_lints, non_local_definitions, clippy::result_large_err)] #[cfg(not(any(