Auto merge of #13513 - samueltardieu:push-zvvzytrovulq, r=y21

Style: do not defensively use `saturating_sub()`

Using `saturating_sub()` here in code which cannot fail brings a false sense of security. If for any reason a logic error was introduced and caused `self.loop_depth` to reach 0 before being decremented, using `saturating_sub(1)` would silently mask the programming error instead of panicking loudly as it should (at least in dev profile).

changelog: none
This commit is contained in:
bors
2024-10-06 17:15:53 +00:00
+1 -1
View File
@@ -112,7 +112,7 @@ fn visit_expr(&mut self, ex: &'hir Expr<'_>) {
ExprKind::Loop(..) => {
self.loop_depth += 1;
walk_expr(self, ex);
self.loop_depth = self.loop_depth.saturating_sub(1);
self.loop_depth -= 1;
},
_ => {
// Calls to a function that never return