Skip to content

Commit

Permalink
Re-enable usage of saved tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Mar 18, 2020
1 parent 542e2f5 commit c99fd5c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/librustc_ast/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl PartialEq<TokenKind> for Token {
}
}

#[derive(Clone, RustcEncodable, RustcDecodable)]
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
/// For interpolation during macro expansion.
pub enum Nonterminal {
NtItem(P<ast::Item>),
Expand Down Expand Up @@ -786,7 +786,7 @@ impl PartialEq for Nonterminal {
}
}

impl fmt::Debug for Nonterminal {
/*impl fmt::Debug for Nonterminal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
NtItem(..) => f.pad("NtItem(..)"),
Expand All @@ -804,7 +804,7 @@ impl fmt::Debug for Nonterminal {
NtLifetime(..) => f.pad("NtLifetime(..)"),
}
}
}
}*/

impl<CTX> HashStable<CTX> for Nonterminal
where
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_parse/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,12 @@ pub fn nt_to_tokenstream(nt: &Nonterminal, sess: &ParseSess, span: Span) -> Toke
Some(tokenstream::TokenTree::token(token::Lifetime(ident.name), ident.span).into())
}
Nonterminal::NtTT(ref tt) => Some(tt.clone().into()),
_ => None
/*Nonterminal::NtLiteral(ref expr) | Nonterminal::NtExpr(ref expr) => expr.tokens.clone(),
Nonterminal::NtLiteral(ref expr) | Nonterminal::NtExpr(ref expr) => expr.tokens.clone(),
Nonterminal::NtTy(ref ty) => ty.tokens.clone(),
Nonterminal::NtBlock(ref block) => block.tokens.clone(),
Nonterminal::NtPat(ref pat) => pat.tokens.clone(),
Nonterminal::NtStmt(ref stmt) => stmt.tokens.clone(),
Nonterminal::NtMeta(_) | Nonterminal::NtPath(_) | Nonterminal::NtVis(_) => None,*/
Nonterminal::NtMeta(_) | Nonterminal::NtPath(_) | Nonterminal::NtVis(_) => None,
};

// FIXME(#43081): Avoid this pretty-print + reparse hack
Expand Down Expand Up @@ -367,6 +366,7 @@ pub fn nt_to_tokenstream(nt: &Nonterminal, sess: &ParseSess, span: Span) -> Toke
going with stringified version"
);
}
info!("nt_to_tokenstream: no tokens found at {:?} for {:?}", span, nt);
return tokens_for_real;
}

Expand Down

0 comments on commit c99fd5c

Please sign in to comment.