From 1ed0cbf698bbed4135eb4e47c4ac22a907dd41e9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 13 Jun 2025 12:59:25 -0700 Subject: [PATCH] Preserve Paren expression's attributes during Unparenthesize --- tests/ui-fulldeps/pprust-parenthesis-insertion.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs index 90e07bed40e7..6ac079ae4342 100644 --- a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs +++ b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs @@ -158,7 +158,12 @@ struct Unparenthesize; impl MutVisitor for Unparenthesize { fn visit_expr(&mut self, e: &mut Expr) { while let ExprKind::Paren(paren) = &mut e.kind { + let paren_attrs = mem::take(&mut e.attrs); *e = mem::replace(paren, Expr::dummy()); + if !paren_attrs.is_empty() { + assert!(e.attrs.is_empty()); + e.attrs = paren_attrs; + } } mut_visit::walk_expr(self, e); }