false positive when using a function called min
on an unsigned integer type, when the function doesn't return a minimum (e.g. in a builder pattern)
#13191
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Uh oh!
There was an error while loading. Please reload this page.
Summary
when creating a struct with a
min: u8/u16/..
field and using the builder pattern to fill that field with a value of0
, it erroneously emits aunnecessary_min_or_max
warning, even though the function is used to set a field on a struct, the structParser
is not a number so it doesn't make sense for it to "never [be] smaller than0
" and the return value of themin()
function is not the same as the input value and is not a number at all.also, when i run
cargo --fix
i get this message:side note: this lint doesn't get triggered with a
usize
Lint Name
unnecessary_min_or_max
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
no warning
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: