-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
manual_clamp doesn't trigger if one of the bounds being used is the return value from a function.
Applying this lint might change the meaning of the code if a function returns different results successive times it's called, but I think for a MaybeIncorrect lint it's reasonable to suggest this at least in cases where the function takes no mutable references and is given the same arguments.
Lint Name
manual_clamp
Reproducer
I tried this code:
fn upper_bound() -> f32 {
5.0
}
pub fn manual_clamp(f: f32) -> f32 {
if f < 0. { 0. } else if f > upper_bound() { upper_bound() } else { f }
}I expected to see the manual_clamp lint trigger on the manual_clamp function.
Instead, this happened:
No lints
Version
rustc 1.94.0 (4a4ef493e 2026-03-02)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: x86_64-unknown-linux-gnu
release: 1.94.0
LLVM version: 21.1.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't