Skip to content

Commit 5e35a22

Browse files
authored
Unrolled build for rust-lang#120917
Rollup merge of rust-lang#120917 - chenyukang:yukang-dead-parameters, r=compiler-errors Remove a bunch of dead parameters in functions Found this kind of issue when working on rust-lang#119650 I wrote a trivial toy lint and manual review to find these.
2 parents bdc1592 + 2bcbc16 commit 5e35a22

File tree

16 files changed

+30
-71
lines changed

16 files changed

+30
-71
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
30183018
/// assignment to `x.f`).
30193019
pub(crate) fn report_illegal_reassignment(
30203020
&mut self,
3021-
_location: Location,
30223021
(place, span): (Place<'tcx>, Span),
30233022
assigned_span: Span,
30243023
err_place: Place<'tcx>,

compiler/rustc_borrowck/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10361036
self,
10371037
self.infcx.tcx,
10381038
self.body,
1039-
location,
10401039
(sd, place_span.0),
10411040
&borrow_set,
10421041
|borrow_index| borrows_in_scope.contains(borrow_index),
@@ -2174,7 +2173,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21742173
// report the error as an illegal reassignment
21752174
let init = &self.move_data.inits[init_index];
21762175
let assigned_span = init.span(self.body);
2177-
self.report_illegal_reassignment(location, (place, span), assigned_span, place);
2176+
self.report_illegal_reassignment((place, span), assigned_span, place);
21782177
} else {
21792178
self.report_mutability_error(place, span, the_place_err, error_access, location)
21802179
}

compiler/rustc_borrowck/src/path_utils.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub(super) fn each_borrow_involving_path<'tcx, F, I, S>(
2727
s: &mut S,
2828
tcx: TyCtxt<'tcx>,
2929
body: &Body<'tcx>,
30-
_location: Location,
3130
access_place: (AccessDepth, Place<'tcx>),
3231
borrow_set: &BorrowSet<'tcx>,
3332
is_candidate: I,

compiler/rustc_borrowck/src/polonius/loan_invalidations.rs

-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ impl<'cx, 'tcx> LoanInvalidationsGenerator<'cx, 'tcx> {
340340
self,
341341
self.tcx,
342342
self.body,
343-
location,
344343
(sd, place),
345344
self.borrow_set,
346345
|_| true,

compiler/rustc_borrowck/src/region_infer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
662662
polonius_output: Option<Rc<PoloniusOutput>>,
663663
) -> (Option<ClosureRegionRequirements<'tcx>>, RegionErrors<'tcx>) {
664664
let mir_def_id = body.source.def_id();
665-
self.propagate_constraints(body);
665+
self.propagate_constraints();
666666

667667
let mut errors_buffer = RegionErrors::new(infcx.tcx);
668668

@@ -716,8 +716,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
716716
/// for each region variable until all the constraints are
717717
/// satisfied. Note that some values may grow **too** large to be
718718
/// feasible, but we check this later.
719-
#[instrument(skip(self, _body), level = "debug")]
720-
fn propagate_constraints(&mut self, _body: &Body<'tcx>) {
719+
#[instrument(skip(self), level = "debug")]
720+
fn propagate_constraints(&mut self) {
721721
debug!("constraints={:#?}", {
722722
let mut constraints: Vec<_> = self.outlives_constraints().collect();
723723
constraints.sort_by_key(|c| (c.sup, c.sub));

compiler/rustc_const_eval/src/transform/check_consts/resolver.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ where
9696
});
9797
}
9898

99-
fn address_of_allows_mutation(&self, _mt: mir::Mutability, _place: mir::Place<'tcx>) -> bool {
99+
fn address_of_allows_mutation(&self) -> bool {
100100
// Exact set of permissions granted by AddressOf is undecided. Conservatively assume that
101101
// it might allow mutation until resolution of #56604.
102102
true
@@ -171,10 +171,8 @@ where
171171
self.super_rvalue(rvalue, location);
172172

173173
match rvalue {
174-
mir::Rvalue::AddressOf(mt, borrowed_place) => {
175-
if !borrowed_place.is_indirect()
176-
&& self.address_of_allows_mutation(*mt, *borrowed_place)
177-
{
174+
mir::Rvalue::AddressOf(_mt, borrowed_place) => {
175+
if !borrowed_place.is_indirect() && self.address_of_allows_mutation() {
178176
let place_ty = borrowed_place.ty(self.ccx.body, self.ccx.tcx).ty;
179177
if Q::in_any_value_of_ty(self.ccx, place_ty) {
180178
self.state.qualif.insert(borrowed_place.local);

compiler/rustc_hir_analysis/src/check/region.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_index::Idx;
1616
use rustc_middle::middle::region::*;
1717
use rustc_middle::ty::TyCtxt;
1818
use rustc_span::source_map;
19-
use rustc_span::Span;
2019

2120
use super::errs::{maybe_expr_static_mut, maybe_stmt_static_mut};
2221

@@ -72,11 +71,7 @@ struct RegionResolutionVisitor<'tcx> {
7271
}
7372

7473
/// Records the lifetime of a local variable as `cx.var_parent`
75-
fn record_var_lifetime(
76-
visitor: &mut RegionResolutionVisitor<'_>,
77-
var_id: hir::ItemLocalId,
78-
_sp: Span,
79-
) {
74+
fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_>, var_id: hir::ItemLocalId) {
8075
match visitor.cx.var_parent {
8176
None => {
8277
// this can happen in extern fn declarations like
@@ -210,7 +205,7 @@ fn resolve_pat<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, pat: &'tcx hir
210205

211206
// If this is a binding then record the lifetime of that binding.
212207
if let PatKind::Binding(..) = pat.kind {
213-
record_var_lifetime(visitor, pat.hir_id.local_id, pat.span);
208+
record_var_lifetime(visitor, pat.hir_id.local_id);
214209
}
215210

216211
debug!("resolve_pat - pre-increment {} pat = {:?}", visitor.expr_and_pat_count, pat);

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,7 @@ fn check_predicates<'tcx>(
425425

426426
let mut res = Ok(());
427427
for (clause, span) in impl1_predicates {
428-
if !impl2_predicates
429-
.iter()
430-
.any(|pred2| trait_predicates_eq(tcx, clause.as_predicate(), *pred2, span))
428+
if !impl2_predicates.iter().any(|pred2| trait_predicates_eq(clause.as_predicate(), *pred2))
431429
{
432430
res = res.and(check_specialization_on(tcx, clause, span))
433431
}
@@ -459,10 +457,8 @@ fn check_predicates<'tcx>(
459457
///
460458
/// So we make that check in this function and try to raise a helpful error message.
461459
fn trait_predicates_eq<'tcx>(
462-
_tcx: TyCtxt<'tcx>,
463460
predicate1: ty::Predicate<'tcx>,
464461
predicate2: ty::Predicate<'tcx>,
465-
_span: Span,
466462
) -> bool {
467463
// FIXME(effects)
468464
predicate1 == predicate2

compiler/rustc_hir_typeck/src/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
346346
}
347347
ExprKind::DropTemps(e) => self.check_expr_with_expectation(e, expected),
348348
ExprKind::Array(args) => self.check_expr_array(args, expected, expr),
349-
ExprKind::ConstBlock(ref block) => self.check_expr_const_block(block, expected, expr),
349+
ExprKind::ConstBlock(ref block) => self.check_expr_const_block(block, expected),
350350
ExprKind::Repeat(element, ref count) => {
351351
self.check_expr_repeat(element, count, expected, expr)
352352
}
@@ -1487,7 +1487,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14871487
&self,
14881488
block: &'tcx hir::ConstBlock,
14891489
expected: Expectation<'tcx>,
1490-
_expr: &'tcx hir::Expr<'tcx>,
14911490
) -> Ty<'tcx> {
14921491
let body = self.tcx.hir().body(block.body);
14931492

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
142142
let param_ty = return_if_err!(self.mc.pat_ty_adjusted(param.pat));
143143
debug!("consume_body: param_ty = {:?}", param_ty);
144144

145-
let param_place = self.mc.cat_rvalue(param.hir_id, param.pat.span, param_ty);
145+
let param_place = self.mc.cat_rvalue(param.hir_id, param_ty);
146146

147147
self.walk_irrefutable_pat(&param_place, param.pat);
148148
}

compiler/rustc_hir_typeck/src/mem_categorization.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
273273
deref.region,
274274
ty::TypeAndMut { ty: target, mutbl: deref.mutbl },
275275
);
276-
self.cat_rvalue(expr.hir_id, expr.span, ref_ty)
276+
self.cat_rvalue(expr.hir_id, ref_ty)
277277
} else {
278278
previous()?
279279
};
@@ -285,7 +285,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
285285
| adjustment::Adjust::Borrow(_)
286286
| adjustment::Adjust::DynStar => {
287287
// Result is an rvalue.
288-
Ok(self.cat_rvalue(expr.hir_id, expr.span, target))
288+
Ok(self.cat_rvalue(expr.hir_id, target))
289289
}
290290
}
291291
}
@@ -374,7 +374,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
374374
| hir::ExprKind::Repeat(..)
375375
| hir::ExprKind::InlineAsm(..)
376376
| hir::ExprKind::OffsetOf(..)
377-
| hir::ExprKind::Err(_) => Ok(self.cat_rvalue(expr.hir_id, expr.span, expr_ty)),
377+
| hir::ExprKind::Err(_) => Ok(self.cat_rvalue(expr.hir_id, expr_ty)),
378378
}
379379
}
380380

@@ -396,7 +396,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
396396
| DefKind::AssocFn,
397397
_,
398398
)
399-
| Res::SelfCtor(..) => Ok(self.cat_rvalue(hir_id, span, expr_ty)),
399+
| Res::SelfCtor(..) => Ok(self.cat_rvalue(hir_id, expr_ty)),
400400

401401
Res::Def(DefKind::Static(_), _) => {
402402
Ok(PlaceWithHirId::new(hir_id, expr_ty, PlaceBase::StaticItem, Vec::new()))
@@ -433,13 +433,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
433433
}
434434

435435
#[instrument(level = "debug", skip(self), ret)]
436-
pub(crate) fn cat_rvalue(
437-
&self,
438-
hir_id: hir::HirId,
439-
// FIXME: remove
440-
_span: Span,
441-
expr_ty: Ty<'tcx>,
442-
) -> PlaceWithHirId<'tcx> {
436+
pub(crate) fn cat_rvalue(&self, hir_id: hir::HirId, expr_ty: Ty<'tcx>) -> PlaceWithHirId<'tcx> {
443437
PlaceWithHirId::new(hir_id, expr_ty, PlaceBase::Rvalue, Vec::new())
444438
}
445439

@@ -487,7 +481,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
487481
};
488482
let ref_ty = Ty::new_ref(self.tcx(), region, ty::TypeAndMut { ty: place_ty, mutbl });
489483

490-
let base = self.cat_rvalue(expr.hir_id, expr.span, ref_ty);
484+
let base = self.cat_rvalue(expr.hir_id, ref_ty);
491485
self.cat_deref(expr, base)
492486
}
493487

compiler/rustc_mir_transform/src/coroutine.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ fn replace_resume_ty_local<'tcx>(
726726
/// The async lowering step and the type / lifetime inference / checking are
727727
/// still using the `resume` argument for the time being. After this transform,
728728
/// the coroutine body doesn't have the `resume` argument.
729-
fn transform_gen_context<'tcx>(_tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
729+
fn transform_gen_context<'tcx>(body: &mut Body<'tcx>) {
730730
// This leaves the local representing the `resume` argument in place,
731731
// but turns it into a regular local variable. This is cheaper than
732732
// adjusting all local references in the body after removing it.
@@ -1733,7 +1733,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
17331733

17341734
// Remove the context argument within generator bodies.
17351735
if matches!(coroutine_kind, CoroutineKind::Desugared(CoroutineDesugaring::Gen, _)) {
1736-
transform_gen_context(tcx, body);
1736+
transform_gen_context(body);
17371737
}
17381738

17391739
// The original arguments to the function are no longer arguments, mark them as such.

compiler/rustc_mir_transform/src/instsimplify.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@ impl<'tcx> MirPass<'tcx> for InstSimplify {
2929
ctx.simplify_bool_cmp(&statement.source_info, rvalue);
3030
ctx.simplify_ref_deref(&statement.source_info, rvalue);
3131
ctx.simplify_len(&statement.source_info, rvalue);
32-
ctx.simplify_cast(&statement.source_info, rvalue);
32+
ctx.simplify_cast(rvalue);
3333
}
3434
_ => {}
3535
}
3636
}
3737

3838
ctx.simplify_primitive_clone(block.terminator.as_mut().unwrap(), &mut block.statements);
39-
ctx.simplify_intrinsic_assert(
40-
block.terminator.as_mut().unwrap(),
41-
&mut block.statements,
42-
);
39+
ctx.simplify_intrinsic_assert(block.terminator.as_mut().unwrap());
4340
ctx.simplify_nounwind_call(block.terminator.as_mut().unwrap());
4441
simplify_duplicate_switch_targets(block.terminator.as_mut().unwrap());
4542
}
@@ -143,7 +140,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
143140
}
144141
}
145142

146-
fn simplify_cast(&self, _source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
143+
fn simplify_cast(&self, rvalue: &mut Rvalue<'tcx>) {
147144
if let Rvalue::Cast(kind, operand, cast_ty) = rvalue {
148145
let operand_ty = operand.ty(self.local_decls, self.tcx);
149146
if operand_ty == *cast_ty {
@@ -277,11 +274,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
277274
}
278275
}
279276

280-
fn simplify_intrinsic_assert(
281-
&self,
282-
terminator: &mut Terminator<'tcx>,
283-
_statements: &mut Vec<Statement<'tcx>>,
284-
) {
277+
fn simplify_intrinsic_assert(&self, terminator: &mut Terminator<'tcx>) {
285278
let TerminatorKind::Call { func, target, .. } = &mut terminator.kind else {
286279
return;
287280
};

compiler/rustc_passes/src/check_attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
197197
| sym::unstable
198198
| sym::stable
199199
| sym::rustc_allowed_through_unstable_modules
200-
| sym::rustc_promotable => self.check_stability_promotable(attr, span, target),
200+
| sym::rustc_promotable => self.check_stability_promotable(attr, target),
201201
sym::link_ordinal => self.check_link_ordinal(attr, span, target),
202202
sym::rustc_confusables => self.check_confusables(attr, target),
203203
sym::rustc_safe_intrinsic => {
@@ -2099,7 +2099,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
20992099
}
21002100
}
21012101

2102-
fn check_stability_promotable(&self, attr: &Attribute, _span: Span, target: Target) -> bool {
2102+
fn check_stability_promotable(&self, attr: &Attribute, target: Target) -> bool {
21032103
match target {
21042104
Target::Expression => {
21052105
self.dcx().emit_err(errors::StabilityPromotable { attr_span: attr.span });

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,7 @@ fn encode_predicates<'tcx>(
261261
}
262262

263263
/// Encodes a region using the Itanium C++ ABI as a vendor extended type.
264-
fn encode_region<'tcx>(
265-
_tcx: TyCtxt<'tcx>,
266-
region: Region<'tcx>,
267-
dict: &mut FxHashMap<DictKey<'tcx>, usize>,
268-
_options: EncodeTyOptions,
269-
) -> String {
264+
fn encode_region<'tcx>(region: Region<'tcx>, dict: &mut FxHashMap<DictKey<'tcx>, usize>) -> String {
270265
// u6region[I[<region-disambiguator>][<region-index>]E] as vendor extended type
271266
let mut s = String::new();
272267
match region.kind() {
@@ -314,7 +309,7 @@ fn encode_args<'tcx>(
314309
for arg in args {
315310
match arg.unpack() {
316311
GenericArgKind::Lifetime(region) => {
317-
s.push_str(&encode_region(tcx, region, dict, options));
312+
s.push_str(&encode_region(region, dict));
318313
}
319314
GenericArgKind::Type(ty) => {
320315
s.push_str(&encode_ty(tcx, ty, dict, options));
@@ -704,7 +699,7 @@ fn encode_ty<'tcx>(
704699
ty::DynStar => "u7dynstarI",
705700
});
706701
s.push_str(&encode_predicates(tcx, predicates, dict, options));
707-
s.push_str(&encode_region(tcx, *region, dict, options));
702+
s.push_str(&encode_region(*region, dict));
708703
s.push('E');
709704
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
710705
typeid.push_str(&s);
@@ -736,7 +731,6 @@ fn encode_ty<'tcx>(
736731
fn transform_predicates<'tcx>(
737732
tcx: TyCtxt<'tcx>,
738733
predicates: &List<ty::PolyExistentialPredicate<'tcx>>,
739-
_options: EncodeTyOptions,
740734
) -> &'tcx List<ty::PolyExistentialPredicate<'tcx>> {
741735
let predicates: Vec<ty::PolyExistentialPredicate<'tcx>> = predicates
742736
.iter()
@@ -968,7 +962,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
968962
ty::Dynamic(predicates, _region, kind) => {
969963
ty = Ty::new_dynamic(
970964
tcx,
971-
transform_predicates(tcx, predicates, options),
965+
transform_predicates(tcx, predicates),
972966
tcx.lifetimes.re_erased,
973967
*kind,
974968
);

compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs

-6
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
615615

616616
let UnsatisfiedConst(unsatisfied_const) = self
617617
.maybe_add_note_for_unsatisfied_const(
618-
&obligation,
619-
trait_ref,
620618
&trait_predicate,
621619
&mut err,
622620
span,
@@ -1480,8 +1478,6 @@ pub(super) trait InferCtxtPrivExt<'tcx> {
14801478

14811479
fn maybe_add_note_for_unsatisfied_const(
14821480
&self,
1483-
obligation: &PredicateObligation<'tcx>,
1484-
trait_ref: ty::PolyTraitRef<'tcx>,
14851481
trait_predicate: &ty::PolyTraitPredicate<'tcx>,
14861482
err: &mut Diagnostic,
14871483
span: Span,
@@ -3359,8 +3355,6 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
33593355

33603356
fn maybe_add_note_for_unsatisfied_const(
33613357
&self,
3362-
_obligation: &PredicateObligation<'tcx>,
3363-
_trait_ref: ty::PolyTraitRef<'tcx>,
33643358
_trait_predicate: &ty::PolyTraitPredicate<'tcx>,
33653359
_err: &mut Diagnostic,
33663360
_span: Span,

0 commit comments

Comments
 (0)