Remove NtItem
and NtStmt
.
This involves replacing `nt_pretty_printing_compatibility_hack` with `stream_pretty_printing_compatibility_hack`. The handling of statements in `transcribe` is slightly different to other nonterminal kinds, due to the lack of `from_ast` implementation for empty statements. Notable test changes: - `tests/ui/proc-macro/expand-to-derive.rs`: the diff looks large but the only difference is the insertion of a single invisible-delimited group around a metavar.
This commit is contained in:
parent
98a48781fe
commit
141719f68a
18 changed files with 198 additions and 145 deletions
|
@ -48,12 +48,11 @@ impl<'a> Parser<'a> {
|
|||
/// Old variant of `may_be_ident`. Being phased out.
|
||||
fn nt_may_be_ident(nt: &Nonterminal) -> bool {
|
||||
match nt {
|
||||
NtStmt(_)
|
||||
| NtExpr(_)
|
||||
NtExpr(_)
|
||||
| NtLiteral(_) // `true`, `false`
|
||||
=> true,
|
||||
|
||||
NtItem(_) | NtBlock(_) => false,
|
||||
NtBlock(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,8 +95,7 @@ impl<'a> Parser<'a> {
|
|||
token::OpenDelim(Delimiter::Brace) => true,
|
||||
token::NtLifetime(..) => true,
|
||||
token::Interpolated(nt) => match &**nt {
|
||||
NtBlock(_) | NtStmt(_) | NtExpr(_) | NtLiteral(_) => true,
|
||||
NtItem(_) => false,
|
||||
NtBlock(_) | NtExpr(_) | NtLiteral(_) => true,
|
||||
},
|
||||
token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(k))) => match k {
|
||||
MetaVarKind::Block
|
||||
|
@ -147,7 +145,7 @@ impl<'a> Parser<'a> {
|
|||
// Note that TT is treated differently to all the others.
|
||||
NonterminalKind::TT => return Ok(ParseNtResult::Tt(self.parse_token_tree())),
|
||||
NonterminalKind::Item => match self.parse_item(ForceCollect::Yes)? {
|
||||
Some(item) => NtItem(item),
|
||||
Some(item) => return Ok(ParseNtResult::Item(item)),
|
||||
None => {
|
||||
return Err(self
|
||||
.dcx()
|
||||
|
@ -160,7 +158,7 @@ impl<'a> Parser<'a> {
|
|||
NtBlock(self.collect_tokens_no_attrs(|this| this.parse_block())?)
|
||||
}
|
||||
NonterminalKind::Stmt => match self.parse_stmt(ForceCollect::Yes)? {
|
||||
Some(s) => NtStmt(P(s)),
|
||||
Some(stmt) => return Ok(ParseNtResult::Stmt(P(stmt))),
|
||||
None => {
|
||||
return Err(self
|
||||
.dcx()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue