Skip to content

Commit 497cb89

Browse files
committed
Preserve Paren expression's attributes during Unparenthesize
1 parent 0d6ab20 commit 497cb89

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/ui-fulldeps/pprust-parenthesis-insertion.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ struct Unparenthesize;
154154
impl MutVisitor for Unparenthesize {
155155
fn visit_expr(&mut self, e: &mut P<Expr>) {
156156
while let ExprKind::Paren(paren) = &mut e.kind {
157+
let paren_attrs = mem::take(&mut e.attrs);
157158
*e = mem::replace(paren, Expr::dummy());
159+
if !paren_attrs.is_empty() {
160+
assert!(e.attrs.is_empty());
161+
e.attrs = paren_attrs;
162+
}
158163
}
159164
mut_visit::walk_expr(self, e);
160165
}

0 commit comments

Comments
 (0)