Skip to content

Commit 12db6d1

Browse files
committed
Update logging statements
1 parent 31fad20 commit 12db6d1

File tree

4 files changed

+27
-38
lines changed

4 files changed

+27
-38
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+16-31
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
369369

370370
let tcx = self.tcx();
371371
let generics = tcx.generics_of(def_id);
372-
debug!("generics: {:?}", generics);
372+
debug!(?generics);
373373

374374
if generics.has_self {
375375
if generics.parent.is_some() {
@@ -641,17 +641,14 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
641641
assoc_bindings
642642
}
643643

644+
#[instrument(level = "debug", skip(self, parent_args), ret)]
644645
pub fn lower_args_for_assoc_item(
645646
&self,
646647
span: Span,
647648
item_def_id: DefId,
648649
item_segment: &hir::PathSegment<'tcx>,
649650
parent_args: GenericArgsRef<'tcx>,
650651
) -> GenericArgsRef<'tcx> {
651-
debug!(
652-
"create_args_for_associated_item(span: {:?}, item_def_id: {:?}, item_segment: {:?}",
653-
span, item_def_id, item_segment
654-
);
655652
let (args, _) = self.lower_args_for_path(
656653
span,
657654
item_def_id,
@@ -991,15 +988,9 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
991988
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> {
992989
let tcx = self.tcx();
993990

994-
debug!(
995-
"find_bound_for_assoc_item(ty_param_def_id={:?}, assoc_name={:?}, span={:?})",
996-
ty_param_def_id, assoc_name, span,
997-
);
998-
999991
let predicates =
1000992
&self.get_type_parameter_bounds(span, ty_param_def_id, assoc_name).predicates;
1001-
1002-
debug!("find_bound_for_assoc_item: predicates={:#?}", predicates);
993+
debug!(?predicates);
1003994

1004995
let param_name = tcx.hir().ty_param_name(ty_param_def_id);
1005996
self.one_bound_for_assoc_item(
@@ -1149,7 +1140,6 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
11491140
/// parameter or `Self`.
11501141
// NOTE: When this function starts resolving `Trait::AssocTy` successfully
11511142
// it should also start reporting the `BARE_TRAIT_OBJECTS` lint.
1152-
#[instrument(level = "debug", skip(self, hir_ref_id, span, qself, assoc_segment), fields(assoc_ident=?assoc_segment.ident), ret)]
11531143
pub fn lower_assoc_path_to_ty(
11541144
&self,
11551145
hir_ref_id: hir::HirId,
@@ -1159,7 +1149,10 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
11591149
assoc_segment: &hir::PathSegment<'tcx>,
11601150
permit_variants: bool,
11611151
) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> {
1152+
let _guard = tracing::debug_span!("lower_assoc_path_to_ty").entered();
1153+
debug!(%qself_ty, ?assoc_segment.ident);
11621154
let tcx = self.tcx();
1155+
11631156
let assoc_ident = assoc_segment.ident;
11641157
let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = &qself.kind {
11651158
path.res
@@ -1712,25 +1705,23 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17121705
item_segment: &hir::PathSegment<'tcx>,
17131706
constness: ty::BoundConstness,
17141707
) -> Ty<'tcx> {
1708+
let _guard = tracing::debug_span!("lower_qpath_to_ty").entered();
17151709
let tcx = self.tcx();
17161710

17171711
let trait_def_id = tcx.parent(item_def_id);
1718-
1719-
debug!("qpath_to_ty: trait_def_id={:?}", trait_def_id);
1712+
debug!(?trait_def_id);
17201713

17211714
let Some(self_ty) = opt_self_ty else {
17221715
let path_str = tcx.def_path_str(trait_def_id);
17231716

17241717
let def_id = self.item_def_id();
1725-
1726-
debug!("qpath_to_ty: self.item_def_id()={:?}", def_id);
1718+
debug!(item_def_id = ?def_id);
17271719

17281720
let parent_def_id = def_id
17291721
.as_local()
17301722
.map(|def_id| tcx.local_def_id_to_hir_id(def_id))
17311723
.map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id());
1732-
1733-
debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id);
1724+
debug!(?parent_def_id);
17341725

17351726
// If the trait in segment is the same as the trait defining the item,
17361727
// use the `<Self as ..>` syntax in the error.
@@ -1765,8 +1756,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17651756
);
17661757
return Ty::new_error(tcx, reported);
17671758
};
1768-
1769-
debug!("qpath_to_ty: self_type={:?}", self_ty);
1759+
debug!(?self_ty);
17701760

17711761
let trait_ref = self.lower_path_to_mono_trait_ref(
17721762
span,
@@ -1776,12 +1766,11 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17761766
false,
17771767
constness,
17781768
);
1769+
debug!(?trait_ref);
17791770

17801771
let item_args =
17811772
self.lower_args_for_assoc_item(span, item_def_id, item_segment, trait_ref.args);
17821773

1783-
debug!("qpath_to_ty: trait_ref={:?}", trait_ref);
1784-
17851774
Ty::new_projection(tcx, item_def_id, item_args)
17861775
}
17871776

@@ -2031,13 +2020,10 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
20312020
hir_id: hir::HirId,
20322021
permit_variants: bool,
20332022
) -> Ty<'tcx> {
2023+
let _guard = tracing::debug_span!("lower_res_to_ty").entered();
2024+
debug!(?path.res, ?opt_self_ty, ?path.segments);
20342025
let tcx = self.tcx();
20352026

