Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ketsuban opened this issue Oct 24, 2023 · 2 comments · May be fixed by #13888
Open

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

ketsuban opened this issue Oct 24, 2023 · 2 comments · May be fixed by #13888
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@ketsuban
Copy link

ketsuban commented Oct 24, 2023

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 ketsuban added the C-bug Category: Clippy is not doing the correct thing label Oct 24, 2023
@J-ZhengLi
Copy link
Member

@rustbot claim

@profetia
Copy link

@rustbot claim

@rustbot rustbot assigned profetia and unassigned J-ZhengLi Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
3 participants