@@ -1628,16 +1628,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1628
1628
/// ```
1629
1629
///
1630
1630
/// 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) ) ]
1631
1632
fn maybe_note_obligation_cause_for_async_await (
1632
1633
& self ,
1633
1634
err : & mut Diagnostic ,
1634
1635
obligation : & PredicateObligation < ' tcx > ,
1635
1636
) -> bool {
1636
- debug ! (
1637
- "maybe_note_obligation_cause_for_async_await: obligation.predicate={:?} \
1638
- obligation.cause.span={:?}",
1639
- obligation. predicate, obligation. cause. span
1640
- ) ;
1641
1637
let hir = self . tcx . hir ( ) ;
1642
1638
1643
1639
// 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> {
1677
1673
let mut seen_upvar_tys_infer_tuple = false ;
1678
1674
1679
1675
while let Some ( code) = next_code {
1680
- debug ! ( "maybe_note_obligation_cause_for_async_await: code={:?}" , code) ;
1676
+ debug ! ( ? code) ;
1681
1677
match code {
1682
1678
ObligationCauseCode :: FunctionArgumentObligation { parent_code, .. } => {
1683
1679
next_code = Some ( parent_code) ;
1684
1680
}
1685
1681
ObligationCauseCode :: ImplDerivedObligation ( cause) => {
1686
1682
let ty = cause. derived . parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
1687
1683
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" ,
1692
1687
) ;
1693
1688
1694
1689
match * ty. kind ( ) {
@@ -1717,10 +1712,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1717
1712
| ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation) => {
1718
1713
let ty = derived_obligation. parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
1719
1714
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( ) ,
1724
1717
) ;
1725
1718
1726
1719
match * ty. kind ( ) {
@@ -1750,7 +1743,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1750
1743
}
1751
1744
1752
1745
// 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) ;
1754
1747
let ( Some ( generator_did) , Some ( trait_ref) , Some ( target_ty) ) = ( generator, trait_ref, target_ty) else {
1755
1748
return false ;
1756
1749
} ;
@@ -1760,12 +1753,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1760
1753
let in_progress_typeck_results = self . in_progress_typeck_results . map ( |t| t. borrow ( ) ) ;
1761
1754
let generator_did_root = self . tcx . typeck_root_def_id ( generator_did) ;
1762
1755
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,
1769
1760
) ;
1770
1761
1771
1762
let generator_body = generator_did
@@ -1788,7 +1779,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1788
1779
if let Some ( body) = generator_body {
1789
1780
visitor. visit_body ( body) ;
1790
1781
}
1791
- debug ! ( "maybe_note_obligation_cause_for_async_await: awaits = {:?}" , visitor. awaits) ;
1782
+ debug ! ( awaits = ? visitor. awaits) ;
1792
1783
1793
1784
// Look for a type inside the generator interior that matches the target type to get
1794
1785
// a span.
@@ -1809,11 +1800,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1809
1800
let ty_erased = self . tcx . erase_late_bound_regions ( ty) ;
1810
1801
let ty_erased = self . tcx . erase_regions ( ty_erased) ;
1811
1802
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) ;
1817
1804
eq
1818
1805
} ;
1819
1806
@@ -1888,6 +1875,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1888
1875
1889
1876
/// Unconditionally adds the diagnostic note described in
1890
1877
/// `maybe_note_obligation_cause_for_async_await`'s documentation comment.
1878
+ #[ instrument( level = "debug" , skip_all) ]
1891
1879
fn note_obligation_cause_for_async_await (
1892
1880
& self ,
1893
1881
err : & mut Diagnostic ,
@@ -2037,8 +2025,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2037
2025
} else {
2038
2026
// Look at the last interior type to get a span for the `.await`.
2039
2027
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
+ ) ,
2042
2031
) ;
2043
2032
explain_yield ( interior_span, yield_span, scope_span) ;
2044
2033
}
@@ -2073,7 +2062,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2073
2062
// bar(Foo(std::ptr::null())).await;
2074
2063
// ^^^^^^^^^^^^^^^^^^^^^ raw-ptr `*T` created inside this struct ctor.
2075
2064
// ```
2076
- debug ! ( " parent_def_kind: {:?}" , self . tcx. def_kind( parent_did) ) ;
2065
+ debug ! ( parent_def_kind = ? self . tcx. def_kind( parent_did) ) ;
2077
2066
let is_raw_borrow_inside_fn_like_call =
2078
2067
match self . tcx . def_kind ( parent_did) {
2079
2068
DefKind :: Fn | DefKind :: Ctor ( ..) => target_ty. is_unsafe_ptr ( ) ,
@@ -2131,7 +2120,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2131
2120
2132
2121
// Add a note for the item obligation that remains - normally a note pointing to the
2133
2122
// 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) ;
2135
2124
self . note_obligation_cause_code (
2136
2125
err,
2137
2126
& obligation. predicate ,
@@ -2688,20 +2677,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2688
2677
) ) ;
2689
2678
}
2690
2679
2680
+ #[ instrument(
2681
+ level = "debug" , skip( self , err) , fields( trait_pred. self_ty = ?trait_pred. self_ty( ) )
2682
+ ) ]
2691
2683
fn suggest_await_before_try (
2692
2684
& self ,
2693
2685
err : & mut Diagnostic ,
2694
2686
obligation : & PredicateObligation < ' tcx > ,
2695
2687
trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
2696
2688
span : Span ,
2697
2689
) {
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
- ) ;
2705
2690
let body_hir_id = obligation. cause . body_id ;
2706
2691
let item_id = self . tcx . hir ( ) . get_parent_node ( body_hir_id) ;
2707
2692
@@ -2739,14 +2724,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2739
2724
) ;
2740
2725
2741
2726
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)
2744
2728
) ;
2745
2729
let try_obligation = self . mk_trait_obligation_with_new_self_ty (
2746
2730
obligation. param_env ,
2747
2731
trait_pred. map_bound ( |trait_pred| ( trait_pred, projection_ty. skip_binder ( ) ) ) ,
2748
2732
) ;
2749
- debug ! ( "suggest_await_before_try: try_trait_obligation {:?}" , try_obligation) ;
2733
+ debug ! ( try_trait_obligation = ? try_obligation) ;
2750
2734
if self . predicate_may_hold ( & try_obligation)
2751
2735
&& let Ok ( snippet) = self . tcx . sess . source_map ( ) . span_to_snippet ( span)
2752
2736
&& snippet. ends_with ( '?' )
0 commit comments