Skip to content

Commit 937b0a0

Browse files
authored
Rollup merge of #96027 - matthiaskrgr:clippy_rec, r=fee1-dead
remove function parameters only used in recursion
2 parents ba9c3a1 + 6511976 commit 937b0a0

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ use crate::mbe::{KleeneOp, TokenTree};
7777

7878
use rustc_ast::token::{self, DocComment, Nonterminal, NonterminalKind, Token};
7979
use rustc_parse::parser::{NtOrTt, Parser};
80-
use rustc_session::parse::ParseSess;
8180
use rustc_span::symbol::MacroRulesNormalizedIdent;
8281
use rustc_span::Span;
8382

@@ -128,9 +127,8 @@ pub(super) enum MatcherLoc {
128127
Eof,
129128
}
130129

131-
pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<MatcherLoc> {
130+
pub(super) fn compute_locs(matcher: &[TokenTree]) -> Vec<MatcherLoc> {
132131
fn inner(
133-
sess: &ParseSess,
134132
tts: &[TokenTree],
135133
locs: &mut Vec<MatcherLoc>,
136134
next_metavar: &mut usize,
@@ -147,7 +145,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
147145

148146
locs.push(MatcherLoc::Delimited);
149147
locs.push(MatcherLoc::Token { token: open_token });
150-
inner(sess, &delimited.tts, locs, next_metavar, seq_depth);
148+
inner(&delimited.tts, locs, next_metavar, seq_depth);
151149
locs.push(MatcherLoc::Token { token: close_token });
152150
}
153151
TokenTree::Sequence(_, seq) => {
@@ -162,7 +160,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
162160
let op = seq.kleene.op;
163161
let idx_first = locs.len();
164162
let idx_seq = idx_first - 1;
165-
inner(sess, &seq.tts, locs, next_metavar, seq_depth + 1);
163+
inner(&seq.tts, locs, next_metavar, seq_depth + 1);
166164

167165
if let Some(separator) = &seq.separator {
168166
locs.push(MatcherLoc::SequenceSep { separator: separator.clone() });
@@ -197,7 +195,7 @@ pub(super) fn compute_locs(sess: &ParseSess, matcher: &[TokenTree]) -> Vec<Match
197195

198196
let mut locs = vec![];
199197
let mut next_metavar = 0;
200-
inner(sess, matcher, &mut locs, &mut next_metavar, /* seq_depth */ 0);
198+
inner(matcher, &mut locs, &mut next_metavar, /* seq_depth */ 0);
201199

202200
// A final entry is needed for eof.
203201
locs.push(MatcherLoc::Eof);

compiler/rustc_expand/src/mbe/macro_rules.rs

+9-21
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub fn compile_declarative_macro(
435435
),
436436
];
437437
// Convert it into `MatcherLoc` form.
438-
let argument_gram = mbe::macro_parser::compute_locs(&sess.parse_sess, &argument_gram);
438+
let argument_gram = mbe::macro_parser::compute_locs(&argument_gram);
439439

440440
let parser = Parser::new(&sess.parse_sess, body, true, rustc_parse::MACRO_ARGUMENTS);
441441
let mut tt_parser =
@@ -478,7 +478,7 @@ pub fn compile_declarative_macro(
478478
)
479479
.pop()
480480
.unwrap();
481-
valid &= check_lhs_nt_follows(&sess.parse_sess, features, &def, &tt);
481+
valid &= check_lhs_nt_follows(&sess.parse_sess, &def, &tt);
482482
return tt;
483483
}
484484
sess.parse_sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs")
@@ -540,7 +540,7 @@ pub fn compile_declarative_macro(
540540
// Ignore the delimiters around the matcher.
541541
match lhs {
542542
mbe::TokenTree::Delimited(_, delimited) => {
543-
mbe::macro_parser::compute_locs(&sess.parse_sess, &delimited.tts)
543+
mbe::macro_parser::compute_locs(&delimited.tts)
544544
}
545545
_ => sess.parse_sess.span_diagnostic.span_bug(def.span, "malformed macro lhs"),
546546
}
@@ -563,16 +563,11 @@ pub fn compile_declarative_macro(
563563
}))
564564
}
565565

