@@ -125,6 +125,7 @@ pub trait InferCtxtExt<'tcx> {
125
125
err : & mut DiagnosticBuilder < ' _ > ,
126
126
target_span : Span ,
127
127
scope_span : & Option < Span > ,
128
+ await_span : Span ,
128
129
expr : Option < hir:: HirId > ,
129
130
snippet : String ,
130
131
inner_generator_body : Option < & hir:: Body < ' _ > > ,
@@ -1260,20 +1261,31 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1260
1261
ty_matches ( ty)
1261
1262
} )
1262
1263
. map ( |expr| expr. span ) ;
1263
- let ty:: GeneratorInteriorTypeCause { span, scope_span, expr, .. } = cause;
1264
- ( span, source_map. span_to_snippet ( * span) , scope_span, expr, from_awaited_ty)
1264
+ let ty:: GeneratorInteriorTypeCause { span, scope_span, await_span, expr, .. } =
1265
+ cause;
1266
+ (
1267
+ span,
1268
+ source_map. span_to_snippet ( * span) ,
1269
+ scope_span,
1270
+ await_span,
1271
+ expr,
1272
+ from_awaited_ty,
1273
+ )
1265
1274
} ) ;
1266
1275
1267
1276
debug ! (
1268
1277
"maybe_note_obligation_cause_for_async_await: target_ty={:?} \
1269
- generator_interior_types={:?} target_span={:?}",
1270
- target_ty, tables. generator_interior_types, target_span
1278
+ generator_interior_types={:?} target_span={:?} await_span={:?} ",
1279
+ target_ty, tables. generator_interior_types, target_span, await_span
1271
1280
) ;
1272
- if let Some ( ( target_span, Ok ( snippet) , scope_span, expr, from_awaited_ty) ) = target_span {
1281
+ if let Some ( ( target_span, Ok ( snippet) , scope_span, await_span, expr, from_awaited_ty) ) =
1282
+ target_span
1283
+ {
1273
1284
self . note_obligation_cause_for_async_await (
1274
1285
err,
1275
1286
* target_span,
1276
1287
scope_span,
1288
+ await_span,
1277
1289
* expr,
1278
1290
snippet,
1279
1291
generator_body,
@@ -1298,6 +1310,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1298
1310
err : & mut DiagnosticBuilder < ' _ > ,
1299
1311
target_span : Span ,
1300
1312
scope_span : & Option < Span > ,
1313
+ await_span : Span ,
1301
1314
expr : Option < hir:: HirId > ,
1302
1315
snippet : String ,
1303
1316
inner_generator_body : Option < & hir:: Body < ' _ > > ,
@@ -1373,12 +1386,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1373
1386
if let Some ( await_span) = from_awaited_ty {
1374
1387
// The type causing this obligation is one being awaited at await_span.
1375
1388
let mut span = MultiSpan :: from_span ( await_span) ;
1376
-
1377
- span. push_span_label (
1378
- await_span,
1379
- format ! ( "await occurs here on type `{}`, which {}" , target_ty, trait_explanation) ,
1380
- ) ;
1381
-
1382
1389
err. span_note (
1383
1390
span,
1384
1391
& format ! (
@@ -1392,7 +1399,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
1392
1399
"note_obligation_cause_for_async_await generator_interior_types: {:#?}" ,
1393
1400
tables. generator_interior_types
1394
1401
) ;
1395
- let await_span = tables. generator_interior_types . iter ( ) . map ( |t| t. span ) . last ( ) . unwrap ( ) ;
1396
1402
let mut span = MultiSpan :: from_span ( await_span) ;
1397
1403
span. push_span_label (
1398
1404
await_span,
0 commit comments