Remove NtMeta.

Note: there was an existing code path involving `Interpolated` in
`MetaItem::from_tokens` that was dead. This commit transfers that to the
new form, but puts an `unreachable!` call inside it.
This commit is contained in:
Nicholas Nethercote 2024-04-18 16:22:02 +10:00
parent ef1114a964
commit 7ea59e053b
20 changed files with 67 additions and 64 deletions

View file

@ -32,7 +32,7 @@ impl<'a> Parser<'a> {
| MetaVarKind::Expr { .. }
| MetaVarKind::Ty { .. }
| MetaVarKind::Literal // `true`, `false`
| MetaVarKind::Meta
| MetaVarKind::Meta { .. }
| MetaVarKind::Path => true,
MetaVarKind::Item
@ -51,7 +51,6 @@ impl<'a> Parser<'a> {
NtStmt(_)
| NtExpr(_)
| NtLiteral(_) // `true`, `false`
| NtMeta(_)
| NtPath(_) => true,
NtItem(_) | NtBlock(_) => false,
@ -98,7 +97,7 @@ impl<'a> Parser<'a> {
token::NtLifetime(..) => true,
token::Interpolated(nt) => match &**nt {
NtBlock(_) | NtStmt(_) | NtExpr(_) | NtLiteral(_) => true,
NtItem(_) | NtMeta(_) | NtPath(_) => false,
NtItem(_) | NtPath(_) => false,
},
token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(k))) => match k {
MetaVarKind::Block
@ -108,7 +107,7 @@ impl<'a> Parser<'a> {
MetaVarKind::Item
| MetaVarKind::Pat(_)
| MetaVarKind::Ty { .. }
| MetaVarKind::Meta
| MetaVarKind::Meta { .. }
| MetaVarKind::Path
| MetaVarKind::Vis => false,
MetaVarKind::Lifetime | MetaVarKind::Ident | MetaVarKind::TT => {
@ -207,7 +206,9 @@ impl<'a> Parser<'a> {
NonterminalKind::Path => {
NtPath(P(self.collect_tokens_no_attrs(|this| this.parse_path(PathStyle::Type))?))
}
NonterminalKind::Meta => NtMeta(P(self.parse_attr_item(ForceCollect::Yes)?)),
NonterminalKind::Meta => {
return Ok(ParseNtResult::Meta(P(self.parse_attr_item(ForceCollect::Yes)?)));
}
NonterminalKind::Vis => {
return Ok(ParseNtResult::Vis(P(self.collect_tokens_no_attrs(|this| {
this.parse_visibility(FollowedByType::Yes)