mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
Fix false positive of implicit_saturating_sub
with else
clause
Fixes #7831
This commit is contained in:
parent
d50cfd26e5
commit
a550133b8f
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