mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
remove reudndant function param in check_matcher_core()
This commit is contained in:
parent
75287dd73d
commit
15abc81967
@ -478,7 +478,7 @@ pub fn compile_declarative_macro(
|
|||||||
)
|
)
|
||||||
.pop()
|
.pop()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
valid &= check_lhs_nt_follows(&sess.parse_sess, features, &def, &tt);
|
valid &= check_lhs_nt_follows(&sess.parse_sess, &def, &tt);
|
||||||
return tt;
|
return tt;
|
||||||
}
|
}
|
||||||
sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs")
|
sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs")
|
||||||
@ -563,16 +563,11 @@ pub fn compile_declarative_macro(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_lhs_nt_follows(
|
fn check_lhs_nt_follows(sess: &ParseSess, def: &ast::Item, lhs: &mbe::TokenTree) -> bool {
|
||||||
sess: &ParseSess,
|
|
||||||
features: &Features,
|
|
||||||
def: &ast::Item,
|
|
||||||
lhs: &mbe::TokenTree,
|
|
||||||
) -> bool {
|
|
||||||
// lhs is going to be like TokenTree::Delimited(...), where the
|
// lhs is going to be like TokenTree::Delimited(...), where the
|
||||||
// entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens.
|
// entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens.
|
||||||
if let mbe::TokenTree::Delimited(_, delimited) = lhs {
|
if let mbe::TokenTree::Delimited(_, delimited) = lhs {
|
||||||
check_matcher(sess, features, def, &delimited.tts)
|
check_matcher(sess, def, &delimited.tts)
|
||||||
} else {
|
} else {
|
||||||
let msg = "invalid macro matcher; matchers must be contained in balanced delimiters";
|
let msg = "invalid macro matcher; matchers must be contained in balanced delimiters";
|
||||||
sess.span_diagnostic.span_err(lhs.span(), msg);
|
sess.span_diagnostic.span_err(lhs.span(), msg);
|
||||||
@ -632,16 +627,11 @@ fn check_rhs(sess: &ParseSess, rhs: &mbe::TokenTree) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_matcher(
|
fn check_matcher(sess: &ParseSess, def: &ast::Item, matcher: &[mbe::TokenTree]) -> bool {
|
||||||
sess: &ParseSess,
|
|
||||||
features: &Features,
|
|
||||||
def: &ast::Item,
|
|
||||||
matcher: &[mbe::TokenTree],
|
|
||||||
) -> bool {
|
|
||||||
let first_sets = FirstSets::new(matcher);
|
let first_sets = FirstSets::new(matcher);
|
||||||
let empty_suffix = TokenSet::empty();
|
let empty_suffix = TokenSet::empty();
|
||||||
let err = sess.span_diagnostic.err_count();
|
let err = sess.span_diagnostic.err_count();
|
||||||
check_matcher_core(sess, features, def, &first_sets, matcher, &empty_suffix);
|
check_matcher_core(sess, def, &first_sets, matcher, &empty_suffix);
|
||||||
err == sess.span_diagnostic.err_count()
|
err == sess.span_diagnostic.err_count()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,7 +945,6 @@ impl<'tt> TokenSet<'tt> {
|
|||||||
// see `FirstSets::new`.
|
// see `FirstSets::new`.
|
||||||
fn check_matcher_core<'tt>(
|
fn check_matcher_core<'tt>(
|
||||||
sess: &ParseSess,
|
sess: &ParseSess,
|
||||||
features: &Features,
|
|
||||||
def: &ast::Item,
|
def: &ast::Item,
|
||||||
first_sets: &FirstSets<'tt>,
|
first_sets: &FirstSets<'tt>,
|
||||||
matcher: &'tt [mbe::TokenTree],
|
matcher: &'tt [mbe::TokenTree],
|
||||||
@ -1008,7 +997,7 @@ fn check_matcher_core<'tt>(
|
|||||||
token::CloseDelim(d.delim),
|
token::CloseDelim(d.delim),
|
||||||
span.close,
|
span.close,
|
||||||
));
|
));
|
||||||
check_matcher_core(sess, features, def, first_sets, &d.tts, &my_suffix);
|
check_matcher_core(sess, def, first_sets, &d.tts, &my_suffix);
|
||||||
// don't track non NT tokens
|
// don't track non NT tokens
|
||||||
last.replace_with_irrelevant();
|
last.replace_with_irrelevant();
|
||||||
|
|
||||||
@ -1040,8 +1029,7 @@ fn check_matcher_core<'tt>(
|
|||||||
// At this point, `suffix_first` is built, and
|
// At this point, `suffix_first` is built, and
|
||||||
// `my_suffix` is some TokenSet that we can use
|
// `my_suffix` is some TokenSet that we can use
|
||||||
// for checking the interior of `seq_rep`.
|
// for checking the interior of `seq_rep`.
|
||||||
let next =
|
let next = check_matcher_core(sess, def, first_sets, &seq_rep.tts, my_suffix);
|
||||||
check_matcher_core(sess, features, def, first_sets, &seq_rep.tts, my_suffix);
|
|
||||||
if next.maybe_empty {
|
if next.maybe_empty {
|
||||||
last.add_all(&next);
|
last.add_all(&next);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user