@@ -593,7 +593,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
593
593
594
594
/// Desugar `<expr>.await` into:
595
595
/// ```rust
596
- /// match <expr> {
596
+ /// match ::std::future::IntoFuture::into_future( <expr>) {
597
597
/// mut pinned => loop {
598
598
/// match unsafe { ::std::future::Future::poll(
599
599
/// <::std::pin::Pin>::new_unchecked(&mut pinned),
@@ -629,7 +629,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
629
629
await_span,
630
630
self . allow_gen_future . clone ( ) ,
631
631
) ;
632
- let expr = self . lower_expr ( expr) ;
632
+ let expr = self . lower_expr_mut ( expr) ;
633
633
634
634
let pinned_ident = Ident :: with_dummy_span ( sym:: pinned) ;
635
635
let ( pinned_pat, pinned_pat_hid) =
@@ -746,10 +746,26 @@ impl<'hir> LoweringContext<'_, 'hir> {
746
746
// mut pinned => loop { ... }
747
747
let pinned_arm = self . arm ( pinned_pat, loop_expr) ;
748
748
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 { .. }
751
763
// }
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
+ )
753
769
}
754
770
755
771
fn lower_expr_closure (
0 commit comments