@@ -521,7 +521,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
521521
522522 /// Desugar `<expr>.await` into:
523523 /// ```rust
524- /// match <expr> {
524+ /// match ::std::future::IntoFuture::into_future( <expr>) {
525525 /// mut pinned => loop {
526526 /// match ::std::future::poll_with_tls_context(unsafe {
527527 /// <::std::pin::Pin>::new_unchecked(&mut pinned)
@@ -645,11 +645,27 @@ impl<'hir> LoweringContext<'_, 'hir> {
645645 // mut pinned => loop { ... }
646646 let pinned_arm = self . arm ( pinned_pat, loop_expr) ;
647647
648- // match <expr> {
648+ // `match ::std::future::IntoFuture::into_future(<expr>) { ... }`
649+ let into_future_span = self . mark_span_with_reason (
650+ DesugaringKind :: Await ,
651+ await_span,
652+ self . allow_into_future . clone ( ) ,
653+ ) ;
654+ let expr = self . lower_expr_mut ( expr) ;
655+ let into_future_expr = self . expr_call_std_path (
656+ into_future_span,
657+ & [ sym:: future, sym:: IntoFuture , sym:: into_future] ,
658+ arena_vec ! [ self ; expr] ,
659+ ) ;
660+
661+ // match <into_future_expr> {
649662 // mut pinned => loop { .. }
650663 // }
651- let expr = self . lower_expr ( expr) ;
652- hir:: ExprKind :: Match ( expr, arena_vec ! [ self ; pinned_arm] , hir:: MatchSource :: AwaitDesugar )
664+ hir:: ExprKind :: Match (
665+ into_future_expr,
666+ arena_vec ! [ self ; pinned_arm] ,
667+ hir:: MatchSource :: AwaitDesugar ,
668+ )
653669 }
654670
655671 fn lower_expr_closure (
0 commit comments