Skip to content

Commit 24799e3

Browse files
committed
remove an unused DefId
1 parent a3beeaa commit 24799e3

File tree

11 files changed

+28
-74
lines changed

11 files changed

+28
-74
lines changed

compiler/rustc_infer/src/infer/free_regions.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! and use that to decide when one free region outlives another, and so forth.
55
66
use rustc_data_structures::transitive_relation::TransitiveRelation;
7-
use rustc_hir::def_id::DefId;
87
use rustc_middle::ty::{self, Lift, Region, TyCtxt};
98

109
/// Combines a `FreeRegionMap` and a `TyCtxt`.
@@ -14,16 +13,13 @@ use rustc_middle::ty::{self, Lift, Region, TyCtxt};
1413
pub(crate) struct RegionRelations<'a, 'tcx> {
1514
pub tcx: TyCtxt<'tcx>,
1615

17-
/// The context used for debug messages
18-
pub context: DefId,
19-
2016
/// Free-region relationships.
2117
pub free_regions: &'a FreeRegionMap<'tcx>,
2218
}
2319

2420
impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
25-
pub fn new(tcx: TyCtxt<'tcx>, context: DefId, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
26-
Self { tcx, context, free_regions }
21+
pub fn new(tcx: TyCtxt<'tcx>, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
22+
Self { tcx, free_regions }
2723
}
2824

2925
pub fn lub_free_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
120120
) -> LexicalRegionResolutions<'tcx> {
121121
let mut var_data = self.construct_var_data(self.tcx());
122122

123-
// Dorky hack to cause `dump_constraints` to only get called
124-
// if debug mode is enabled:
125-
debug!(
126-
"----() End constraint listing (context={:?}) {:?}---",
127-
self.region_rels.context,
128-
self.dump_constraints(self.region_rels)
129-
);
123+
if cfg!(debug_assertions) {
124+
self.dump_constraints();
125+
}
130126

131127
let graph = self.construct_graph();
132128
self.expand_givens(&graph);
@@ -156,8 +152,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
156152
}
157153
}
158154

159-
fn dump_constraints(&self, free_regions: &RegionRelations<'_, 'tcx>) {
160-
debug!("----() Start constraint listing (context={:?}) ()----", free_regions.context);
155+
#[instrument(level = "debug", skip(self))]
156+
fn dump_constraints(&self) {
161157
for (idx, (constraint, _)) in self.data.constraints.iter().enumerate() {
162158
debug!("Constraint {} => {:?}", idx, constraint);
163159
}

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12671267
/// `resolve_vars_if_possible` as well as `fully_resolve`.
12681268
pub fn resolve_regions(
12691269
&self,
1270-
region_context: DefId,
12711270
outlives_env: &OutlivesEnvironment<'tcx>,
12721271
) -> Vec<RegionResolutionError<'tcx>> {
12731272
let (var_infos, data) = {
@@ -1286,8 +1285,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
12861285
.into_infos_and_data()
12871286
};
12881287

1289-
let region_rels =
1290-
&RegionRelations::new(self.tcx, region_context, outlives_env.free_region_map());
1288+
let region_rels = &RegionRelations::new(self.tcx, outlives_env.free_region_map());
12911289

12921290
let (lexical_region_resolutions, errors) =
12931291
lexical_region_resolve::resolve(outlives_env.param_env, region_rels, var_infos, data);
@@ -1302,12 +1300,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13021300
/// result. After this, no more unification operations should be
13031301
/// done -- or the compiler will panic -- but it is legal to use
13041302
/// `resolve_vars_if_possible` as well as `fully_resolve`.
1305-
pub fn resolve_regions_and_report_errors(
1306-
&self,
1307-
region_context: DefId,
1308-
outlives_env: &OutlivesEnvironment<'tcx>,
1309-
) {
1310-
let errors = self.resolve_regions(region_context, outlives_env);
1303+
pub fn resolve_regions_and_report_errors(&self, outlives_env: &OutlivesEnvironment<'tcx>) {
1304+
let errors = self.resolve_regions(outlives_env);
13111305

13121306
if !self.is_tainted_by_errors() {
13131307
// As a heuristic, just skip reporting region errors

compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,13 @@ fn negative_impl<'cx, 'tcx>(
317317
let (subject2, obligations) =
318318
impl_subject_and_oblig(selcx, impl_env, impl2_def_id, impl2_substs);
319319

320-
!equate(&infcx, impl_env, impl1_def_id, subject1, subject2, obligations)
320+
!equate(&infcx, impl_env, subject1, subject2, obligations)
321321
})
322322
}
323323

324324
fn equate<'cx, 'tcx>(
325325
infcx: &InferCtxt<'cx, 'tcx>,
326326
impl_env: ty::ParamEnv<'tcx>,
327-
impl1_def_id: DefId,
328327
subject1: ImplSubject<'tcx>,
329328
subject2: ImplSubject<'tcx>,
330329
obligations: impl Iterator<Item = PredicateObligation<'tcx>>,
@@ -341,7 +340,7 @@ fn equate<'cx, 'tcx>(
341340
let opt_failing_obligation = obligations
342341
.into_iter()
343342
.chain(more_obligations)
344-
.find(|o| negative_impl_exists(selcx, impl_env, impl1_def_id, o));
343+
.find(|o| negative_impl_exists(selcx, impl_env, o));
345344

346345
if let Some(failing_obligation) = opt_failing_obligation {
347346
debug!("overlap: obligation unsatisfiable {:?}", failing_obligation);
@@ -356,18 +355,17 @@ fn equate<'cx, 'tcx>(
356355
fn negative_impl_exists<'cx, 'tcx>(
357356
selcx: &SelectionContext<'cx, 'tcx>,
358357
param_env: ty::ParamEnv<'tcx>,
359-
region_context: DefId,
360358
o: &PredicateObligation<'tcx>,
361359
) -> bool {
362360
let infcx = &selcx.infcx().fork();
363361

364-
if resolve_negative_obligation(infcx, param_env, region_context, o) {
362+
if resolve_negative_obligation(infcx, param_env, o) {
365363
return true;
366364
}
367365

368366
// Try to prove a negative obligation exists for super predicates
369367
for o in util::elaborate_predicates(infcx.tcx, iter::once(o.predicate)) {
370-
if resolve_negative_obligation(infcx, param_env, region_context, &o) {
368+
if resolve_negative_obligation(infcx, param_env, &o) {
371369
return true;
372370
}
373371
}
@@ -379,7 +377,6 @@ fn negative_impl_exists<'cx, 'tcx>(
379377
fn resolve_negative_obligation<'cx, 'tcx>(
380378
infcx: &InferCtxt<'cx, 'tcx>,
381379
param_env: ty::ParamEnv<'tcx>,
382-
region_context: DefId,
383380
o: &PredicateObligation<'tcx>,
384381
) -> bool {
385382
let tcx = infcx.tcx;
@@ -409,7 +406,7 @@ fn resolve_negative_obligation<'cx, 'tcx>(
409406

410407
infcx.process_registered_region_obligations(outlives_env.region_bound_pairs_map(), param_env);
411408

412-
let errors = infcx.resolve_regions(region_context, &outlives_env);
409+
let errors = infcx.resolve_regions(&outlives_env);
413410

414411
if !errors.is_empty() {
415412
return false;

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,13 @@ pub fn type_known_to_meet_bound_modulo_regions<'a, 'tcx>(
198198
}
199199
}
200200

201+
#[instrument(level = "debug", skip(tcx, elaborated_env))]
201202
fn do_normalize_predicates<'tcx>(
202203
tcx: TyCtxt<'tcx>,
203-
region_context: DefId,
204204
cause: ObligationCause<'tcx>,
205205
elaborated_env: ty::ParamEnv<'tcx>,
206206
predicates: Vec<ty::Predicate<'tcx>>,
207207
) -> Result<Vec<ty::Predicate<'tcx>>, ErrorGuaranteed> {
208-
debug!(
209-
"do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})",
210-
predicates, region_context, cause,
211-
);
212208
let span = cause.span;
213209
tcx.infer_ctxt().enter(|infcx| {
214210
// FIXME. We should really... do something with these region
@@ -240,7 +236,7 @@ fn do_normalize_predicates<'tcx>(
240236
// cares about declarations like `'a: 'b`.
241237
let outlives_env = OutlivesEnvironment::new(elaborated_env);
242238

243-
infcx.resolve_regions_and_report_errors(region_context, &outlives_env);
239+
infcx.resolve_regions_and_report_errors(&outlives_env);
244240

245241
let predicates = match infcx.fully_resolve(predicates) {
246242
Ok(predicates) => predicates,
@@ -269,9 +265,9 @@ fn do_normalize_predicates<'tcx>(
269265

270266
// FIXME: this is gonna need to be removed ...
271267
/// Normalizes the parameter environment, reporting errors if they occur.
268+
#[instrument(level = "debug", skip(tcx))]
272269
pub fn normalize_param_env_or_error<'tcx>(
273270
tcx: TyCtxt<'tcx>,
274-
region_context: DefId,
275271
unnormalized_env: ty::ParamEnv<'tcx>,
276272
cause: ObligationCause<'tcx>,
277273
) -> ty::ParamEnv<'tcx> {
@@ -289,12 +285,6 @@ pub fn normalize_param_env_or_error<'tcx>(
289285
// parameter environments once for every fn as it goes,
290286
// and errors will get reported then; so outside of type inference we
291287
// can be sure that no errors should occur.
292-
293-
debug!(
294-
"normalize_param_env_or_error(region_context={:?}, unnormalized_env={:?}, cause={:?})",
295-
region_context, unnormalized_env, cause
296-
);
297-
298288
let mut predicates: Vec<_> =
299289
util::elaborate_predicates(tcx, unnormalized_env.caller_bounds().into_iter())
300290
.map(|obligation| obligation.predicate)
@@ -338,7 +328,6 @@ pub fn normalize_param_env_or_error<'tcx>(
338328
);
339329
let Ok(non_outlives_predicates) = do_normalize_predicates(
340330
tcx,
341-
region_context,
342331
cause.clone(),
343332
elaborated_env,
344333
predicates,
@@ -362,7 +351,6 @@ pub fn normalize_param_env_or_error<'tcx>(
362351
);
363352
let Ok(outlives_predicates) = do_normalize_predicates(
364353
tcx,
365-
region_context,
366354
cause,
367355
outlives_env,
368356
outlives_predicates,

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
211211
tcx.hir().maybe_body_owned_by(id).map_or(id, |body| body.hir_id)
212212
});
213213
let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id);
214-
traits::normalize_param_env_or_error(tcx, def_id, unnormalized_env, cause)
214+
traits::normalize_param_env_or_error(tcx, unnormalized_env, cause)
215215
}
216216

217217
/// Elaborate the environment.

compiler/rustc_typeck/src/check/compare_method.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ fn compare_predicate_entailment<'tcx>(
208208
Reveal::UserFacing,
209209
hir::Constness::NotConst,
210210
);
211-
let param_env =
212-
traits::normalize_param_env_or_error(tcx, impl_m.def_id, param_env, normalize_cause);
211+
let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause);
213212

214213
tcx.infer_ctxt().enter(|infcx| {
215214
let inh = Inherited::new(infcx, impl_m.def_id.expect_local());
@@ -1247,12 +1246,7 @@ fn compare_type_predicate_entailment<'tcx>(
12471246
Reveal::UserFacing,
12481247
hir::Constness::NotConst,
12491248
);
1250-
let param_env = traits::normalize_param_env_or_error(
1251-
tcx,
1252-
impl_ty.def_id,
1253-
param_env,
1254-
normalize_cause.clone(),
1255-
);
1249+
let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause.clone());
12561250
tcx.infer_ctxt().enter(|infcx| {
12571251
let inh = Inherited::new(infcx, impl_ty.def_id.expect_local());
12581252
let infcx = &inh.infcx;

compiler/rustc_typeck/src/check/regionck.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,8 @@ pub struct RegionCtxt<'a, 'tcx> {
222222

223223
// id of innermost fn body id
224224
body_id: hir::HirId,
225+
// TODO: is this always equal to `body_id`?
225226
body_owner: LocalDefId,
226-
227-
// id of AST node being analyzed (the subject of the analysis).
228-
subject_def_id: LocalDefId,
229227
}
230228

231229
impl<'a, 'tcx> Deref for RegionCtxt<'a, 'tcx> {
@@ -245,13 +243,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
245243
param_env: ty::ParamEnv<'tcx>,
246244
) -> RegionCtxt<'a, 'tcx> {
247245
let outlives_environment = OutlivesEnvironment::new(param_env);
248-
RegionCtxt {
249-
fcx,
250-
body_id: initial_body_id,
251-
body_owner: subject,
252-
subject_def_id: subject,
253-
outlives_environment,
254-
}
246+
RegionCtxt { fcx, body_id: initial_body_id, body_owner: subject, outlives_environment }
255247
}
256248

257249
/// Try to resolve the type for the given node, returning `t_err` if an error results. Note that
@@ -369,10 +361,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
369361
self.param_env,
370362
);
371363

372-
self.fcx.resolve_regions_and_report_errors(
373-
self.subject_def_id.to_def_id(),
374-
&self.outlives_environment,
375-
);
364+
self.fcx.resolve_regions_and_report_errors(&self.outlives_environment);
376365
}
377366

378367
fn constrain_bindings_in_pat(&mut self, pat: &hir::Pat<'_>) {

compiler/rustc_typeck/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ fn resolve_regions_with_wf_tys<'tcx>(
661661

662662
add_constraints(&infcx, region_bound_pairs);
663663

664-
let errors = infcx.resolve_regions(id.expect_owner().to_def_id(), &outlives_environment);
664+
let errors = infcx.resolve_regions(&outlives_environment);
665665

666666
debug!(?errors, "errors");
667667

compiler/rustc_typeck/src/coherence/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did:
349349

350350
// Finally, resolve all regions.
351351
let outlives_env = OutlivesEnvironment::new(param_env);
352-
infcx.resolve_regions_and_report_errors(impl_did.to_def_id(), &outlives_env);
352+
infcx.resolve_regions_and_report_errors(&outlives_env);
353353
}
354354
}
355355
_ => {
@@ -606,7 +606,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
606606

607607
// Finally, resolve all regions.
608608
let outlives_env = OutlivesEnvironment::new(param_env);
609-
infcx.resolve_regions_and_report_errors(impl_did.to_def_id(), &outlives_env);
609+
infcx.resolve_regions_and_report_errors(&outlives_env);
610610

611611
CoerceUnsizedInfo { custom_kind: kind }
612612
})

compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn get_impl_substs<'tcx>(
150150

151151
// Conservatively use an empty `ParamEnv`.
152152
let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty());
153-
infcx.resolve_regions_and_report_errors(impl1_def_id.to_def_id(), &outlives_env);
153+
infcx.resolve_regions_and_report_errors(&outlives_env);
154154
let Ok(impl2_substs) = infcx.fully_resolve(impl2_substs) else {
155155
let span = tcx.def_span(impl1_def_id);
156156
tcx.sess.emit_err(SubstsOnOverriddenImpl { span });

0 commit comments

Comments
 (0)