Change Token::interpolated_to_tokenstream().

It is currently a method of `Token`, but it only is valid to call if
`self` is a `Token::Interpolated`. This commit eliminates the
possibility of misuse by changing it to an associated function that
takes a `Nonterminal`, which also simplifies the call sites.

This requires splitting out a new function, `nonterminal_to_string`.
This commit is contained in:
Nicholas Nethercote 2019-02-15 08:31:44 +11:00
parent f47ec2ad5b
commit d26bf742db
4 changed files with 38 additions and 40 deletions

View file

@ -178,8 +178,8 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec<Self>)>
tt!(Punct::new('#', false))
}
Interpolated(_) => {
let stream = token.interpolated_to_tokenstream(sess, span);
Interpolated(nt) => {
let stream = Token::interpolated_to_tokenstream(sess, nt, span);
TokenTree::Group(Group {
delimiter: Delimiter::None,
stream,