Skip to content

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

Open
@Xaeroxe

Description

@Xaeroxe

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

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions