about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-06-25 22:05:08 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-06-25 22:35:01 +0000
commitf0310e061b9d0a7d8dc515390fa68dfb6318df4b (patch)
tree09633b17c39077a6128e2a7a34d86f7daffcfbab /src/libsyntax/print
parentb8214dc6c6fc20d0a660fb5700dca9ebf51ebe89 (diff)
parentdc3d878e0f513bde3dfad69d4f2722e2884c23a3 (diff)
downloadrust-f0310e061b9d0a7d8dc515390fa68dfb6318df4b.tar.gz
rust-f0310e061b9d0a7d8dc515390fa68dfb6318df4b.zip
Rollup merge of #34213 - josephDunne:trait_item_macros, r=jseyfried
**syntax-[breaking-change]** cc #31645
New `TraitItemKind::Macro` variant

This change adds support for macro expansion inside trait items by adding the new `TraitItemKind::Macro` and associated parsing code.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index a2ee5bf6090..fb1c9679c8f 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1550,6 +1550,17 @@ impl<'a> State<'a> {
                 try!(self.print_associated_type(ti.ident, Some(bounds),
                                            default.as_ref().map(|ty| &**ty)));
             }
+            ast::TraitItemKind::Macro(codemap::Spanned { ref node, .. }) => {
+                // code copied from ItemKind::Mac:
+                self.print_path(&node.path, false, 0)?;
+                word(&mut self.s, "! ")?;
+                self.cbox(INDENT_UNIT)?;
+                self.popen()?;
+                self.print_tts(&node.tts[..])?;
+                self.pclose()?;
+                word(&mut self.s, ";")?;
+                self.end()?
+            }
         }
         self.ann.post(self, NodeSubItem(ti.id))
     }