Skip to content

Commit

Permalink
Adjust pretty-print compat hack to work with item statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Nov 25, 2020
1 parent 9c9f406 commit baefba8
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions compiler/rustc_ast/src/token.rs
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit baefba8

Please sign in to comment.