@@ -1263,10 +1263,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1263
1263
)
1264
1264
} ;
1265
1265
1266
- let push_target_span = |span : & mut MultiSpan | {
1266
+ let push_target_span_with_fallback = |span : & mut MultiSpan , fallback : & str | {
1267
1267
if target_ty. is_impl_trait ( ) {
1268
1268
// It's not very useful to tell the user the type if it's opaque.
1269
- span. push_span_label ( target_span, "created here" . to_string ( ) ) ;
1269
+ span. push_span_label ( target_span, fallback . to_string ( ) ) ;
1270
1270
} else {
1271
1271
span. push_span_label ( target_span, format ! ( "has type `{}`" , target_ty) ) ;
1272
1272
}
@@ -1275,10 +1275,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1275
1275
if let Some ( await_span) = from_awaited_ty {
1276
1276
// The type causing this obligation is one being awaited at await_span.
1277
1277
let mut span = MultiSpan :: from_span ( await_span) ;
1278
- span. push_span_label ( await_span, "await occurs here" . to_string ( ) ) ;
1279
1278
1280
- if target_span != await_span {
1281
- push_target_span ( & mut span) ;
1279
+ if target_span == await_span {
1280
+ push_target_span_with_fallback ( & mut span, "await occurs here" ) ;
1281
+ } else {
1282
+ span. push_span_label ( await_span, "await occurs here" . to_string ( ) ) ;
1283
+ push_target_span_with_fallback ( & mut span, "created here" ) ;
1282
1284
}
1283
1285
1284
1286
err. span_note (
@@ -1298,7 +1300,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1298
1300
format ! ( "{} occurs here, with `{}` maybe used later" , await_or_yield, snippet) ,
1299
1301
) ;
1300
1302
1301
- push_target_span ( & mut span) ;
1303
+ push_target_span_with_fallback ( & mut span, "created here" ) ;
1302
1304
1303
1305
// If available, use the scope span to annotate the drop location.
1304
1306
if let Some ( scope_span) = scope_span {
0 commit comments