Skip to content

Commit a92fd7f

Browse files
committed
remove a bunch of dead parameters in fn
1 parent 42752cb commit a92fd7f

File tree

26 files changed

+61
-134
lines changed

26 files changed

+61
-134
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
30203020
/// assignment to `x.f`).
30213021
pub(crate) fn report_illegal_reassignment(
30223022
&mut self,
3023-
_location: Location,
30243023
(place, span): (Place<'tcx>, Span),
30253024
assigned_span: Span,
30263025
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_codegen_gcc/src/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
185185
Cow::Owned(casted_args)
186186
}
187187

188-
fn check_ptr_call<'b>(&mut self, _typ: &str, func_ptr: RValue<'gcc>, args: &'b [RValue<'gcc>]) -> Cow<'b, [RValue<'gcc>]> {
188+
fn check_ptr_call<'b>(&mut self, func_ptr: RValue<'gcc>, args: &'b [RValue<'gcc>]) -> Cow<'b, [RValue<'gcc>]> {
189189
let mut all_args_match = true;
190190
let mut param_types = vec![];
191191
let gcc_func = func_ptr.get_type().dyncast_function_ptr_type().expect("function ptr");
@@ -256,7 +256,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
256256
self.block.get_function()
257257
}
258258

259-
fn function_call(&mut self, func: RValue<'gcc>, args: &[RValue<'gcc>], _funclet: Option<&Funclet>) -> RValue<'gcc> {
259+
fn function_call(&mut self, func: RValue<'gcc>, args: &[RValue<'gcc>]) -> RValue<'gcc> {
260260
// TODO(antoyo): remove when the API supports a different type for functions.
261261
let func: Function<'gcc> = self.cx.rvalue_as_function(func);
262262
let args = self.check_call("call", func, args);
@@ -299,7 +299,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
299299
llvm::adjust_intrinsic_arguments(&self, gcc_func, args.into(), &func_name, original_function_name)
300300
};
301301
let args_adjusted = args.len() != previous_arg_count;
302-
let args = self.check_ptr_call("call", func_ptr, &*args);
302+
let args = self.check_ptr_call(func_ptr, &*args);
303303

304304
// gccjit requires to use the result of functions, even when it's not used.
305305
// That's why we assign the result to a local or call add_eval().
@@ -333,7 +333,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
333333
}
334334
}
335335

336-
pub fn overflow_call(&self, func: Function<'gcc>, args: &[RValue<'gcc>], _funclet: Option<&Funclet>) -> RValue<'gcc> {
336+
pub fn overflow_call(&self, func: Function<'gcc>, args: &[RValue<'gcc>]) -> RValue<'gcc> {
337337
// gccjit requires to use the result of functions, even when it's not used.
338338
// That's why we assign the result to a local.
339339
let return_type = self.context.new_type::<bool>();
@@ -1386,7 +1386,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
13861386
// FIXME(antoyo): remove when having a proper API.
13871387
let gcc_func = unsafe { std::mem::transmute(func) };
13881388
let call = if self.functions.borrow().values().any(|value| *value == gcc_func) {
1389-
self.function_call(func, args, funclet)
1389+
self.function_call(func, args)
13901390
}
13911391
else {
13921392
// If it's a not function that was defined, it's a function pointer.

compiler/rustc_codegen_gcc/src/int.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
337337
// TODO(antoyo): is it correct to use rhs type instead of the parameter typ?
338338
.new_local(None, rhs.get_type(), "binopResult")
339339
.get_address(None);
340-
let overflow = self.overflow_call(intrinsic, &[lhs, rhs, res], None);
340+
let overflow = self.overflow_call(intrinsic, &[lhs, rhs, res]);
341341
(res.dereference(None).to_rvalue(), overflow)
342342
}
343343

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
934934
_ => unreachable!(),
935935
};
936936
let overflow_func = self.context.get_builtin_function(func_name);
937-
self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(None)], None)
937+
self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(None)])
938938
}
939939
else {
940940
let func_name =
@@ -996,7 +996,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
996996
_ => unreachable!(),
997997
};
998998
let overflow_func = self.context.get_builtin_function(func_name);
999-
self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(None)], None)
999+
self.overflow_call(overflow_func, &[lhs, rhs, res.get_address(None)])
10001000
}
10011001
else {
10021002
let func_name =

compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2542,7 +2542,7 @@ fn add_native_libs_from_crate(
25422542
}
25432543
NativeLibKind::Framework { as_needed } => {
25442544
if link_dynamic {
2545-
cmd.link_framework_by_name(name, verbatim, as_needed.unwrap_or(true))
2545+
cmd.link_framework_by_name(name, as_needed.unwrap_or(true))
25462546
}
25472547
}
25482548
NativeLibKind::RawDylib => {

compiler/rustc_codegen_ssa/src/back/linker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub trait Linker {
168168
fn cmd(&mut self) -> &mut Command;
169169
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path);
170170
fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, as_needed: bool);
171-
fn link_framework_by_name(&mut self, _name: &str, _verbatim: bool, _as_needed: bool) {
171+
fn link_framework_by_name(&mut self, _name: &str, _as_needed: bool) {
172172
bug!("framework linked with unsupported linker")
173173
}
174174
fn link_staticlib_by_name(
@@ -470,7 +470,7 @@ impl<'a> Linker for GccLinker<'a> {
470470
}
471471
}
472472

473-
fn link_framework_by_name(&mut self, name: &str, _verbatim: bool, as_needed: bool) {
473+
fn link_framework_by_name(&mut self, name: &str, as_needed: bool) {
474474
self.hint_dynamic();
475475
if !as_needed {
476476
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework

compiler/rustc_const_eval/src/interpret/validity.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
//! That's useful because it means other passes (e.g. promotion) can rely on `const`s
55
//! to be const-safe.
66
7-
use std::fmt::Write;
8-
use std::num::NonZeroUsize;
9-
107
use either::{Left, Right};
8+
use std::fmt::Write;
119

1210
use hir::def::DefKind;
1311
use rustc_ast::Mutability;
@@ -777,11 +775,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
777775
}
778776

779777
#[inline(always)]
780-
fn visit_union(
781-
&mut self,
782-
op: &OpTy<'tcx, M::Provenance>,
783-
_fields: NonZeroUsize,
784-
) -> InterpResult<'tcx> {
778+
fn visit_union(&mut self, op: &OpTy<'tcx, M::Provenance>) -> InterpResult<'tcx> {
785779
// Special check for CTFE validation, preventing `UnsafeCell` inside unions in immutable memory.
786780
if self.ctfe_mode.is_some_and(|c| !c.allow_immutable_unsafe_cell()) {
787781
if !op.layout.is_zst() && !op.layout.ty.is_freeze(*self.ecx.tcx, self.ecx.param_env) {

compiler/rustc_const_eval/src/interpret/visitor.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
//! Visitor for a run-time value with a given layout: Traverse enums, structs and other compound
22
//! types until we arrive at the leaves, with custom handling for primitive types.
33
4+
use super::{InterpCx, MPlaceTy, Machine, Projectable};
45
use rustc_index::IndexVec;
56
use rustc_middle::mir::interpret::InterpResult;
67
use rustc_middle::ty;
78
use rustc_target::abi::FieldIdx;
89
use rustc_target::abi::{FieldsShape, VariantIdx, Variants};
910

10-
use std::num::NonZeroUsize;
11-
12-
use super::{InterpCx, MPlaceTy, Machine, Projectable};
13-
1411
/// How to traverse a value and what to do when we are at the leaves.
1512
pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
1613
type V: Projectable<'tcx, M::Provenance> + From<MPlaceTy<'tcx, M::Provenance>>;
@@ -43,7 +40,7 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
4340
}
4441
/// Visits the given value as a union. No automatic recursion can happen here.
4542
#[inline(always)]
46-
fn visit_union(&mut self, _v: &Self::V, _fields: NonZeroUsize) -> InterpResult<'tcx> {
43+
fn visit_union(&mut self, _v: &Self::V) -> InterpResult<'tcx> {
4744
Ok(())
4845
}
4946
/// Visits the given value as the pointer of a `Box`. There is nothing to recurse into.
@@ -159,8 +156,8 @@ pub trait ValueVisitor<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>: Sized {
159156
// Visit the fields of this value.
160157
match &v.layout().fields {
161158
FieldsShape::Primitive => {}
162-
&FieldsShape::Union(fields) => {
163-
self.visit_union(v, fields)?;
159+
&FieldsShape::Union(_fields) => {
160+
self.visit_union(v)?;
164161
}
165162
FieldsShape::Arbitrary { offsets, memory_index } => {
166163
for idx in 0..offsets.len() {

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
}
@@ -1493,7 +1493,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14931493
&self,
14941494
block: &'tcx hir::ConstBlock,
14951495
expected: Expectation<'tcx>,
1496-
_expr: &'tcx hir::Expr<'tcx>,
14971496
) -> Ty<'tcx> {
14981497
let body = self.tcx.hir().body(block.body);
14991498

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

0 commit comments

Comments
 (0)