Skip to content

Commit

Permalink
Recurse over fold expr in just one place
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 15, 2023
1 parent 2dc903f commit 04c9972
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/test_precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,12 @@ fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr {

impl Fold for ParenthesizeEveryExpr {
fn fold_expr(&mut self, expr: Expr) -> Expr {
if needs_paren(&expr) {
parenthesize(fold_expr(self, expr))
let needs_paren = needs_paren(&expr);
let folded = fold_expr(self, expr);
if needs_paren {
parenthesize(folded)
} else {
fold_expr(self, expr)
folded
}
}

Expand Down

0 comments on commit 04c9972

Please sign in to comment.