rust-lang / rust-lang/rust-clippy
move expect from `allow_attributes_without_reason` to it's own lint
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
Currently allow_attributes works only on allow, but doesn't trigger on expect.
The allow_attributes_without_reason works differently, it applies to both allow and expect.
It would be nice if these could be set separately, so that allow_attributes_without_reason only applied to
#[allow()] and expect_attributes_without_reason could apply the same logic to expect.
Advantage
The allow_attributes lint is too much for many cases, such as when you conditionally need an allow in a #[cfg()] where #[expect(...)] is too strong.
We would like to be able to use:
#[allow(...) reason = "...."]
#[expect(something_else)]
but erroring on
#[allow(some_other_thing)]
Moving expect_attributes_without_reason to it's own lint would allow this kind of flexibility.
Drawbacks
People relying on the current behavior of allow_attributes_without_reason need to enable another lint to keep that behavior.
Example
<code>
Could be written as:
<code>
Comparison with existing lints
No response
Additional Context
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 tracing the existing allow_attributes_without_reason lint and its tests to understand how it handles both allow and expect attributes. Separate the expect behavior into expect_attributes_without_reason, preserve the existing behavior for allow, and verify both lints cover the requested examples and configuration cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100