@@ -1378,10 +1378,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1378
1378
)
1379
1379
} ;
1380
1380
1381
- let push_target_span = |span : & mut MultiSpan | {
1381
+ let push_target_span_with_fallback = |span : & mut MultiSpan , fallback : & str | {
1382
1382
if target_ty. is_impl_trait ( ) {
1383
1383
// It's not very useful to tell the user the type if it's opaque.
1384
- span. push_span_label ( target_span, "created here" . to_string ( ) ) ;
1384
+ span. push_span_label ( target_span, fallback . to_string ( ) ) ;
1385
1385
} else {
1386
1386
span. push_span_label ( target_span, format ! ( "has type `{}`" , target_ty) ) ;
1387
1387
}
@@ -1390,10 +1390,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1390
1390
if let Some ( await_span) = from_awaited_ty {
1391
1391
// The type causing this obligation is one being awaited at await_span.
1392
1392
let mut span = MultiSpan :: from_span ( await_span) ;
1393
- span. push_span_label ( await_span, "await occurs here" . to_string ( ) ) ;
1394
1393
1395
- if target_span != await_span {
1396
- push_target_span ( & mut span) ;
1394
+ if target_span == await_span {
1395
+ push_target_span_with_fallback ( & mut span, "await occurs here" ) ;
1396
+ } else {
1397
+ span. push_span_label ( await_span, "await occurs here" . to_string ( ) ) ;
1398
+ push_target_span_with_fallback ( & mut span, "created here" ) ;
1397
1399
}
1398
1400
1399
1401
err. span_note (
@@ -1413,7 +1415,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1413
1415
format ! ( "{} occurs here, with `{}` maybe used later" , await_or_yield, snippet) ,
1414
1416
) ;
1415
1417
1416
- push_target_span ( & mut span) ;
1418
+ push_target_span_with_fallback ( & mut span, "created here" ) ;
1417
1419
1418
1420
// If available, use the scope span to annotate the drop location.
1419
1421
if let Some ( scope_span) = scope_span {
0 commit comments