Skip to content

Commit bdc20e3

Browse files
committed
Use instrument debugging for more readable logs
1 parent 6d76002 commit bdc20e3

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

compiler/rustc_trait_selection/src/opaque_types.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub struct OpaqueTypeDecl<'tcx> {
8383
}
8484

8585
/// Whether member constraints should be generated for all opaque types
86+
#[derive(Debug)]
8687
pub enum GenerateMemberConstraints {
8788
/// The default, used by typeck
8889
WhenRequired,
@@ -354,8 +355,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
354355
opaque_types: &OpaqueTypeMap<'tcx>,
355356
free_region_relations: &FRR,
356357
) {
357-
debug!("constrain_opaque_types()");
358-
359358
for &(opaque_type_key, opaque_defn) in opaque_types {
360359
self.constrain_opaque_type(
361360
opaque_type_key,
@@ -367,6 +366,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
367366
}
368367

369368
/// See `constrain_opaque_types` for documentation.
369+
#[instrument(level = "debug", skip(self, free_region_relations))]
370370
fn constrain_opaque_type<FRR: FreeRegionRelations<'tcx>>(
371371
&self,
372372
opaque_type_key: OpaqueTypeKey<'tcx>,
@@ -376,15 +376,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
376376
) {
377377
let def_id = opaque_type_key.def_id;
378378

379-
debug!("constrain_opaque_type()");
380-
debug!("constrain_opaque_type: def_id={:?}", def_id);
381-
debug!("constrain_opaque_type: opaque_defn={:#?}", opaque_defn);
382-
383379
let tcx = self.tcx;
384380

385381
let concrete_ty = self.resolve_vars_if_possible(opaque_defn.concrete_ty);
386382

387-
debug!("constrain_opaque_type: concrete_ty={:?}", concrete_ty);
383+
debug!(?concrete_ty);
388384

389385
let first_own_region = match opaque_defn.origin {
390386
hir::OpaqueTyOrigin::FnReturn | hir::OpaqueTyOrigin::AsyncFn => {
@@ -397,7 +393,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
397393
// type foo::<'p0..'pn>::Foo<'q0..'qm>
398394
// fn foo<l0..'ln>() -> foo::<'static..'static>::Foo<'l0..'lm>.
399395
//
400-
// For these types we onlt iterate over `'l0..lm` below.
396+
// For these types we only iterate over `'l0..lm` below.
401397
tcx.generics_of(def_id).parent_count
402398
}
403399
// These opaque type inherit all lifetime parameters from their
@@ -410,10 +406,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
410406
// If there are required region bounds, we can use them.
411407
if opaque_defn.has_required_region_bounds {
412408
let bounds = tcx.explicit_item_bounds(def_id);
413-
debug!("constrain_opaque_type: predicates: {:#?}", bounds);
409+
debug!("{:#?}", bounds);
414410
let bounds: Vec<_> =
415411
bounds.iter().map(|(bound, _)| bound.subst(tcx, opaque_type_key.substs)).collect();
416-
debug!("constrain_opaque_type: bounds={:#?}", bounds);
412+
debug!("{:#?}", bounds);
417413
let opaque_type = tcx.mk_opaque(def_id, opaque_type_key.substs);
418414

419415
let required_region_bounds =
@@ -452,8 +448,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
452448
};
453449

454450
// Compute the least upper bound of it with the other regions.
455-
debug!("constrain_opaque_types: least_region={:?}", least_region);
456-
debug!("constrain_opaque_types: subst_region={:?}", subst_region);
451+
debug!(?least_region);
452+
debug!(?subst_region);
457453
match least_region {
458454
None => least_region = Some(subst_region),
459455
Some(lr) => {
@@ -484,7 +480,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
484480
}
485481

486482
let least_region = least_region.unwrap_or(tcx.lifetimes.re_static);
487-
debug!("constrain_opaque_types: least_region={:?}", least_region);
483+
debug!(?least_region);
488484

489485
if let GenerateMemberConstraints::IfNoStaticBound = mode {
490486
if least_region != tcx.lifetimes.re_static {

0 commit comments

Comments
 (0)