Skip to content

Commit baefba8

Browse files
committed
Adjust pretty-print compat hack to work with item statements
1 parent 9c9f406 commit baefba8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

compiler/rustc_ast/src/token.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,20 @@ impl Nonterminal {
785785
/// See issue #73345 for more details.
786786
/// FIXME(#73933): Remove this eventually.
787787
pub fn pretty_printing_compatibility_hack(&self) -> bool {
788-
if let NtItem(item) = self {
789-
let name = item.ident.name;
790-
if name == sym::ProceduralMasqueradeDummyType || name == sym::ProcMacroHack {
791-
if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
792-
if let [variant] = &*enum_def.variants {
793-
return variant.ident.name == sym::Input;
794-
}
788+
let item = match self {
789+
NtItem(item) => item,
790+
NtStmt(stmt) => match &stmt.kind {
791+
ast::StmtKind::Item(item) => item,
792+
_ => return false,
793+
},
794+
_ => return false,
795+
};
796+
797+
let name = item.ident.name;
798+
if name == sym::ProceduralMasqueradeDummyType || name == sym::ProcMacroHack {
799+
if let ast::ItemKind::Enum(enum_def, _) = &item.kind {
800+
if let [variant] = &*enum_def.variants {
801+
return variant.ident.name == sym::Input;
795802
}
796803
}
797804
}

0 commit comments

Comments
 (0)