Skip to content

Commit 1ed0cbf

Browse files
committed
Preserve Paren expression's attributes during Unparenthesize
1 parent 8de4c72 commit 1ed0cbf

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
@@ -158,7 +158,12 @@ struct Unparenthesize;
158158
impl MutVisitor for Unparenthesize {
159159
fn visit_expr(&mut self, e: &mut Expr) {
160160
while let ExprKind::Paren(paren) = &mut e.kind {
161+
let paren_attrs = mem::take(&mut e.attrs);
161162
*e = mem::replace(paren, Expr::dummy());
163+
if !paren_attrs.is_empty() {
164+
assert!(e.attrs.is_empty());
165+
e.attrs = paren_attrs;
166+
}
162167
}
163168
mut_visit::walk_expr(self, e);
164169
}

0 commit comments

Comments
 (0)