566-
fn check_lhs_nt_follows(
567-
sess: &ParseSess,
568-
features: &Features,
569-
def: &ast::Item,
570-
lhs: &mbe::TokenTree,
571-
) -> bool {
566+
fn check_lhs_nt_follows(sess: &ParseSess, def: &ast::Item, lhs: &mbe::TokenTree) -> bool {
572567
// lhs is going to be like TokenTree::Delimited(...), where the
573568
// entire lhs is those tts. Or, it can be a "bare sequence", not wrapped in parens.
574569
if let mbe::TokenTree::Delimited(_, delimited) = lhs {
575-
check_matcher(sess, features, def, &delimited.tts)
570+
check_matcher(sess, def, &delimited.tts)
576571
} else {
577572
let msg = "invalid macro matcher; matchers must be contained in balanced delimiters";
578573
sess.span_diagnostic.span_err(lhs.span(), msg);
@@ -632,16 +627,11 @@ fn check_rhs(sess: &ParseSess, rhs: &mbe::TokenTree) -> bool {
632627
false
633628
}
634629

635-
fn check_matcher(
636-
sess: &ParseSess,
637-
features: &Features,
638-
def: &ast::Item,
639-
matcher: &[mbe::TokenTree],
640-
) -> bool {
630+
fn check_matcher(sess: &ParseSess, def: &ast::Item, matcher: &[mbe::TokenTree]) -> bool {
641631
let first_sets = FirstSets::new(matcher);
642632
let empty_suffix = TokenSet::empty();
643633
let err = sess.span_diagnostic.err_count();
644-
check_matcher_core(sess, features, def, &first_sets, matcher, &empty_suffix);
634+
check_matcher_core(sess, def, &first_sets, matcher, &empty_suffix);
645635
err == sess.span_diagnostic.err_count()
646636
}
647637

@@ -955,7 +945,6 @@ impl<'tt> TokenSet<'tt> {
955945
// see `FirstSets::new`.
956946
fn check_matcher_core<'tt>(
957947
sess: &ParseSess,
958-
features: &Features,
959948
def: &ast::Item,
960949
first_sets: &FirstSets<'tt>,
961950
matcher: &'tt [mbe::TokenTree],
@@ -1008,7 +997,7 @@ fn check_matcher_core<'tt>(
1008997
token::CloseDelim(d.delim),
1009998
span.close,
1010999
));
1011-
check_matcher_core(sess, features, def, first_sets, &d.tts, &my_suffix);
1000+
check_matcher_core(sess, def, first_sets, &d.tts, &my_suffix);
10121001
// don't track non NT tokens
10131002
last.replace_with_irrelevant();
10141003

@@ -1040,8 +1029,7 @@ fn check_matcher_core<'tt>(
10401029
// At this point, `suffix_first` is built, and
10411030
// `my_suffix` is some TokenSet that we can use
10421031
// for checking the interior of `seq_rep`.
1043-
let next =
1044-
check_matcher_core(sess, features, def, first_sets, &seq_rep.tts, my_suffix);
1032+
let next = check_matcher_core(sess, def, first_sets, &seq_rep.tts, my_suffix);
10451033
if next.maybe_empty {
10461034
last.add_all(&next);
10471035
} else {

compiler/rustc_passes/src/dead.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
158158
#[allow(dead_code)] // FIXME(81658): should be used + lint reinstated after #83171 relands.
159159
fn check_for_self_assign(&mut self, assign: &'tcx hir::Expr<'tcx>) {
160160
fn check_for_self_assign_helper<'tcx>(
161-
tcx: TyCtxt<'tcx>,
162161
typeck_results: &'tcx ty::TypeckResults<'tcx>,
163162
lhs: &'tcx hir::Expr<'tcx>,
164163
rhs: &'tcx hir::Expr<'tcx>,
@@ -177,7 +176,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
177176
}
178177
(hir::ExprKind::Field(lhs_l, ident_l), hir::ExprKind::Field(lhs_r, ident_r)) => {
179178
if ident_l == ident_r {
180-
return check_for_self_assign_helper(tcx, typeck_results, lhs_l, lhs_r);
179+
return check_for_self_assign_helper(typeck_results, lhs_l, lhs_r);
181180
}
182181
return false;
183182
}
@@ -188,7 +187,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
188187
}
189188

190189
if let hir::ExprKind::Assign(lhs, rhs, _) = assign.kind {
191-
if check_for_self_assign_helper(self.tcx, self.typeck_results(), lhs, rhs)
190+
if check_for_self_assign_helper(self.typeck_results(), lhs, rhs)
192191
&& !assign.span.from_expansion()
193192
{
194193
let is_field_assign = matches!(lhs.kind, hir::ExprKind::Field(..));

0 commit comments

Comments
 (0)