mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-22 12:43:36 +00:00
remove function param that is only used in recursive of fn inner()
This commit is contained in:
parent
f9d4d12b6a
commit
75287dd73d
@ -77,7 +77,6 @@ use crate::mbe::{KleeneOp, TokenTree};
|
||||
|
||||
use rustc_ast::token::{self, DocComment, Nonterminal, NonterminalKind, Token};
|
||||
use rustc_parse::parser::{NtOrTt, Parser};
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::symbol::MacroRulesNormalizedIdent;
|
||||
use rustc_span::Span;
|
||||
|
||||
@ -128,9 +127,8 @@ pub(super) enum MatcherLoc {
|
||||
Eof,
|
||||
}
|
||||
|
||||
pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<MatcherLoc> {
|
||||
pub(super) fn compute_locs(matcher: &[TokenTree]) -> Vec<MatcherLoc> {
|
||||
fn inner(
|
||||
sess: &ParseSess,
|
||||
tts: &[TokenTree],
|
||||
locs: &mut Vec<MatcherLoc>,
|
||||
next_metavar: &mut usize,
|
||||
@ -147,7 +145,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
|
||||
|
||||
locs.push(MatcherLoc::Delimited);
|
||||
locs.push(MatcherLoc::Token { token: open_token });
|
||||
inner(sess, &delimited.tts, locs, next_metavar, seq_depth);
|
||||
inner(&delimited.tts, locs, next_metavar, seq_depth);
|
||||
locs.push(MatcherLoc::Token { token: close_token });
|
||||
}
|
||||
TokenTree::Sequence(_, seq) => {
|
||||
@ -162,7 +160,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
|
||||
let op = seq.kleene.op;
|
||||
let idx_first = locs.len();
|
||||
let idx_seq = idx_first - 1;
|
||||
inner(sess, &seq.tts, locs, next_metavar, seq_depth + 1);
|
||||
inner(&seq.tts, locs, next_metavar, seq_depth + 1);
|
||||
|
||||
if let Some(separator) = &seq.separator {
|
||||
locs.push(MatcherLoc::SequenceSep { separator: separator.clone() });
|
||||
@ -197,7 +195,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
|
||||
|
||||
let mut locs = vec![];
|
||||
let mut next_metavar = 0;
|
||||
inner(sess, matcher, &mut locs, &mut next_metavar, /* seq_depth */ 0);
|
||||
inner(matcher, &mut locs, &mut next_metavar, /* seq_depth */ 0);
|
||||
|
||||
// A final entry is needed for eof.
|
||||
locs.push(MatcherLoc::Eof);
|
||||
|
@ -435,7 +435,7 @@ pub fn compile_declarative_macro(
|
||||
),
|
||||
];
|
||||
// Convert it into `MatcherLoc` form.
|
||||
let argument_gram = mbe::macro_parser::compute_locs(&sess.parse_sess, &argument_gram);
|
||||
let argument_gram = mbe::macro_parser::compute_locs(&argument_gram);
|
||||
|
||||
let parser = Parser::new(&sess.parse_sess, body, true, rustc_parse::MACRO_ARGUMENTS);
|
||||
let mut tt_parser =
|
||||
@ -540,7 +540,7 @@ pub fn compile_declarative_macro(
|
||||
// Ignore the delimiters around the matcher.
|
||||
match lhs {
|
||||
mbe::TokenTree::Delimited(_, delimited) => {
|
||||
mbe::macro_parser::compute_locs(&sess.parse_sess, &delimited.tts)
|
||||
mbe::macro_parser::compute_locs(&delimited.tts)
|
||||
}
|
||||
_ => sess.parse_sess.span_diagnostic.span_bug(def.span, "malformed macro lhs"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user