Skip to content

Commit da52816

Browse files
committed
Update tracing calls
1 parent 3265527 commit da52816

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
@@ -1704,6 +1699,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17041699
.collect()
17051700
}
17061701

1702+
#[instrument(level = "debug", skip_all)]
17071703
fn lower_qpath_to_ty(
17081704
&self,
17091705
span: Span,
@@ -1716,22 +1712,19 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17161712
let tcx = self.tcx();
17171713

17181714
let trait_def_id = tcx.parent(item_def_id);
1719-
1720-
debug!("qpath_to_ty: trait_def_id={:?}", trait_def_id);
1715+
debug!(?trait_def_id);
17211716

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

17251720
let def_id = self.item_def_id();
1726-
1727-
debug!("qpath_to_ty: self.item_def_id()={:?}", def_id);
1721+
debug!(item_def_id = ?def_id);
17281722

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

17361729
// If the trait in segment is the same as the trait defining the item,
17371730
// use the `<Self as ..>` syntax in the error.
@@ -1766,8 +1759,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17661759
);
17671760
return Ty::new_error(tcx, reported);
17681761
};
1769-
1770-
debug!("qpath_to_ty: self_type={:?}", self_ty);
1762+
debug!(?self_ty);
17711763

17721764
let trait_ref = self.lower_path_to_mono_trait_ref(
17731765
span,
@@ -1777,12 +1769,11 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
17771769
false,
17781770
constness,
17791771
);
1772+
debug!(?trait_ref);
17801773

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

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

@@ -2025,20 +2016,17 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
20252016
}
20262017

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

2037-
debug!(
2038-
"res_to_ty(res={:?}, opt_self_ty={:?}, path_segments={:?})",
2039-
path.res, opt_self_ty, path.segments
2040-
);
2041-
20422030
let span = path.span;
20432031
match path.res {
20442032
Res::Def(DefKind::OpaqueTy, did) => {
@@ -2572,19 +2560,19 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
25722560
result_ty
25732561
}
25742562

2575-
#[instrument(level = "debug", skip(self), ret)]
2563+
#[instrument(level = "debug", skip_all, ret)]
25762564
fn lower_impl_trait_ty(
25772565
&self,
25782566
def_id: DefId,
25792567
lifetimes: &[hir::GenericArg<'_>],
25802568
in_trait: bool,
25812569
) -> Ty<'tcx> {
2582-
debug!("impl_trait_ty_to_ty(def_id={:?}, lifetimes={:?})", def_id, lifetimes);
2570+
debug!(?def_id, ?lifetimes);
25832571
let tcx = self.tcx();
25842572

25852573
let generics = tcx.generics_of(def_id);
2574+
debug!(?generics);
25862575

2587-
debug!("impl_trait_ty_to_ty: generics={:?}", generics);
25882576
let args = ty::GenericArgs::for_item(tcx, def_id, |param, _| {
25892577
// We use `generics.count() - lifetimes.len()` here instead of `generics.parent_count`
25902578
// since return-position impl trait in trait squashes all of the generics from its source fn
@@ -2610,7 +2598,7 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
26102598
tcx.mk_param_from_def(param)
26112599
}
26122600
});
2613-
debug!("impl_trait_ty_to_ty: args={:?}", args);
2601+
debug!(?args);
26142602

26152603
if in_trait {
26162604
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() {
@@ -246,8 +247,8 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
246247
// the bounds
247248
let mut duplicates = FxHashSet::default();
248249
auto_traits.retain(|i| duplicates.insert(i.trait_ref().def_id()));
249-
debug!("regular_traits: {:?}", regular_traits);
250-
debug!("auto_traits: {:?}", auto_traits);
250+
debug!(?regular_traits);
251+
debug!(?auto_traits);
251252

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

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

compiler/rustc_hir_analysis/src/collect.rs

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

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

557558
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)