Skip to content

undocumented_unsafe_blocks false positive on consts #11246

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

Closed
jhpratt opened this issue Jul 28, 2023 · 4 comments · Fixed by #11375
Closed

undocumented_unsafe_blocks false positive on consts #11246

jhpratt opened this issue Jul 28, 2023 · 4 comments · Fixed by #11375
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

@jhpratt
Copy link
Member

jhpratt commented Jul 28, 2023

Summary

See repro, as it's self-explanatory.

Lint Name

undocumented_unsafe_blocks

Reproducer

#![deny(clippy::undocumented_unsafe_blocks)]

// Safety: foo
const _: () = unsafe {};

The lint fires, but it should not, as a safety comment is present on the preceding line. This is the case regardless of configuration.

Version

rustc 1.73.0-nightly (500647fd8 2023-07-27)
binary: rustc
commit-hash: 500647fd8138cc09e87edb08d62f81654fbf6ef8
commit-date: 2023-07-27
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 16.0.5

Additional Labels

No response

@jhpratt jhpratt added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jul 28, 2023
@J-ZhengLi
Copy link
Member

always wonder how this lint was able to check comments 🤔 , so I'm gonna try @rustbot claim

@J-ZhengLi
Copy link
Member

J-ZhengLi commented Aug 18, 2023

as it turns out, there was a similar issue (#10832) which got fixed by adding a configuration to this lint.

adding accept-comment-above-statement = true should fix this

@J-ZhengLi J-ZhengLi removed their assignment Aug 18, 2023
@jhpratt
Copy link
Member Author

jhpratt commented Aug 18, 2023

As I said in the original issue, this occurs regardless of configuration.

@J-ZhengLi
Copy link
Member

As I said in the original issue, this occurs regardless of configuration.

oops, I didn't read it through, my bad

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
2 participants