about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-11-25 11:31:22 -0500
committerAaron Hill <aa1ronham@gmail.com>2020-11-25 11:32:08 -0500
commitbaefba80b733f1676f141a033424ec0d257b09d9 (patch)
tree1f6ca22ec78b28724a27c307972cad2e8946176e
parent9c9f40656dadf3c2a05b2d5add875f5d0d3541d8 (diff)
downloadrust-baefba80b733f1676f141a033424ec0d257b09d9.tar.gz
rust-baefba80b733f1676f141a033424ec0d257b09d9.zip
Adjust pretty-print compat hack to work with item statements
-rw-r--r--compiler/rustc_ast/src/token.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs
index 2bba7e618c0..f583825fbb3 100644
--- a/compiler/rustc_ast/src/token.rs
+++ b/compiler/rustc_ast/src/token.rs
@@ -785,13 +785,20 @@ impl Nonterminal {
     /// See issue #73345 for more details.
     /// FIXME(#73933): Remove this eventually.
     pub fn pretty_printing_compatibility_hack(&self) -> bool {
-        if let NtItem(item) = self {
-            let name = item.ident.name;
-            if name == sym::ProceduralMasqueradeDummyType || name == sym::ProcMacroHack {
-                if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
-                    if let [variant] = &*enum_def.variants {
-                        return variant.ident.name == sym::Input;
-                    }
+        let item = match self {
+            NtItem(item) => item,
+            NtStmt(stmt) => match &stmt.kind {
+                ast::StmtKind::Item(item) => item,
+                _ => return false,
+            },
+            _ => return false,
+        };
+
+        let name = item.ident.name;
+        if name == sym::ProceduralMasqueradeDummyType || name == sym::ProcMacroHack {
+            if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
+                if let [variant] = &*enum_def.variants {
+                    return variant.ident.name == sym::Input;
                 }
             }
         }