rust-lang / rust-lang/rust-clippy
items_after_statements shouldn't fire when const has no name
Open
Nobody has claimed this yet.
C-bug
I-false-positive
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
const _: () = assert!(mem::size_of::<RingKind>() <= u8::BITS as usize);
I'm putting this const assertion near the code that uses it to make understanding the assumptions easier. The lint shouldn't fire since there is no name so no way to refer to the const anyway.
Lint Name
items_after_statements
Reproducer
No response
Version
No response
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the items_after_statements lint and reproducing the issue with the unnamed const assertion shown in the report. Check the lint's existing tests, if present, and add coverage so this const form is not reported while named items after statements retain their existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100