- Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
I'm using the undocumented_unsafe_blocks
lint in my Cargo.toml
, but want to exclude a certain module from any lints, as it's auto generated by using #[allow(clippy::all)]
.
The lint still triggers.
P.S.: Thanks for your great presentation at Rustikon @llogiq, where I learned about this lint ❤ !
Lint Name
No response
Reproducer
I tried this code:
# Cargo.toml [package] name = "foo" version = "0.1.0" edition = "2021" [dependencies] [lints.clippy] undocumented_unsafe_blocks = "deny"
// src/lib.rs #![allow(clippy::all)] pub fn add(left: u64, right: u64) -> u64 { unsafe { foo(left, right) } } unsafe fn foo(left: u64, right: u64) -> u64 { left + right }
I saw this happen:
error: unsafe block missing a safety comment --> src/lib.rs:3:5 | 3 | unsafe { foo(left, right) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a safety comment on the preceding line = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks = note: requested on the command line with `-D clippy::undocumented-unsafe-blocks` error: could not compile `foo` (lib) due to 1 previous error
I expected to see this happen:
With this diff, clippy ignores the lint as expected:
#![allow(clippy::all, clippy::undocumented_unsafe_blocks)]
Version
rustc 1.85.1 (4eb161250 2025-03-15) binary: rustc commit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181 commit-date: 2025-03-15 host: aarch64-apple-darwin release: 1.85.1 LLVM version: 19.1.7
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have