Skip to content

Commit

Permalink
Give ast::ExprKind::Paren no-op expressions the same node ids as th…
Browse files Browse the repository at this point in the history
…eir children.
  • Loading branch information
jseyfried committed Jun 29, 2016
1 parent a9d25f8 commit 8557a2e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,6 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {

pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mut T) -> Expr {
Expr {
id: folder.new_id(id),
node: match node {
ExprKind::Box(e) => {
ExprKind::Box(folder.fold_expr(e))
Expand Down Expand Up @@ -1270,9 +1269,19 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
fields.move_map(|x| folder.fold_field(x)),
maybe_expr.map(|x| folder.fold_expr(x)))
},
ExprKind::Paren(ex) => ExprKind::Paren(folder.fold_expr(ex)),
ExprKind::Paren(ex) => {
let sub_expr = folder.fold_expr(ex);
return Expr {
// Nodes that are equal modulo `Paren` sugar no-ops should have the same ids.
id: sub_expr.id,
node: ExprKind::Paren(sub_expr),
span: folder.new_span(span),
attrs: fold_attrs(attrs.into(), folder).into(),
};
}
ExprKind::Try(ex) => ExprKind::Try(folder.fold_expr(ex)),
},
id: folder.new_id(id),
span: folder.new_span(span),
attrs: fold_attrs(attrs.into(), folder).into(),
}
Expand Down

0 comments on commit 8557a2e

Please sign in to comment.