@@ -1735,16 +1735,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1735
1735
// | |
1736
1736
// LL | | foo(tx.clone());
1737
1737
// LL | | }).await;
1738
- // | | - ^^^^^^- value is later dropped here
1739
- // | | | |
1740
- // | |__________| await occurs here, with value maybe used later
1738
+ // | | - ^^^^^^ await occurs here, with value maybe used later
1739
+ // | |__________|
1741
1740
// | has type `closure` which is not `Send`
1741
+ // note: value is later dropped here
1742
+ // LL | | }).await;
1743
+ // | | ^
1742
1744
//
1743
- // If available, use the scope span to annotate the drop location.
1744
- if let Some ( scope_span) = scope_span {
1745
- let scope_span = source_map. end_point ( scope_span) ;
1746
- span. push_span_label ( scope_span, format ! ( "{} is later dropped here" , snippet) ) ;
1747
- }
1748
1745
span. push_span_label (
1749
1746
yield_span,
1750
1747
format ! ( "{} occurs here, with {} maybe used later" , await_or_yield, snippet) ,
@@ -1753,13 +1750,28 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1753
1750
interior_span,
1754
1751
format ! ( "has type `{}` which {}" , target_ty, trait_explanation) ,
1755
1752
) ;
1753
+ // If available, use the scope span to annotate the drop location.
1754
+ let mut scope_note = None ;
1755
+ if let Some ( scope_span) = scope_span {
1756
+ let scope_span = source_map. end_point ( scope_span) ;
1757
+
1758
+ let msg = format ! ( "{} is later dropped here" , snippet) ;
1759
+ if source_map. is_multiline ( yield_span. between ( scope_span) ) {
1760
+ span. push_span_label ( scope_span, msg) ;
1761
+ } else {
1762
+ scope_note = Some ( ( scope_span, msg) ) ;
1763
+ }
1764
+ }
1756
1765
err. span_note (
1757
1766
span,
1758
1767
& format ! (
1759
1768
"{} {} as this value is used across {}" ,
1760
1769
future_or_generator, trait_explanation, an_await_or_yield
1761
1770
) ,
1762
1771
) ;
1772
+ if let Some ( ( span, msg) ) = scope_note {
1773
+ err. span_note ( span, & msg) ;
1774
+ }
1763
1775
}
1764
1776
} ;
1765
1777
match interior_or_upvar_span {
0 commit comments