@@ -593,7 +593,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
593593
594594 /// Desugar `<expr>.await` into:
595595 /// ```rust
596- /// match <expr> {
596+ /// match ::std::future::IntoFuture::into_future( <expr>) {
597597 /// mut pinned => loop {
598598 /// match unsafe { ::std::future::Future::poll(
599599 /// <::std::pin::Pin>::new_unchecked(&mut pinned),
@@ -629,7 +629,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
629629 await_span,
630630 self . allow_gen_future . clone ( ) ,
631631 ) ;
632- let expr = self . lower_expr ( expr) ;
632+ let expr = self . lower_expr_mut ( expr) ;
633633
634634 let pinned_ident = Ident :: with_dummy_span ( sym:: pinned) ;
635635 let ( pinned_pat, pinned_pat_hid) =
@@ -746,10 +746,26 @@ impl<'hir> LoweringContext<'_, 'hir> {
746746 // mut pinned => loop { ... }
747747 let pinned_arm = self . arm ( pinned_pat, loop_expr) ;
748748
749- // match <expr> {
750- // mut pinned => loop { .. }
749+ // `match ::std::future::IntoFuture::into_future(<expr>) { ... }`
750+ let into_future_span = self . mark_span_with_reason (
751+ DesugaringKind :: Await ,
752+ await_span,
753+ self . allow_into_future . clone ( ) ,
754+ ) ;
755+ //let expr = self.lower_expr_mut(expr);
756+ let into_future_expr = self . expr_call_lang_item_fn (
757+ into_future_span,
758+ hir:: LangItem :: IntoFutureIntoFuture ,
759+ arena_vec ! [ self ; expr] ,
760+ ) ;
761+
762+ // match <into_future_expr> { // mut pinned => loop { .. }
751763 // }
752- hir:: ExprKind :: Match ( expr, arena_vec ! [ self ; pinned_arm] , hir:: MatchSource :: AwaitDesugar )
764+ hir:: ExprKind :: Match (
765+ into_future_expr,
766+ arena_vec ! [ self ; pinned_arm] ,
767+ hir:: MatchSource :: AwaitDesugar ,
768+ )
753769 }
754770
755771 fn lower_expr_closure (
0 commit comments