about summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty/src/pprust/state/item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pprust/state/item.rs')
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/item.rs65
1 files changed, 45 insertions, 20 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
index 8486e809378..d406a56c05d 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
@@ -37,18 +37,23 @@ impl<'a> State<'a> {
             ast::ForeignItemKind::Fn(func) => {
                 self.print_fn_full(ident, vis, attrs, &*func);
             }
-            ast::ForeignItemKind::Static(box ast::StaticItem { ty, mutability, expr, safety }) => {
-                self.print_item_const(
-                    ident,
-                    Some(*mutability),
-                    &ast::Generics::default(),
-                    ty,
-                    expr.as_deref(),
-                    vis,
-                    *safety,
-                    ast::Defaultness::Final,
-                )
-            }
+            ast::ForeignItemKind::Static(box ast::StaticItem {
+                ty,
+                mutability,
+                expr,
+                safety,
+                define_opaque,
+            }) => self.print_item_const(
+                ident,
+                Some(*mutability),
+                &ast::Generics::default(),
+                ty,
+                expr.as_deref(),
+                vis,
+                *safety,
+                ast::Defaultness::Final,
+                define_opaque.as_deref(),
+            ),
             ast::ForeignItemKind::TyAlias(box ast::TyAlias {
                 defaultness,
                 generics,
@@ -86,7 +91,9 @@ impl<'a> State<'a> {
         vis: &ast::Visibility,
         safety: ast::Safety,
         defaultness: ast::Defaultness,
+        define_opaque: Option<&[(ast::NodeId, ast::Path)]>,
     ) {
+        self.print_define_opaques(define_opaque);
         self.head("");
         self.print_visibility(vis);
         self.print_safety(safety);
@@ -174,7 +181,13 @@ impl<'a> State<'a> {
                 self.print_use_tree(tree);
                 self.word(";");
             }
-            ast::ItemKind::Static(box StaticItem { ty, safety, mutability: mutbl, expr: body }) => {
+            ast::ItemKind::Static(box StaticItem {
+                ty,
+                safety,
+                mutability: mutbl,
+                expr: body,
+                define_opaque,
+            }) => {
                 self.print_safety(*safety);
                 self.print_item_const(
                     item.ident,
@@ -185,9 +198,16 @@ impl<'a> State<'a> {
                     &item.vis,
                     ast::Safety::Default,
                     ast::Defaultness::Final,
+                    define_opaque.as_deref(),
                 );
             }
-            ast::ItemKind::Const(box ast::ConstItem { defaultness, generics, ty, expr }) => {
+            ast::ItemKind::Const(box ast::ConstItem {
+                defaultness,
+                generics,
+                ty,
+                expr,
+                define_opaque,
+            }) => {
                 self.print_item_const(
                     item.ident,
                     None,
@@ -197,6 +217,7 @@ impl<'a> State<'a> {
                     &item.vis,
                     ast::Safety::Default,
                     *defaultness,
+                    define_opaque.as_deref(),
                 );
             }
             ast::ItemKind::Fn(func) => {
@@ -537,7 +558,13 @@ impl<'a> State<'a> {
             ast::AssocItemKind::Fn(func) => {
                 self.print_fn_full(ident, vis, attrs, &*func);
             }
-            ast::AssocItemKind::Const(box ast::ConstItem { defaultness, generics, ty, expr }) => {
+            ast::AssocItemKind::Const(box ast::ConstItem {
+                defaultness,
+                generics,
+                ty,
+                expr,
+                define_opaque,
+            }) => {
                 self.print_item_const(
                     ident,
                     None,
@@ -547,6 +574,7 @@ impl<'a> State<'a> {
                     vis,
                     ast::Safety::Default,
                     *defaultness,
+                    define_opaque.as_deref(),
                 );
             }
             ast::AssocItemKind::Type(box ast::TyAlias {
@@ -652,7 +680,7 @@ impl<'a> State<'a> {
     ) {
         let ast::Fn { defaultness, generics, sig, contract, body, define_opaque } = func;
 
-        self.print_define_opaques(define_opaque);
+        self.print_define_opaques(define_opaque.as_deref());
 
         if body.is_some() {
             self.head("");
@@ -672,10 +700,7 @@ impl<'a> State<'a> {
         }
     }
 
-    fn print_define_opaques(
-        &mut self,
-        define_opaque: Option<&[(ast::NodeId, ast::Path)]>,
-    ) {
+    fn print_define_opaques(&mut self, define_opaque: Option<&[(ast::NodeId, ast::Path)]>) {
         if let Some(define_opaque) = define_opaque {
             self.word("#[define_opaque(");
             for (i, (_, path)) in define_opaque.iter().enumerate() {