Skip to content

undocumented_unsafe_blocks doesn't detect safety comment above associated constant #11709

Closed
@ketsuban

Description

@ketsuban

Summary

I make use of the voladdress crate which uses a pattern of "unsafe construction, safe use", but when I put a VolAddress in a constant clippy doesn't detect the safety comment I add above it.

Reproducer

I tried this code:

#![warn(clippy::undocumented_unsafe_block)]

use voladdress::{Safe, VolAddress};

struct Control(u16);

impl Control {
    // SAFETY: this is safe
    const REGISTER: VolAddress<Self, Safe, Safe> = unsafe { VolAddress::new(0x0400_0204) };
}

I expected to see this happen:
no clippy warning

Instead, this happened:
a clippy warning

Version

rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
binary: rustc
commit-hash: 1c05d50c8403c56d9a8b6fb871f15aaa26fb5d07
commit-date: 2023-10-21
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions