@@ -1623,16 +1623,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1623
1623
/// ```
1624
1624
///
1625
1625
/// 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) ) ]
1626
1627
fn maybe_note_obligation_cause_for_async_await (
1627
1628
& self ,
1628
1629
err : & mut Diagnostic ,
1629
1630
obligation : & PredicateObligation < ' tcx > ,
1630
1631
) -> bool {
1631
- debug ! (
1632
- "maybe_note_obligation_cause_for_async_await: obligation.predicate={:?} \
1633
- obligation.cause.span={:?}",
1634
- obligation. predicate, obligation. cause. span
1635
- ) ;
1636
1632
let hir = self . tcx . hir ( ) ;
1637
1633
1638
1634
// 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> {
1672
1668
let mut seen_upvar_tys_infer_tuple = false ;
1673
1669
1674
1670
while let Some ( code) = next_code {
1675
- debug ! ( "maybe_note_obligation_cause_for_async_await: code={:?}" , code) ;
1671
+ debug ! ( ? code) ;
1676
1672
match code {
1677
1673
ObligationCauseCode :: FunctionArgumentObligation { parent_code, .. } => {
1678
1674
next_code = Some ( parent_code) ;
1679
1675
}
1680
1676
ObligationCauseCode :: ImplDerivedObligation ( cause) => {
1681
1677
let ty = cause. derived . parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
1682
1678
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" ,
1687
1682
) ;
1688
1683
1689
1684
match * ty. kind ( ) {
@@ -1712,10 +1707,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1712
1707
| ObligationCauseCode :: BuiltinDerivedObligation ( derived_obligation) => {
1713
1708
let ty = derived_obligation. parent_trait_pred . skip_binder ( ) . self_ty ( ) ;
1714
1709
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( ) ,
1719
1712
) ;
1720
1713
1721
1714
match * ty. kind ( ) {
@@ -1745,7 +1738,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1745
1738
}
1746
1739
1747
1740
// 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) ;
1749
1742
let ( Some ( generator_did) , Some ( trait_ref) , Some ( target_ty) ) = ( generator, trait_ref, target_ty) else {
1750
1743
return false ;
1751
1744
} ;
@@ -1755,12 +1748,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1755
1748
let in_progress_typeck_results = self . in_progress_typeck_results . map ( |t| t. borrow ( ) ) ;
1756
1749
let generator_did_root = self . tcx . typeck_root_def_id ( generator_did) ;
1757
1750
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,
1764
1755
) ;
1765
1756
1766
1757
let generator_body = generator_did
@@ -1783,7 +1774,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1783
1774
if let Some ( body) = generator_body {
1784
1775
visitor. visit_body ( body) ;
1785
1776
}
1786
- debug ! ( "maybe_note_obligation_cause_for_async_await: awaits = {:?}" , visitor. awaits) ;
1777
+ debug ! ( awaits = ? visitor. awaits) ;
1787
1778
1788
1779
// Look for a type inside the generator interior that matches the target type to get
1789
1780
// a span.
@@ -1804,11 +1795,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1804
1795
let ty_erased = self . tcx . erase_late_bound_regions ( ty) ;
1805
1796
let ty_erased = self . tcx . erase_regions ( ty_erased) ;
1806
1797
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) ;
1812
1799
eq
1813
1800
} ;
1814
1801
@@ -1883,6 +1870,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1883
1870
1884
1871
/// Unconditionally adds the diagnostic note described in
1885
1872
/// `maybe_note_obligation_cause_for_async_await`'s documentation comment.
1873
+ #[ instrument( level = "debug" , skip_all) ]
1886
1874
fn note_obligation_cause_for_async_await (
1887
1875
& self ,
1888
1876
err : & mut Diagnostic ,
@@ -2032,8 +2020,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2032
2020
} else {
2033
2021
// Look at the last interior type to get a span for the `.await`.
2034
2022
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
+ ) ,
2037
2026
) ;
2038
2027
explain_yield ( interior_span, yield_span, scope_span) ;
2039
2028
}
@@ -2068,7 +2057,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2068
2057
// bar(Foo(std::ptr::null())).await;
2069
2058
// ^^^^^^^^^^^^^^^^^^^^^ raw-ptr `*T` created inside this struct ctor.
2070
2059
// ```
2071
- debug ! ( " parent_def_kind: {:?}" , self . tcx. def_kind( parent_did) ) ;
2060
+ debug ! ( parent_def_kind = ? self . tcx. def_kind( parent_did) ) ;
2072
2061
let is_raw_borrow_inside_fn_like_call =
2073
2062
match self . tcx . def_kind ( parent_did) {
2074
2063
DefKind :: Fn | DefKind :: Ctor ( ..) => target_ty. is_unsafe_ptr ( ) ,
@@ -2126,7 +2115,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2126
2115
2127
2116
// Add a note for the item obligation that remains - normally a note pointing to the
2128
2117
// 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) ;
2130
2119
self . note_obligation_cause_code (
2131
2120
err,
2132
2121
& obligation. predicate ,
@@ -2683,20 +2672,16 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2683
2672
) ) ;
2684
2673
}
2685
2674
2675
+ #[ instrument(
2676
+ level = "debug" , skip( self , err) , fields( trait_pred. self_ty = ?trait_pred. self_ty( ) )
2677
+ ) ]
2686
2678
fn suggest_await_before_try (
2687
2679
& self ,
2688
2680
err : & mut Diagnostic ,
2689
2681
obligation : & PredicateObligation < ' tcx > ,
2690
2682
trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
2691
2683
span : Span ,
2692
2684
) {
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
- ) ;
2700
2685
let body_hir_id = obligation. cause . body_id ;
2701
2686
let item_id = self . tcx . hir ( ) . get_parent_node ( body_hir_id) ;
2702
2687
@@ -2734,14 +2719,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
2734
2719
) ;
2735
2720
2736
2721
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)
2739
2723
) ;
2740
2724
let try_obligation = self . mk_trait_obligation_with_new_self_ty (
2741
2725
obligation. param_env ,
2742
2726
trait_pred. map_bound ( |trait_pred| ( trait_pred, projection_ty. skip_binder ( ) ) ) ,
2743
2727
) ;
2744
- debug ! ( "suggest_await_before_try: try_trait_obligation {:?}" , try_obligation) ;
2728
+ debug ! ( try_trait_obligation = ? try_obligation) ;
2745
2729
if self . predicate_may_hold ( & try_obligation)
2746
2730
&& let Ok ( snippet) = self . tcx . sess . source_map ( ) . span_to_snippet ( span)
2747
2731
&& snippet. ends_with ( '?' )
0 commit comments