Skip to content

Commit 7e17265

Browse files
committed
Update tracing calls
1 parent 71bbb6e commit 7e17265

File tree

4 files changed

+31
-44
lines changed

4 files changed

+31
-44
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+21-33
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
371371

372372
let tcx = self.tcx();
373373
let generics = tcx.generics_of(def_id);
374-
debug!("generics: {:?}", generics);
374+
debug!(?generics);
375375

376376
if generics.has_self {
377377
if generics.parent.is_some() {
@@ -643,17 +643,15 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
643643
assoc_bindings
644644
}
645645

646+
#[instrument(level = "debug", skip_all)]
646647
pub fn lower_args_for_assoc_item(
647648
&self,
648649
span: Span,
649650
item_def_id: DefId,
650651
item_segment: &hir::PathSegment<'tcx>,
651652
parent_args: GenericArgsRef<'tcx>,
652653
) -> GenericArgsRef<'tcx> {
653-
debug!(
654-
"create_args_for_associated_item(span: {:?}, item_def_id: {:?}, item_segment: {:?}",
655-
span, item_def_id, item_segment
656-
);
654+
debug!(?span, ?item_def_id, ?item_segment);
657655
let (args, _) = self.lower_args_for_path(
658656
span,
659657
item_def_id,
@@ -984,24 +982,19 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
984982
///
985983
/// `ty_param_def_id` is the `DefId` of the type parameter.
986984
/// This function will fail if there are no suitable bounds or there is any ambiguity.
987-
#[instrument(level = "debug", skip(self), ret)]
985+
#[instrument(level = "debug", skip_all, ret)]
988986
fn find_bound_for_assoc_item(
989987
&self,
990988
ty_param_def_id: LocalDefId,
991989
assoc_name: Ident,
992990
span: Span,
993991
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> {
992+
debug!(?ty_param_def_id, ?assoc_name, ?span);
994993
let tcx = self.tcx();
995994

996-
debug!(
997-
"find_bound_for_assoc_item(ty_param_def_id={:?}, assoc_name={:?}, span={:?})",
998-
ty_param_def_id, assoc_name, span,
999-
);
1000-
1001995
let predicates =
1002996
&self.get_type_parameter_bounds(span, ty_param_def_id, assoc_name).predicates;
1003-
1004-
debug!("find_bound_for_assoc_item: predicates={:#?}", predicates);
997+
debug!("predicates={:#?}", predicates);
1005998

1006999
let param_name = tcx.hir().ty_param_name(ty_param_def_id);
10071000
self.one_bound_for_assoc_item(
@@ -1151,7 +1144,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
11511144
/// parameter or `Self`.
11521145
// NOTE: When this function starts resolving `Trait::AssocTy` successfully
11531146
// it should also start reporting the `BARE_TRAIT_OBJECTS` lint.
1154-
#[instrument(level = "debug", skip(self, hir_ref_id, span, qself, assoc_segment), fields(assoc_ident=?assoc_segment.ident), ret)]
1147+
#[instrument(level = "debug", skip_all, ret)]
11551148
pub fn lower_assoc_path_to_ty(
11561149
&self,
11571150
hir_ref_id: hir::HirId,
@@ -1161,7 +1154,9 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
11611154
assoc_segment: &hir::PathSegment<'tcx>,
11621155
permit_variants: bool,
11631156
) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> {
1157+
debug!(%qself_ty, ?assoc_segment.ident);
11641158
let tcx = self.tcx();
1159+
11651160
let assoc_ident = assoc_segment.ident;
11661161
let qself_res = if let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = &qself.kind {
11671162
path.res
@@ -1705,6 +1700,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17051700
.collect()
17061701
}
17071702

1703+
#[instrument(level = "debug", skip_all)]
17081704
fn lower_qpath_to_ty(
17091705
&self,
17101706
span: Span,
@@ -1717,22 +1713,19 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17171713
let tcx = self.tcx();
17181714

17191715
let trait_def_id = tcx.parent(item_def_id);
1720-
1721-
debug!("qpath_to_ty: trait_def_id={:?}", trait_def_id);
1716+
debug!(?trait_def_id);
17221717

17231718
let Some(self_ty) = opt_self_ty else {
17241719
let path_str = tcx.def_path_str(trait_def_id);
17251720

17261721
let def_id = self.item_def_id();
1727-
1728-
debug!("qpath_to_ty: self.item_def_id()={:?}", def_id);
1722+
debug!(item_def_id = ?def_id);
17291723

17301724
let parent_def_id = def_id
17311725
.as_local()
17321726
.map(|def_id| tcx.local_def_id_to_hir_id(def_id))
17331727
.map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id());
1734-
1735-
debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id);
1728+
debug!(?parent_def_id);
17361729

17371730
// If the trait in segment is the same as the trait defining the item,
17381731
// use the `<Self as ..>` syntax in the error.
@@ -1767,8 +1760,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17671760
);
17681761
return Ty::new_error(tcx, reported);
17691762
};
1770-
1771-
debug!("qpath_to_ty: self_type={:?}", self_ty);
1763+
debug!(?self_ty);
17721764

17731765
let trait_ref = self.lower_path_to_mono_trait_ref(
17741766
span,
@@ -1778,12 +1770,11 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17781770
false,
17791771
constness,
17801772
);
1773+
debug!(?trait_ref);
17811774

17821775
let item_args =
17831776
self.lower_args_for_assoc_item(span, item_def_id, item_segment, trait_ref.args);
17841777

1785-
debug!("qpath_to_ty: trait_ref={:?}", trait_ref);
1786-
17871778
Ty::new_projection(tcx, item_def_id, item_args)
17881779
}
17891780

@@ -2026,20 +2017,17 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
20262017
}
20272018

20282019
/// Check a type `Path` and lower it to a `Ty`.
2020+
#[instrument(level = "debug", skip_all)]
20292021
pub fn lower_res_to_ty(
20302022
&self,
20312023
opt_self_ty: Option<Ty<'tcx>>,
20322024
path: &hir::Path<'tcx>,
20332025
hir_id: hir::HirId,
20342026
permit_variants: bool,
20352027
) -> Ty<'tcx> {
2028+
debug!(?path.res, ?opt_self_ty, ?path.segments);
20362029
let tcx = self.tcx();
20372030

2038-
debug!(
2039-
"res_to_ty(res={:?}, opt_self_ty={:?}, path_segments={:?})",
2040-
path.res, opt_self_ty, path.segments
2041-
);
2042-
20432031
let span = path.span;
20442032
match path.res {
20452033
Res::Def(DefKind::OpaqueTy, did) => {
@@ -2560,19 +2548,19 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25602548
result_ty
25612549
}
25622550

2563-
#[instrument(level = "debug", skip(self), ret)]
2551+
#[instrument(level = "debug", skip_all, ret)]
25642552
fn lower_impl_trait_ty(
25652553
&self,
25662554
def_id: DefId,
25672555
lifetimes: &[hir::GenericArg<'_>],
25682556
in_trait: bool,
25692557
) -> Ty<'tcx> {
2570-
debug!("impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})", def_id, lifetimes);
2558+
debug!(?def_id, ?lifetimes);
25712559
let tcx = self.tcx();
25722560

25732561
let generics = tcx.generics_of(def_id);
2562+
debug!(?generics);
25742563

2575-
debug!("impl_trait_ty_to_ty: generics={:?}", generics);
25762564
let args = ty::GenericArgs::for_item(tcx, def_id, |param, _| {
25772565
// We use `generics.count() - lifetimes.len()` here instead of `generics.parent_count`
25782566
// since return-position impl trait in trait squashes all of the generics from its source fn
@@ -2598,7 +2586,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25982586
tcx.mk_param_from_def(param)
25992587
}
26002588
});
2601-
debug!("impl_trait_ty_to_ty: args={:?}", args);
2589+
debug!(?args);
26022590

26032591
if in_trait {
26042592
Ty::new_projection(tcx, def_id, args)

compiler/rustc_hir_analysis/src/astconv/object_safety.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use smallvec::{smallvec, SmallVec};
1818
use super::HirTyLowerer;
1919

2020
impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
21+
#[instrument(level = "debug", skip_all, ret)]
2122
pub(super) fn lower_object_ty_to_poly_trait_ref(
2223
&self,
2324
span: Span,
@@ -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,8 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
397398
}
398399
})
399400
};
400-
debug!("region_bound: {:?}", region_bound);
401+
debug!(?region_bound);
401402

402-
let ty = Ty::new_dynamic(tcx, existential_predicates, region_bound, representation);
403-
debug!("trait_object_type: {:?}", ty);
404-
ty
403+
Ty::new_dynamic(tcx, existential_predicates, region_bound, representation)
405404
}
406405
}

