Skip to content

Commit 5115069

Browse files
committed
Add some more instrumentation
1 parent 16868d9 commit 5115069

File tree

1 file changed

+13
-9
lines changed
  • compiler/rustc_infer/src/infer/lexical_region_resolve

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use std::fmt;
2828
/// iteration to find region values which satisfy all constraints,
2929
/// assuming such values can be found. It returns the final values of
3030
/// all the variables as well as a set of errors that must be reported.
31+
#[instrument(level = "debug", skip(region_rels, var_infos, data))]
3132
pub fn resolve<'tcx>(
3233
region_rels: &RegionRelations<'_, 'tcx>,
3334
var_infos: VarInfos,
3435
data: RegionConstraintData<'tcx>,
3536
mode: RegionckMode,
3637
) -> (LexicalRegionResolutions<'tcx>, Vec<RegionResolutionError<'tcx>>) {
37-
debug!("RegionConstraintData: resolve_regions()");
3838
let mut errors = vec![];
3939
let mut resolver = LexicalResolver { region_rels, var_infos, data };
4040
match mode {
@@ -266,13 +266,14 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
266266
///
267267
/// From that list, we look for a *minimal* option `'c_min`. If we
268268
/// find one, then we can enforce that `'r: 'c_min`.
269+
#[instrument(level = "debug", skip(self, graph, member_constraint, var_values))]
269270
fn enforce_member_constraint(
270271
&self,
271272
graph: &RegionGraph<'tcx>,
272273
member_constraint: &MemberConstraint<'tcx>,
273274
var_values: &mut LexicalRegionResolutions<'tcx>,
274275
) -> bool {
275-
debug!("enforce_member_constraint(member_constraint={:#?})", member_constraint);
276+
debug!("member_constraint={:#?}", member_constraint);
276277

277278
// The constraint is some inference variable (`vid`) which
278279
// must be equal to one of the options.
@@ -311,15 +312,15 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
311312
Some(&r) => r,
312313
None => return false,
313314
};
314-
debug!("enforce_member_constraint: least_choice={:?}", least_choice);
315+
debug!(?least_choice);
315316
for &option in options {
316-
debug!("enforce_member_constraint: option={:?}", option);
317+
debug!(?option);
317318
if !self.sub_concrete_regions(least_choice, option) {
318319
if self.sub_concrete_regions(option, least_choice) {
319-
debug!("enforce_member_constraint: new least choice");
320+
debug!("new least choice");
320321
least_choice = option;
321322
} else {
322-
debug!("enforce_member_constraint: no least choice");
323+
debug!("no least choice");
323324
return false;
324325
}
325326
}
@@ -461,6 +462,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
461462
}
462463

463464
/// True if `a <= b`, but not defined over inference variables.
465+
#[instrument(level = "trace", skip(self))]
464466
fn sub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> bool {
465467
let tcx = self.tcx();
466468
let sub_free_regions = |r1, r2| self.region_rels.free_regions.sub_free_regions(tcx, r1, r2);
@@ -492,6 +494,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
492494
///
493495
/// Neither `a` nor `b` may be an inference variable (hence the
494496
/// term "concrete regions").
497+
#[instrument(level = "trace", skip(self))]
495498
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
496499
let r = match (a, b) {
497500
(&ReLateBound(..), _) | (_, &ReLateBound(..)) | (&ReErased, _) | (_, &ReErased) => {
@@ -562,13 +565,14 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
562565
/// After expansion is complete, go and check upper bounds (i.e.,
563566
/// cases where the region cannot grow larger than a fixed point)
564567
/// and check that they are satisfied.
568+
#[instrument(skip(self, var_data, errors))]
565569
fn collect_errors(
566570
&self,
567571
var_data: &mut LexicalRegionResolutions<'tcx>,
568572
errors: &mut Vec<RegionResolutionError<'tcx>>,
569573
) {
570574
for (constraint, origin) in &self.data.constraints {
571-
debug!("collect_errors: constraint={:?} origin={:?}", constraint, origin);
575+
debug!(?constraint, ?origin);
572576
match *constraint {
573577
Constraint::RegSubVar(..) | Constraint::VarSubVar(..) => {
574578
// Expansion will ensure that these constraints hold. Ignore.
@@ -580,7 +584,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
580584
}
581585

582586
debug!(
583-
"collect_errors: region error at {:?}: \
587+
"region error at {:?}: \
584588
cannot verify that {:?} <= {:?}",
585589
origin, sub, sup
586590
);
@@ -606,7 +610,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
606610
// collect them later.
607611
if !self.sub_concrete_regions(a_region, b_region) {
608612
debug!(
609-
"collect_errors: region error at {:?}: \
613+
"region error at {:?}: \
610614
cannot verify that {:?}={:?} <= {:?}",
611615
origin, a_vid, a_region, b_region
612616
);

0 commit comments

Comments
 (0)