Skip to content

Commit 9e22351

Browse files
committed
Rename NtOrTt as ParseNtResult.
It's more descriptive, and future-proofs it if/when additional variants get added.
1 parent 3449304 commit 9e22351

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ use rustc_data_structures::fx::FxHashMap;
8181
use rustc_data_structures::sync::Lrc;
8282
use rustc_errors::ErrorGuaranteed;
8383
use rustc_lint_defs::pluralize;
84-
use rustc_parse::parser::{NtOrTt, Parser};
84+
use rustc_parse::parser::{ParseNtResult, Parser};
8585
use rustc_span::symbol::Ident;
8686
use rustc_span::symbol::MacroRulesNormalizedIdent;
8787
use rustc_span::Span;
@@ -692,8 +692,8 @@ impl TtParser {
692692
Ok(nt) => nt,
693693
};
694694
let m = match nt {
695-
NtOrTt::Nt(nt) => MatchedNonterminal(Lrc::new(nt)),
696-
NtOrTt::Tt(tt) => MatchedTokenTree(tt),
695+
ParseNtResult::Nt(nt) => MatchedNonterminal(Lrc::new(nt)),
696+
ParseNtResult::Tt(tt) => MatchedTokenTree(tt),
697697
};
698698
mp.push_match(next_metavar, seq_depth, m);
699699
mp.idx += 1;

compiler/rustc_parse/src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ pub enum FlatToken {
14911491
}
14921492

14931493
#[derive(Debug)]
1494-
pub enum NtOrTt {
1494+
pub enum ParseNtResult {
14951495
Nt(Nonterminal),
14961496
Tt(TokenTree),
14971497
}

compiler/rustc_parse/src/parser/nonterminal.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_span::symbol::{kw, Ident};
88

99
use crate::errors::UnexpectedNonterminal;
1010
use crate::parser::pat::{CommaRecoveryMode, RecoverColon, RecoverComma};
11-
use crate::parser::{FollowedByType, ForceCollect, NtOrTt, Parser, PathStyle};
11+
use crate::parser::{FollowedByType, ForceCollect, ParseNtResult, Parser, PathStyle};
1212

1313
impl<'a> Parser<'a> {
1414
/// Checks whether a non-terminal may begin with a particular token.
@@ -103,14 +103,14 @@ impl<'a> Parser<'a> {
103103
/// Parse a non-terminal (e.g. MBE `:pat` or `:ident`). Inlined because there is only one call
104104
/// site.
105105
#[inline]
106-
pub fn parse_nonterminal(&mut self, kind: NonterminalKind) -> PResult<'a, NtOrTt> {
106+
pub fn parse_nonterminal(&mut self, kind: NonterminalKind) -> PResult<'a, ParseNtResult> {
107107
// A `macro_rules!` invocation may pass a captured item/expr to a proc-macro,
108108
// which requires having captured tokens available. Since we cannot determine
109109
// in advance whether or not a proc-macro will be (transitively) invoked,
110110
// we always capture tokens for any `Nonterminal` which needs them.
111111
let mut nt = match kind {
112112
// Note that TT is treated differently to all the others.
113-
NonterminalKind::TT => return Ok(NtOrTt::Tt(self.parse_token_tree())),
113+
NonterminalKind::TT => return Ok(ParseNtResult::Tt(self.parse_token_tree())),
114114
NonterminalKind::Item => match self.parse_item(ForceCollect::Yes)? {
115115
Some(item) => NtItem(item),
116116
None => {
@@ -197,7 +197,7 @@ impl<'a> Parser<'a> {
197197
);
198198
}
199199

200-
Ok(NtOrTt::Nt(nt))
200+
Ok(ParseNtResult::Nt(nt))
201201
}
202202
}
203203

0 commit comments

Comments
 (0)