rust-lang / rust-lang/rust-clippy

Should absurd_extreme_comparisons alert for comparison between usize and u64?

Open
#1,802 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

S-needs-discussion
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.