mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +00:00
Auto merge of #7832 - narpfel:implicit-saturating-sub-false-positive-else, r=giraffate
Fix false positive of `implicit_saturating_sub` with `else` clause Fixes #7831 changelog: Fix false positive of [`implicit_saturating_sub`] with `else` clause
This commit is contained in:
commit
af85240049
3 changed files with 17 additions and 1 deletions
|
@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
|
|||
return;
|
||||
}
|
||||
if_chain! {
|
||||
if let Some(higher::If { cond, then, .. }) = higher::If::hir(expr);
|
||||
if let Some(higher::If { cond, then, r#else: None }) = higher::If::hir(expr);
|
||||
|
||||
// Check if the conditional expression is a binary operation
|
||||
if let ExprKind::Binary(ref cond_op, cond_left, cond_right) = cond.kind;
|
||||
|
|
|
@ -157,4 +157,12 @@ fn main() {
|
|||
if i_64 != 0 {
|
||||
i_64 -= 1;
|
||||
}
|
||||
|
||||
// issue #7831
|
||||
// No Lint
|
||||
if u_32 > 0 {
|
||||
u_32 -= 1;
|
||||
} else {
|
||||
println!("side effect");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,4 +203,12 @@ fn main() {
|
|||
if i_64 != 0 {
|
||||
i_64 -= 1;
|
||||
}
|
||||
|
||||
// issue #7831
|
||||
// No Lint
|
||||
if u_32 > 0 {
|
||||
u_32 -= 1;
|
||||
} else {
|
||||
println!("side effect");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue