Skip to content

Commit 0635247

Browse files
authored
Rollup merge of rust-lang#120590 - compiler-errors:dead, r=Nilstrieb
Remove unused args from functions `#[instrument]` suppresses the unused arguments from a function, *and* suppresses unused methods too! This PR removes things which are only used via `#[instrument]` calls, and fixes some other errors (privacy?) that I will comment inline. It's possible that some of these arguments were being passed in for the purposes of being instrumented, but I am unconvinced by most of them.
2 parents 4f3d9e0 + 6b2a824 commit 0635247

File tree

22 files changed

+32
-124
lines changed

22 files changed

+32
-124
lines changed

compiler/rustc_borrowck/src/nll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
184184

185185
// Solve the region constraints.
186186
let (closure_region_requirements, nll_errors) =
187-
regioncx.solve(infcx, param_env, body, polonius_output.clone());
187+
regioncx.solve(infcx, body, polonius_output.clone());
188188

189189
if !nll_errors.is_empty() {
190190
// Suppress unhelpful extra errors in `infer_opaque_types`.

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
658658
pub(super) fn solve(
659659
&mut self,
660660
infcx: &InferCtxt<'tcx>,
661-
param_env: ty::ParamEnv<'tcx>,
662661
body: &Body<'tcx>,
663662
polonius_output: Option<Rc<PoloniusOutput>>,
664663
) -> (Option<ClosureRegionRequirements<'tcx>>, RegionErrors<'tcx>) {
@@ -674,7 +673,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
674673
// eagerly.
675674
let mut outlives_requirements = infcx.tcx.is_typeck_child(mir_def_id).then(Vec::new);
676675

677-
self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);
676+
self.check_type_tests(infcx, outlives_requirements.as_mut(), &mut errors_buffer);
678677

679678
debug!(?errors_buffer);
680679
debug!(?outlives_requirements);
@@ -932,7 +931,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
932931
fn check_type_tests(
933932
&self,
934933
infcx: &InferCtxt<'tcx>,
935-
body: &Body<'tcx>,
936934
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
937935
errors_buffer: &mut RegionErrors<'tcx>,
938936
) {
@@ -957,12 +955,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
957955
}
958956

959957
if let Some(propagated_outlives_requirements) = &mut propagated_outlives_requirements {
960-
if self.try_promote_type_test(
961-
infcx,
962-
body,
963-
type_test,
964-
propagated_outlives_requirements,
965-
) {
958+
if self.try_promote_type_test(infcx, type_test, propagated_outlives_requirements) {
966959
continue;
967960
}
968961
}
@@ -1016,7 +1009,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
10161009
fn try_promote_type_test(
10171010
&self,
10181011
infcx: &InferCtxt<'tcx>,
1019-
body: &Body<'tcx>,
10201012
type_test: &TypeTest<'tcx>,
10211013
propagated_outlives_requirements: &mut Vec<ClosureOutlivesRequirement<'tcx>>,
10221014
) -> bool {
@@ -1179,35 +1171,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11791171
Some(ClosureOutlivesSubject::Ty(ClosureOutlivesSubjectTy::bind(tcx, ty)))
11801172
}
11811173

1182-
/// Returns a universally quantified region that outlives the
1183-
/// value of `r` (`r` may be existentially or universally
1184-
/// quantified).
1185-
///
1186-
/// Since `r` is (potentially) an existential region, it has some
1187-
/// value which may include (a) any number of points in the CFG
1188-
/// and (b) any number of `end('x)` elements of universally
1189-
/// quantified regions. To convert this into a single universal
1190-
/// region we do as follows:
1191-
///
1192-
/// - Ignore the CFG points in `'r`. All universally quantified regions
1193-
/// include the CFG anyhow.
1194-
/// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding
1195-
/// a result `'y`.
1196-
#[instrument(skip(self), level = "debug", ret)]
1197-
pub(crate) fn universal_upper_bound(&self, r: RegionVid) -> RegionVid {
1198-
debug!(r = %self.region_value_str(r));
1199-
1200-
// Find the smallest universal region that contains all other
1201-
// universal regions within `region`.
1202-
let mut lub = self.universal_regions.fr_fn_body;
1203-
let r_scc = self.constraint_sccs.scc(r);
1204-
for ur in self.scc_values.universal_regions_outlived_by(r_scc) {
1205-
lub = self.universal_region_relations.postdom_upper_bound(lub, ur);
1206-
}
1207-
1208-
lub
1209-
}
1210-
12111174
/// Like `universal_upper_bound`, but returns an approximation more suitable
12121175
/// for diagnostics. If `r` contains multiple disjoint universal regions
12131176
/// (e.g. 'a and 'b in `fn foo<'a, 'b> { ... }`, we pick the lower-numbered region.

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ pub(crate) fn type_check<'mir, 'tcx>(
213213
CustomTypeOp::new(
214214
|ocx| {
215215
ocx.infcx.register_member_constraints(
216-
param_env,
217216
opaque_type_key,
218217
decl.hidden_type.ty,
219218
decl.hidden_type.span,

compiler/rustc_hir_analysis/src/astconv/bounds.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
243243
speculative: bool,
244244
dup_bindings: &mut FxHashMap<DefId, Span>,
245245
path_span: Span,
246-
constness: ty::BoundConstness,
247246
only_self_bounds: OnlySelfBounds,
248-
polarity: ty::ImplPolarity,
249247
) -> Result<(), ErrorGuaranteed> {
250248
// Given something like `U: SomeTrait<T = X>`, we want to produce a
251249
// predicate like `<U as SomeTrait>::T = X`. This is somewhat

compiler/rustc_hir_analysis/src/astconv/generics.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_middle::ty::{
1616
self, GenericArgsRef, GenericParamDef, GenericParamDefKind, IsSuggestable, Ty, TyCtxt,
1717
};
1818
use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
19-
use rustc_span::{symbol::kw, Span};
19+
use rustc_span::symbol::kw;
2020
use smallvec::SmallVec;
2121

2222
/// Report an error that a generic argument did not match the generic parameter that was
@@ -404,7 +404,6 @@ pub fn create_args_for_parent_generic_args<'tcx: 'a, 'a>(
404404
/// Used specifically for function calls.
405405
pub fn check_generic_arg_count_for_call(
406406
tcx: TyCtxt<'_>,
407-
span: Span,
408407
def_id: DefId,
409408
generics: &ty::Generics,
410409
seg: &hir::PathSegment<'_>,
@@ -418,25 +417,14 @@ pub fn check_generic_arg_count_for_call(
418417
};
419418
let has_self = generics.parent.is_none() && generics.has_self;
420419

421-
check_generic_arg_count(
422-
tcx,
423-
span,
424-
def_id,
425-
seg,
426-
generics,
427-
gen_args,
428-
gen_pos,
429-
has_self,
430-
seg.infer_args,
431-
)
420+
check_generic_arg_count(tcx, def_id, seg, generics, gen_args, gen_pos, has_self, seg.infer_args)
432421
}
433422

434423
/// Checks that the correct number of generic arguments have been provided.
435424
/// This is used both for datatypes and function calls.
436425
#[instrument(skip(tcx, gen_pos), level = "debug")]
437426
pub(crate) fn check_generic_arg_count(
438427
tcx: TyCtxt<'_>,
439-
span: Span,
440428
def_id: DefId,
441429
seg: &hir::PathSegment<'_>,
442430
gen_params: &ty::Generics,

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_hir as hir;
2525
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
2626
use rustc_hir::def_id::{DefId, LocalDefId};
2727
use rustc_hir::intravisit::{walk_generics, Visitor as _};
28-
use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
28+
use rustc_hir::{GenericArg, GenericArgs};
2929
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
3030
use rustc_infer::traits::ObligationCause;
3131
use rustc_middle::middle::stability::AllowUnstable;
@@ -379,7 +379,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
379379

380380
let mut arg_count = check_generic_arg_count(
381381
tcx,
382-
span,
383382
def_id,
384383
seg,
385384
generics,
@@ -773,9 +772,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
773772
speculative,
774773
&mut dup_bindings,
775774
binding.span,
776-
constness,
777775
only_self_bounds,
778-
polarity,
779776
);
780777
// Okay to ignore `Err` because of `ErrorGuaranteed` (see above).
781778
}
@@ -2493,7 +2490,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24932490
let opaque_ty = tcx.hir().item(item_id);
24942491

24952492
match opaque_ty.kind {
2496-
hir::ItemKind::OpaqueTy(&hir::OpaqueTy { origin, .. }) => {
2493+
hir::ItemKind::OpaqueTy(&hir::OpaqueTy { .. }) => {
24972494
let local_def_id = item_id.owner_id.def_id;
24982495
// If this is an RPITIT and we are using the new RPITIT lowering scheme, we
24992496
// generate the def_id of an associated type for the trait and return as
@@ -2503,7 +2500,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25032500
} else {
25042501
local_def_id.to_def_id()
25052502
};
2506-
self.impl_trait_ty_to_ty(def_id, lifetimes, origin, in_trait)
2503+
self.impl_trait_ty_to_ty(def_id, lifetimes, in_trait)
25072504
}
25082505
ref i => bug!("`impl Trait` pointed to non-opaque type?? {:#?}", i),
25092506
}
@@ -2559,7 +2556,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25592556
&self,
25602557
def_id: DefId,
25612558
lifetimes: &[hir::GenericArg<'_>],
2562-
origin: OpaqueTyOrigin,
25632559
in_trait: bool,
25642560
) -> Ty<'tcx> {
25652561
debug!("impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})", def_id, lifetimes);

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
521521
/// We must not attempt to select obligations after this method has run, or risk query cycle
522522
/// ICE.
523523
#[instrument(level = "debug", skip(self))]
524-
pub(in super::super) fn resolve_coroutine_interiors(&self, def_id: DefId) {
524+
pub(in super::super) fn resolve_coroutine_interiors(&self) {
525525
// Try selecting all obligations that are not blocked on inference variables.
526526
// Once we start unifying coroutine witnesses, trying to select obligations on them will
527527
// trigger query cycle ICEs, as doing so requires MIR.
@@ -1179,14 +1179,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11791179
// parameter internally, but we don't allow users to specify the
11801180
// parameter's value explicitly, so we have to do some error-
11811181
// checking here.
1182-
let arg_count = check_generic_arg_count_for_call(
1183-
tcx,
1184-
span,
1185-
def_id,
1186-
generics,
1187-
seg,
1188-
IsMethodCall::No,
1189-
);
1182+
let arg_count =
1183+
check_generic_arg_count_for_call(tcx, def_id, generics, seg, IsMethodCall::No);
11901184

11911185
if let ExplicitLateBound::Yes = arg_count.explicit_late_bound {
11921186
explicit_late_bound = ExplicitLateBound::Yes;

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ fn typeck_with_fallback<'tcx>(
286286
debug!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations());
287287

288288
// This must be the last thing before `report_ambiguity_errors`.
289-
fcx.resolve_coroutine_interiors(def_id.to_def_id());
289+
fcx.resolve_coroutine_interiors();
290290

291291
debug!(pending_obligations = ?fcx.fulfillment_cx.borrow().pending_obligations());
292292

compiler/rustc_hir_typeck/src/mem_categorization.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
436436
pub(crate) fn cat_rvalue(
437437
&self,
438438
hir_id: hir::HirId,
439-
span: Span,
439+
// FIXME: remove
440+
_span: Span,
440441
expr_ty: Ty<'tcx>,
441442
) -> PlaceWithHirId<'tcx> {
442443
PlaceWithHirId::new(hir_id, expr_ty, PlaceBase::Rvalue, Vec::new())

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
356356

357357
let arg_count_correct = check_generic_arg_count_for_call(
358358
self.tcx,
359-
self.span,
360359
pick.item.def_id,
361360
generics,
362361
seg,

0 commit comments

Comments
 (0)