about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2025-06-13 12:59:25 -0700
committerDavid Tolnay <dtolnay@gmail.com>2025-06-19 12:05:46 -0700
commit1ed0cbf698bbed4135eb4e47c4ac22a907dd41e9 (patch)
tree994b9e64cf4662bd9208974941b481d71a1da59d
parent8de4c7234dd9b97c9d76b58671343fdbbc9a433e (diff)
downloadrust-1ed0cbf698bbed4135eb4e47c4ac22a907dd41e9.tar.gz
rust-1ed0cbf698bbed4135eb4e47c4ac22a907dd41e9.zip
Preserve Paren expression's attributes during Unparenthesize
-rw-r--r--tests/ui-fulldeps/pprust-parenthesis-insertion.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/ui-fulldeps/pprust-parenthesis-insertion.rs b/tests/ui-fulldeps/pprust-parenthesis-insertion.rs
index 90e07bed40e..6ac079ae434 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);
     }