@@ -125,6 +125,7 @@ pub trait InferCtxtExt<'tcx> {
125125 err : & mut DiagnosticBuilder < ' _ > ,
126126 target_span : Span ,
127127 scope_span : & Option < Span > ,
128+ await_span : Span ,
128129 expr : Option < hir:: HirId > ,
129130 snippet : String ,
130131 inner_generator_body : Option < & hir:: Body < ' _ > > ,
@@ -1260,20 +1261,31 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12601261 ty_matches ( ty)
12611262 } )
12621263 . 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+ )
12651274 } ) ;
12661275
12671276 debug ! (
12681277 "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
12711280 ) ;
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+ {
12731284 self . note_obligation_cause_for_async_await (
12741285 err,
12751286 * target_span,
12761287 scope_span,
1288+ await_span,
12771289 * expr,
12781290 snippet,
12791291 generator_body,
@@ -1298,6 +1310,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
12981310 err : & mut DiagnosticBuilder < ' _ > ,
12991311 target_span : Span ,
13001312 scope_span : & Option < Span > ,
1313+ await_span : Span ,
13011314 expr : Option < hir:: HirId > ,
13021315 snippet : String ,
13031316 inner_generator_body : Option < & hir:: Body < ' _ > > ,
@@ -1373,12 +1386,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13731386 if let Some ( await_span) = from_awaited_ty {
13741387 // The type causing this obligation is one being awaited at await_span.
13751388 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-
13821389 err. span_note (
13831390 span,
13841391 & format ! (
@@ -1392,7 +1399,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
13921399 "note_obligation_cause_for_async_await generator_interior_types: {:#?}" ,
13931400 tables. generator_interior_types
13941401 ) ;
1395- let await_span = tables. generator_interior_types . iter ( ) . map ( |t| t. span ) . last ( ) . unwrap ( ) ;
13961402 let mut span = MultiSpan :: from_span ( await_span) ;
13971403 span. push_span_label (
13981404 await_span,
0 commit comments