rust-lang / rust-lang/rust-clippy
conditions that are always true or false
Open
Nobody has claimed this yet.
A-lint
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
It would be great if clippy could somehow try to const-eval expressions in conditions and warn if they always return true/false.
Lint Name
?
Category
suspicious, complexity
Advantage
This could find logic bugs for example
Drawbacks
No response
Example
#![feature(inline_const)]
const X: [i32; 7] = [1, 2, 3, 4, 5, 6, 9];
pub fn main() {
// always true
if const { X[1] == 2 } {}
// always false
if const { X[0] == X[4] } || 2 == X[0] {}
}
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
The issue names no files, tests, or entry points. Start by reviewing the proposed Rust examples and the requested suspicious/complexity categories, then identify the appropriate Clippy lint design and validation path; done means warning when the shown conditions always evaluate true or false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100