rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

undocumented_unsafe_blocks doesn't detect safety comment above associated constant

Open ketsuban opened this issue 1 year ago • 1 comments

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

ketsuban avatar Oct 24 '23 23:10 ketsuban

@rustbot claim

J-ZhengLi avatar Nov 07 '23 02:11 J-ZhengLi