2036-
debug!(
2037-
"res_to_ty(res={:?}, opt_self_ty={:?}, path_segments={:?})",
2038-
path.res, opt_self_ty, path.segments
2039-
);
2040-
20412027
let span = path.span;
20422028
match path.res {
20432029
Res::Def(DefKind::OpaqueTy, did) => {
@@ -2565,12 +2551,11 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25652551
lifetimes: &[hir::GenericArg<'_>],
25662552
in_trait: bool,
25672553
) -> Ty<'tcx> {
2568-
debug!("impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})", def_id, lifetimes);
25692554
let tcx = self.tcx();
25702555

25712556
let generics = tcx.generics_of(def_id);
2557+
debug!(?generics);
25722558

2573-
debug!("impl_trait_ty_to_ty: generics={:?}", generics);
25742559
let args = ty::GenericArgs::for_item(tcx, def_id, |param, _| {
25752560
// We use `generics.count() - lifetimes.len()` here instead of `generics.parent_count`
25762561
// since return-position impl trait in trait squashes all of the generics from its source fn
@@ -2596,7 +2581,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25962581
tcx.mk_param_from_def(param)
25972582
}
25982583
});
2599-
debug!("impl_trait_ty_to_ty: args={:?}", args);
2584+
debug!(?args);
26002585

26012586
if in_trait {
26022587
Ty::new_projection(tcx, def_id, args)

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
2727
borrowed: bool,
2828
representation: DynKind,
2929
) -> Ty<'tcx> {
30+
let _guard = trace::debug_span!("lower_object_ty_to_poly_trait_ref");
3031
let tcx = self.tcx();
3132

3233
let mut bounds = Bounds::default();
@@ -159,7 +160,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
159160
for (base_trait_ref, span) in regular_traits_refs_spans {
160161
let base_pred: ty::Predicate<'tcx> = base_trait_ref.to_predicate(tcx);
161162
for pred in traits::elaborate(tcx, [base_pred]) {
162-
debug!("conv_object_ty_poly_trait_ref: observing object predicate `{:?}`", pred);
163+
debug!("observing object predicate `{:?}`", pred);
163164

164165
let bound_predicate = pred.kind();
165166
match bound_predicate.skip_binder() {
@@ -245,8 +246,8 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
245246
// the bounds
246247
let mut duplicates = FxHashSet::default();
247248
auto_traits.retain(|i| duplicates.insert(i.trait_ref().def_id()));
248-
debug!("regular_traits: {:?}", regular_traits);
249-
debug!("auto_traits: {:?}", auto_traits);
249+
debug!(?regular_traits);
250+
debug!(?auto_traits);
250251

251252
// Erase the `dummy_self` (`trait_object_dummy_self`) used above.
252253
let existential_trait_refs = regular_traits.iter().map(|i| {
@@ -397,10 +398,10 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
397398
}
398399
})
399400
};
400-
debug!("region_bound: {:?}", region_bound);
401+
debug!(?region_bound);
401402

402403
let ty = Ty::new_dynamic(tcx, existential_predicates, region_bound, representation);
403-
debug!("trait_object_type: {:?}", ty);
404+
debug!(trait_object_type = ?ty);
404405
ty
405406
}
406407
}

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ fn get_new_lifetime_name<'tcx>(
553553

554554
fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
555555
let it = tcx.hir().item(item_id);
556-
debug!("convert: item {} with id {}", it.ident, it.hir_id());
556+
debug!("lower_item: item {} with id {}", it.ident, it.hir_id());
557557
let def_id = item_id.owner_id.def_id;
558558

559559
match &it.kind {

compiler/rustc_trait_selection/src/traits/object_safety.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ pub fn hir_ty_lowering_object_safety_violations(
4848
.map(ObjectSafetyViolation::SupertraitSelf)
4949
.collect();
5050

51-
debug!("astconv_object_safety_violations(trait_def_id={:?}) = {:?}", trait_def_id, violations);
51+
debug!(
52+
"hir_ty_lowering_object_safety_violations(trait_def_id={:?}) = {:?}",
53+
trait_def_id, violations
54+
);
5255

5356
violations
5457
}

0 commit comments

Comments
 (0)