rust-lang / rust-lang/rust-clippy
Should absurd_extreme_comparisons alert for comparison between usize and u64?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
let t = i64::MAX;
assert!(t as u64 > usize::MAX as u64);
When compiling above snippet, clippy complains that:
note: #[warn(absurd_extreme_comparisons)] on by default
help: because usize::MAX as u64 is the maximum value for this type, this comparison is always false
It's true on amd64 platform but not true on i686 platform. Alert on this will assume the code is only compiled and run for amd64 target. And all portable code will need to allow absurd_extreme_comparisons explicitly.
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 reproducing the provided comparison with the absurd_extreme_comparisons lint on amd64 and i686 targets, then locate that lint's implementation and tests. Determine whether the warning is valid for each target; done means the lint no longer produces an incorrect platform-dependent diagnostic and relevant target behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100