Use saturating_sub in more token-walking methods (#4773)

This commit is contained in:
Charlie Marsh 2023-06-01 17:16:32 -04:00 committed by GitHub
parent 0099f9720f
commit ab26f2dc9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 50 deletions

View file

@ -132,11 +132,11 @@ impl<'a> Generator<'a> {
}
fn body<U>(&mut self, stmts: &[Stmt<U>]) {
self.indent_depth += 1;
self.indent_depth = self.indent_depth.saturating_add(1);
for stmt in stmts {
self.unparse_stmt(stmt);
}
self.indent_depth -= 1;
self.indent_depth = self.indent_depth.saturating_sub(1);
}
fn p(&mut self, s: &str) {
@ -531,11 +531,11 @@ impl<'a> Generator<'a> {
self.p(":");
});
for case in cases {
self.indent_depth += 1;
self.indent_depth = self.indent_depth.saturating_add(1);
statement!({
self.unparse_match_case(case);
});
self.indent_depth -= 1;
self.indent_depth = self.indent_depth.saturating_sub(1);
}
}
Stmt::Raise(ast::StmtRaise {