compiler/rustc_hir_analysis/src/collect.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,10 @@ fn get_new_lifetime_name<'tcx>(
551551
(1..).flat_map(a_to_z_repeat_n).find(|lt| !existing_lifetimes.contains(lt.as_str())).unwrap()
552552
}
553553

554+
#[instrument(level = "debug", skip_all)]
554555
fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
555556
let it = tcx.hir().item(item_id);
556-
debug!("convert: item {} with id {}", it.ident, it.hir_id());
557+
debug!(item = %it.ident, id = %it.hir_id());
557558
let def_id = item_id.owner_id.def_id;
558559

559560
match &it.kind {

compiler/rustc_trait_selection/src/traits/object_safety.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub use crate::traits::{MethodViolationCode, ObjectSafetyViolation};
3737
/// Currently that is `Self` in supertraits. This is needed
3838
/// because `object_safety_violations` can't be used during
3939
/// type collection.
40+
#[instrument(level = "debug", skip(tcx))]
4041
pub fn hir_ty_lowering_object_safety_violations(
4142
tcx: TyCtxt<'_>,
4243
trait_def_id: DefId,
@@ -47,9 +48,7 @@ pub fn hir_ty_lowering_object_safety_violations(
4748
.filter(|spans| !spans.is_empty())
4849
.map(ObjectSafetyViolation::SupertraitSelf)
4950
.collect();
50-
51-
debug!("astconv_object_safety_violations(trait_def_id={:?}) = {:?}", trait_def_id, violations);
52-
51+
debug!(?violations);
5352
violations
5453
}
5554

0 commit comments

Comments
 (0)