@@ -1623,16 +1623,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16231623 /// ```
16241624 ///
16251625 /// Returns `true` if an async-await specific note was added to the diagnostic.
1626+ #[ instrument( level = "debug" , skip_all, fields( ?obligation. predicate, ?obligation. cause. span) ) ]
16261627 fn maybe_note_obligation_cause_for_async_await (
16271628 & self ,
16281629 err : & mut Diagnostic ,
16291630 obligation : & PredicateObligation < ' tcx > ,
16301631 ) -> bool {
1631- debug ! (
1632- "maybe_note_obligation_cause_for_async_await: obligation.predicate={:?} \
1633- obligation.cause.span={:?}",
1634- obligation. predicate, obligation. cause. span
1635- ) ;
16361632 let hir = self . tcx . hir ( ) ;
16371633
16381634 // Attempt to detect an async-await error by looking at the obligation causes, looking
@@ -1672,18 +1668,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16721668 let mut seen_upvar_tys_infer_tuple = false ;
16731669
16741670 while let Some ( code) = next_code {
1675- debug ! ( "maybe_note_obligation_cause_for_async_await: code={:?}" , code) ;
1671+ debug ! ( ? code) ;
16761672 match code {
16771673 ObligationCauseCode :: FunctionArgumentObligation { parent_code, .. } => {
16781674 next_code = Some ( parent_code) ;
16791675 }
16801676 ObligationCauseCode :: ImplDerivedObligation ( cause) => {
16811677 let ty = cause. derived . parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
16821678 debug ! (
1683- "maybe_note_obligation_cause_for_async_await: ImplDerived \
1684- parent_trait_ref={:?} self_ty.kind={:?}",
1685- cause. derived. parent_trait_pred,
1686- ty. kind( )
1679+ parent_trait_ref = ?cause. derived. parent_trait_pred,
1680+ self_ty. kind = ?ty. kind( ) ,
1681+ "ImplDerived" ,
16871682 ) ;
16881683
16891684 match * ty. kind ( ) {
@@ -1712,10 +1707,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17121707 | ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation) => {
17131708 let ty = derived_obligation. parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
17141709 debug ! (
1715- "maybe_note_obligation_cause_for_async_await: \
1716- parent_trait_ref={:?} self_ty.kind={:?}",
1717- derived_obligation. parent_trait_pred,
1718- ty. kind( )
1710+ parent_trait_ref = ?derived_obligation. parent_trait_pred,
1711+ self_ty. kind = ?ty. kind( ) ,
17191712 ) ;
17201713
17211714 match * ty. kind ( ) {
@@ -1745,7 +1738,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17451738 }
17461739
17471740 // Only continue if a generator was found.
1748- debug ! ( ?generator, ?trait_ref, ?target_ty, "maybe_note_obligation_cause_for_async_await" ) ;
1741+ debug ! ( ?generator, ?trait_ref, ?target_ty) ;
17491742 let ( Some ( generator_did) , Some ( trait_ref) , Some ( target_ty) ) = ( generator, trait_ref, target_ty) else {
17501743 return false ;
17511744 } ;
@@ -1755,12 +1748,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17551748 let in_progress_typeck_results = self . in_progress_typeck_results . map ( |t| t. borrow ( ) ) ;
17561749 let generator_did_root = self . tcx . typeck_root_def_id ( generator_did) ;
17571750 debug ! (
1758- "maybe_note_obligation_cause_for_async_await: generator_did={:?} \
1759- generator_did_root={:?} in_progress_typeck_results.hir_owner={:?} span={:?}",
1760- generator_did,
1761- generator_did_root,
1762- in_progress_typeck_results. as_ref( ) . map( |t| t. hir_owner) ,
1763- span
1751+ ?generator_did,
1752+ ?generator_did_root,
1753+ in_progress_typeck_results. hir_owner = ?in_progress_typeck_results. as_ref( ) . map( |t| t. hir_owner) ,
1754+ ?span,
17641755 ) ;
17651756
17661757 let generator_body = generator_did
@@ -1783,7 +1774,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17831774 if let Some ( body) = generator_body {
17841775 visitor. visit_body ( body) ;
17851776 }
1786- debug ! ( "maybe_note_obligation_cause_for_async_await: awaits = {:?}" , visitor. awaits) ;
1777+ debug ! ( awaits = ? visitor. awaits) ;
17871778
17881779 // Look for a type inside the generator interior that matches the target type to get
17891780 // a span.
@@ -1804,11 +1795,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
18041795 let ty_erased = self . tcx . erase_late_bound_regions ( ty) ;
18051796 let ty_erased = self . tcx . erase_regions ( ty_erased) ;
18061797 let eq = ty_erased == target_ty_erased;
1807- debug ! (
1808- "maybe_note_obligation_cause_for_async_await: ty_erased={:?} \
1809- target_ty_erased={:?} eq={:?}",
1810- ty_erased, target_ty_erased, eq
1811- ) ;
1798+ debug ! ( ?ty_erased, ?target_ty_erased, ?eq) ;
18121799 eq
18131800 } ;
18141801
@@ -1883,6 +1870,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
18831870
18841871 /// Unconditionally adds the diagnostic note described in
18851872 /// `maybe_note_obligation_cause_for_async_await`'s documentation comment.
1873+ #[ instrument( level = "debug" , skip_all) ]
18861874 fn note_obligation_cause_for_async_await (
18871875 & self ,
18881876 err : & mut Diagnostic ,
@@ -2032,8 +2020,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
20322020 } else {
20332021 // Look at the last interior type to get a span for the `.await`.
20342022 debug ! (
2035- "note_obligation_cause_for_async_await generator_interior_types: {:#?}" ,
2036- typeck_results. as_ref( ) . map( |t| & t. generator_interior_types)
2023+ generator_interior_types = ?format_args!(
2024+ "{:#?}" , typeck_results. as_ref( ) . map( |t| & t. generator_interior_types)
2025+ ) ,
20372026 ) ;
20382027 explain_yield ( interior_span, yield_span, scope_span) ;
20392028 }
@@ -2068,7 +2057,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
20682057 // bar(Foo(std::ptr::null())).await;
20692058 // ^^^^^^^^^^^^^^^^^^^^^ raw-ptr `*T` created inside this struct ctor.
20702059 // ```
2071- debug ! ( " parent_def_kind: {:?}" , self . tcx. def_kind( parent_did) ) ;
2060+ debug ! ( parent_def_kind = ? self . tcx. def_kind( parent_did) ) ;
20722061 let is_raw_borrow_inside_fn_like_call =
20732062 match self . tcx . def_kind ( parent_did) {
20742063 DefKind :: Fn | DefKind :: Ctor ( ..) => target_ty. is_unsafe_ptr ( ) ,
@@ -2126,7 +2115,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
21262115
21272116 // Add a note for the item obligation that remains - normally a note pointing to the
21282117 // bound that introduced the obligation (e.g. `T: Send`).
2129- debug ! ( "note_obligation_cause_for_async_await: next_code={:?}" , next_code) ;
2118+ debug ! ( ? next_code) ;
21302119 self . note_obligation_cause_code (
21312120 err,
21322121 & obligation. predicate ,
@@ -2683,20 +2672,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
26832672 ) ) ;
26842673 }
26852674
2675+ #[ instrument(
2676+ level = "debug" , skip( self , err) , fields( trait_pred. self_ty = ?trait_pred. self_ty( ) )
2677+ ) ]
26862678 fn suggest_await_before_try (
26872679 & self ,
26882680 err : & mut Diagnostic ,
26892681 obligation : & PredicateObligation < ' tcx > ,
26902682 trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
26912683 span : Span ,
26922684 ) {
2693- debug ! (
2694- "suggest_await_before_try: obligation={:?}, span={:?}, trait_pred={:?}, trait_pred_self_ty={:?}" ,
2695- obligation,
2696- span,
2697- trait_pred,
2698- trait_pred. self_ty( )
2699- ) ;
27002685 let body_hir_id = obligation. cause . body_id ;
27012686 let item_id = self . tcx . hir ( ) . get_parent_node ( body_hir_id) ;
27022687
@@ -2734,14 +2719,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
27342719 ) ;
27352720
27362721 debug ! (
2737- "suggest_await_before_try: normalized_projection_type {:?}" ,
2738- self . resolve_vars_if_possible( projection_ty)
2722+ normalized_projection_type = ?self . resolve_vars_if_possible( projection_ty)
27392723 ) ;
27402724 let try_obligation = self . mk_trait_obligation_with_new_self_ty (
27412725 obligation. param_env ,
27422726 trait_pred. map_bound ( |trait_pred| ( trait_pred, projection_ty. skip_binder ( ) ) ) ,
27432727 ) ;
2744- debug ! ( "suggest_await_before_try: try_trait_obligation {:?}" , try_obligation) ;
2728+ debug ! ( try_trait_obligation = ? try_obligation) ;
27452729 if self . predicate_may_hold ( & try_obligation)
27462730 && let Ok ( snippet) = self . tcx . sess . source_map ( ) . span_to_snippet ( span)
27472731 && snippet. ends_with ( '?' )
0 commit comments