@@ -1628,16 +1628,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16281628 /// ```
16291629 ///
16301630 /// Returns `true` if an async-await specific note was added to the diagnostic.
1631+ #[ instrument( level = "debug" , skip_all, fields( ?obligation. predicate, ?obligation. cause. span) ) ]
16311632 fn maybe_note_obligation_cause_for_async_await (
16321633 & self ,
16331634 err : & mut Diagnostic ,
16341635 obligation : & PredicateObligation < ' tcx > ,
16351636 ) -> bool {
1636- debug ! (
1637- "maybe_note_obligation_cause_for_async_await: obligation.predicate={:?} \
1638- obligation.cause.span={:?}",
1639- obligation. predicate, obligation. cause. span
1640- ) ;
16411637 let hir = self . tcx . hir ( ) ;
16421638
16431639 // Attempt to detect an async-await error by looking at the obligation causes, looking
@@ -1677,18 +1673,17 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
16771673 let mut seen_upvar_tys_infer_tuple = false ;
16781674
16791675 while let Some ( code) = next_code {
1680- debug ! ( "maybe_note_obligation_cause_for_async_await: code={:?}" , code) ;
1676+ debug ! ( ? code) ;
16811677 match code {
16821678 ObligationCauseCode :: FunctionArgumentObligation { parent_code, .. } => {
16831679 next_code = Some ( parent_code) ;
16841680 }
16851681 ObligationCauseCode :: ImplDerivedObligation ( cause) => {
16861682 let ty = cause. derived . parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
16871683 debug ! (
1688- "maybe_note_obligation_cause_for_async_await: ImplDerived \
1689- parent_trait_ref={:?} self_ty.kind={:?}",
1690- cause. derived. parent_trait_pred,
1691- ty. kind( )
1684+ parent_trait_ref = ?cause. derived. parent_trait_pred,
1685+ self_ty. kind = ?ty. kind( ) ,
1686+ "ImplDerived" ,
16921687 ) ;
16931688
16941689 match * ty. kind ( ) {
@@ -1717,10 +1712,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17171712 | ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation) => {
17181713 let ty = derived_obligation. parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
17191714 debug ! (
1720- "maybe_note_obligation_cause_for_async_await: \
1721- parent_trait_ref={:?} self_ty.kind={:?}",
1722- derived_obligation. parent_trait_pred,
1723- ty. kind( )
1715+ parent_trait_ref = ?derived_obligation. parent_trait_pred,
1716+ self_ty. kind = ?ty. kind( ) ,
17241717 ) ;
17251718
17261719 match * ty. kind ( ) {
@@ -1750,7 +1743,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17501743 }
17511744
17521745 // Only continue if a generator was found.
1753- debug ! ( ?generator, ?trait_ref, ?target_ty, "maybe_note_obligation_cause_for_async_await" ) ;
1746+ debug ! ( ?generator, ?trait_ref, ?target_ty) ;
17541747 let ( Some ( generator_did) , Some ( trait_ref) , Some ( target_ty) ) = ( generator, trait_ref, target_ty) else {
17551748 return false ;
17561749 } ;
@@ -1760,12 +1753,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17601753 let in_progress_typeck_results = self . in_progress_typeck_results . map ( |t| t. borrow ( ) ) ;
17611754 let generator_did_root = self . tcx . typeck_root_def_id ( generator_did) ;
17621755 debug ! (
1763- "maybe_note_obligation_cause_for_async_await: generator_did={:?} \
1764- generator_did_root={:?} in_progress_typeck_results.hir_owner={:?} span={:?}",
1765- generator_did,
1766- generator_did_root,
1767- in_progress_typeck_results. as_ref( ) . map( |t| t. hir_owner) ,
1768- span
1756+ ?generator_did,
1757+ ?generator_did_root,
1758+ in_progress_typeck_results. hir_owner = ?in_progress_typeck_results. as_ref( ) . map( |t| t. hir_owner) ,
1759+ ?span,
17691760 ) ;
17701761
17711762 let generator_body = generator_did
@@ -1788,7 +1779,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
17881779 if let Some ( body) = generator_body {
17891780 visitor. visit_body ( body) ;
17901781 }
1791- debug ! ( "maybe_note_obligation_cause_for_async_await: awaits = {:?}" , visitor. awaits) ;
1782+ debug ! ( awaits = ? visitor. awaits) ;
17921783
17931784 // Look for a type inside the generator interior that matches the target type to get
17941785 // a span.
@@ -1809,11 +1800,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
18091800 let ty_erased = self . tcx . erase_late_bound_regions ( ty) ;
18101801 let ty_erased = self . tcx . erase_regions ( ty_erased) ;
18111802 let eq = ty_erased == target_ty_erased;
1812- debug ! (
1813- "maybe_note_obligation_cause_for_async_await: ty_erased={:?} \
1814- target_ty_erased={:?} eq={:?}",
1815- ty_erased, target_ty_erased, eq
1816- ) ;
1803+ debug ! ( ?ty_erased, ?target_ty_erased, ?eq) ;
18171804 eq
18181805 } ;
18191806
@@ -1888,6 +1875,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
18881875
18891876 /// Unconditionally adds the diagnostic note described in
18901877 /// `maybe_note_obligation_cause_for_async_await`'s documentation comment.
1878+ #[ instrument( level = "debug" , skip_all) ]
18911879 fn note_obligation_cause_for_async_await (
18921880 & self ,
18931881 err : & mut Diagnostic ,
@@ -2037,8 +2025,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
20372025 } else {
20382026 // Look at the last interior type to get a span for the `.await`.
20392027 debug ! (
2040- "note_obligation_cause_for_async_await generator_interior_types: {:#?}" ,
2041- typeck_results. as_ref( ) . map( |t| & t. generator_interior_types)
2028+ generator_interior_types = ?format_args!(
2029+ "{:#?}" , typeck_results. as_ref( ) . map( |t| & t. generator_interior_types)
2030+ ) ,
20422031 ) ;
20432032 explain_yield ( interior_span, yield_span, scope_span) ;
20442033 }
@@ -2073,7 +2062,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
20732062 // bar(Foo(std::ptr::null())).await;
20742063 // ^^^^^^^^^^^^^^^^^^^^^ raw-ptr `*T` created inside this struct ctor.
20752064 // ```
2076- debug ! ( " parent_def_kind: {:?}" , self . tcx. def_kind( parent_did) ) ;
2065+ debug ! ( parent_def_kind = ? self . tcx. def_kind( parent_did) ) ;
20772066 let is_raw_borrow_inside_fn_like_call =
20782067 match self . tcx . def_kind ( parent_did) {
20792068 DefKind :: Fn | DefKind :: Ctor ( ..) => target_ty. is_unsafe_ptr ( ) ,
@@ -2131,7 +2120,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
21312120
21322121 // Add a note for the item obligation that remains - normally a note pointing to the
21332122 // bound that introduced the obligation (e.g. `T: Send`).
2134- debug ! ( "note_obligation_cause_for_async_await: next_code={:?}" , next_code) ;
2123+ debug ! ( ? next_code) ;
21352124 self . note_obligation_cause_code (
21362125 err,
21372126 & obligation. predicate ,
@@ -2688,20 +2677,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
26882677 ) ) ;
26892678 }
26902679
2680+ #[ instrument(
2681+ level = "debug" , skip( self , err) , fields( trait_pred. self_ty = ?trait_pred. self_ty( ) )
2682+ ) ]
26912683 fn suggest_await_before_try (
26922684 & self ,
26932685 err : & mut Diagnostic ,
26942686 obligation : & PredicateObligation < ' tcx > ,
26952687 trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
26962688 span : Span ,
26972689 ) {
2698- debug ! (
2699- "suggest_await_before_try: obligation={:?}, span={:?}, trait_pred={:?}, trait_pred_self_ty={:?}" ,
2700- obligation,
2701- span,
2702- trait_pred,
2703- trait_pred. self_ty( )
2704- ) ;
27052690 let body_hir_id = obligation. cause . body_id ;
27062691 let item_id = self . tcx . hir ( ) . get_parent_node ( body_hir_id) ;
27072692
@@ -2739,14 +2724,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
27392724 ) ;
27402725
27412726 debug ! (
2742- "suggest_await_before_try: normalized_projection_type {:?}" ,
2743- self . resolve_vars_if_possible( projection_ty)
2727+ normalized_projection_type = ?self . resolve_vars_if_possible( projection_ty)
27442728 ) ;
27452729 let try_obligation = self . mk_trait_obligation_with_new_self_ty (
27462730 obligation. param_env ,
27472731 trait_pred. map_bound ( |trait_pred| ( trait_pred, projection_ty. skip_binder ( ) ) ) ,
27482732 ) ;
2749- debug ! ( "suggest_await_before_try: try_trait_obligation {:?}" , try_obligation) ;
2733+ debug ! ( try_trait_obligation = ? try_obligation) ;
27502734 if self . predicate_may_hold ( & try_obligation)
27512735 && let Ok ( snippet) = self . tcx . sess . source_map ( ) . span_to_snippet ( span)
27522736 && snippet. ends_with ( '?' )
0 commit comments