mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
short circuit logic better
This commit is contained in:
parent
0cf9d9c440
commit
aecdb921ae
1 changed files with 7 additions and 6 deletions
|
@ -114,12 +114,13 @@ impl<'tcx> ClampSuggestion<'tcx> {
|
|||
if max_type != min_type {
|
||||
return false;
|
||||
}
|
||||
let max = constant(cx, cx.typeck_results(), self.params.max);
|
||||
let min = constant(cx, cx.typeck_results(), self.params.min);
|
||||
let cmp = max
|
||||
.zip(min)
|
||||
.and_then(|(max, min)| Constant::partial_cmp(cx.tcx, max_type, &min, &max));
|
||||
cmp.is_some_and(|cmp| cmp != Ordering::Greater)
|
||||
if let Some(max) = constant(cx, cx.typeck_results(), self.params.max)
|
||||
&& let Some(min) = constant(cx, cx.typeck_results(), self.params.min)
|
||||
{
|
||||
Constant::partial_cmp(cx.tcx, max_type, &min, &max).is_some_and(|o| o != Ordering::Greater)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue