Skip to content

absurd extreme comparisons not working for std::time::Duration #14524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Xaeroxe opened this issue Apr 2, 2025 · 1 comment · May be fixed by #14817
Open

absurd extreme comparisons not working for std::time::Duration #14524

Xaeroxe opened this issue Apr 2, 2025 · 1 comment · May be fixed by #14817
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@Xaeroxe
Copy link
Contributor

Xaeroxe commented Apr 2, 2025

Summary

Duration values cannot be negative under any circumstance, so it's not useful to check if a Duration is less than zero. Please make sure all Durations which can be const evaluated to zero, are treated as zero for the purposes of this lint.

Lint Name

absurd_extreme_comparisons

Reproducer

I tried this code:

if duration < Duration::from_secs(0) {
    // ...
}

I expected to see this happen: absurd_extreme_comparisons lint activates

Instead, this happened: no lint is triggered, code is accepted as is

Version

rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: aarch64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7
@Xaeroxe Xaeroxe added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Apr 2, 2025
@alex-semenyuk
Copy link
Member

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants