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
@ -43,7 +43,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if_chain! {
|
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
|
// Check if the conditional expression is a binary operation
|
||||||
if let ExprKind::Binary(ref cond_op, cond_left, cond_right) = cond.kind;
|
if let ExprKind::Binary(ref cond_op, cond_left, cond_right) = cond.kind;
|
||||||
|
@ -157,4 +157,12 @@ fn main() {
|
|||||||
if i_64 != 0 {
|
if i_64 != 0 {
|
||||||
i_64 -= 1;
|
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 {
|
if i_64 != 0 {
|
||||||
i_64 -= 1;
|
i_64 -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue #7831
|
||||||
|
// No Lint
|
||||||
|
if u_32 > 0 {
|
||||||
|
u_32 -= 1;
|
||||||
|
} else {
|
||||||
|
println!("side effect");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user