Remove NtBlock
, Nonterminal
, and TokenKind::Interpolated
.
`NtBlock` is the last remaining variant of `Nonterminal`, so once it is gone then `Nonterminal` can be removed as well.
This commit is contained in:
parent
70dab5a27c
commit
bb495d6d3e
18 changed files with 108 additions and 388 deletions
|
@ -238,13 +238,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
Some(AttrTokenTree::Delimited(sp, spacing, delim, inner))
|
||||
}
|
||||
AttrTokenTree::Token(
|
||||
Token {
|
||||
kind:
|
||||
TokenKind::NtIdent(..)
|
||||
| TokenKind::NtLifetime(..)
|
||||
| TokenKind::Interpolated(..),
|
||||
..
|
||||
},
|
||||
Token { kind: TokenKind::NtIdent(..) | TokenKind::NtLifetime(..), .. },
|
||||
_,
|
||||
) => {
|
||||
panic!("Nonterminal should have been flattened: {:?}", tree);
|
||||
|
|
|
@ -66,9 +66,7 @@ pub(super) fn failed_to_match_macro(
|
|||
}
|
||||
|
||||
if let MatcherLoc::Token { token: expected_token } = &remaining_matcher
|
||||
&& (matches!(expected_token.kind, TokenKind::Interpolated(_))
|
||||
|| matches!(token.kind, TokenKind::Interpolated(_))
|
||||
|| matches!(expected_token.kind, TokenKind::OpenDelim(Delimiter::Invisible(_)))
|
||||
&& (matches!(expected_token.kind, TokenKind::OpenDelim(Delimiter::Invisible(_)))
|
||||
|| matches!(token.kind, TokenKind::OpenDelim(Delimiter::Invisible(_))))
|
||||
{
|
||||
err.note("captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens");
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_ast::mut_visit::{self, MutVisitor};
|
||||
use rustc_ast::token::{
|
||||
|
@ -307,7 +306,9 @@ pub(super) fn transcribe<'a>(
|
|||
let tt = match cur_matched {
|
||||
MatchedSingle(ParseNtResult::Tt(tt)) => {
|
||||
// `tt`s are emitted into the output stream directly as "raw tokens",
|
||||
// without wrapping them into groups.
|
||||
// without wrapping them into groups. Other variables are emitted into
|
||||
// the output stream as groups with `Delimiter::Invisible` to maintain
|
||||
// parsing priorities.
|
||||
maybe_use_metavar_location(psess, &stack, sp, tt, &mut marker)
|
||||
}
|
||||
MatchedSingle(ParseNtResult::Ident(ident, is_raw)) => {
|
||||
|
@ -325,6 +326,11 @@ pub(super) fn transcribe<'a>(
|
|||
MatchedSingle(ParseNtResult::Item(item)) => {
|
||||
mk_delimited(item.span, MetaVarKind::Item, TokenStream::from_ast(item))
|
||||
}
|
||||
MatchedSingle(ParseNtResult::Block(block)) => mk_delimited(
|
||||
block.span,
|
||||
MetaVarKind::Block,
|
||||
TokenStream::from_ast(block),
|
||||
),
|
||||
MatchedSingle(ParseNtResult::Stmt(stmt)) => {
|
||||
let stream = if let StmtKind::Empty = stmt.kind {
|
||||
// FIXME: Properly collect tokens for empty statements.
|
||||
|
@ -385,15 +391,6 @@ pub(super) fn transcribe<'a>(
|
|||
MatchedSingle(ParseNtResult::Vis(vis)) => {
|
||||
mk_delimited(vis.span, MetaVarKind::Vis, TokenStream::from_ast(vis))
|
||||
}
|
||||
MatchedSingle(ParseNtResult::Nt(nt)) => {
|
||||
// Other variables are emitted into the output stream as groups with
|
||||
// `Delimiter::Invisible` to maintain parsing priorities.
|
||||
// `Interpolated` is currently used for such groups in rustc parser.
|
||||
marker.visit_span(&mut sp);
|
||||
let use_span = nt.use_span();
|
||||
with_metavar_spans(|mspans| mspans.insert(use_span, sp));
|
||||
TokenTree::token_alone(token::Interpolated(Arc::clone(nt)), sp)
|
||||
}
|
||||
MatchedSeq(..) => {
|
||||
// We were unable to descend far enough. This is an error.
|
||||
return Err(dcx.create_err(VarStillRepeating { span: sp, ident }));
|
||||
|
|
|
@ -309,15 +309,6 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
|
|||
}));
|
||||
}
|
||||
|
||||
Interpolated(nt) => {
|
||||
let stream = TokenStream::from_nonterminal_ast(&nt);
|
||||
trees.push(TokenTree::Group(Group {
|
||||
delimiter: pm::Delimiter::None,
|
||||
stream: Some(stream),
|
||||
span: DelimSpan::from_single(span),
|
||||
}))
|
||||
}
|
||||
|
||||
OpenDelim(..) | CloseDelim(..) => unreachable!(),
|
||||
Eof => unreachable!(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue