Skip to content

Commit 81cc1f5

Browse files
committed
fixup add gen blocks
1 parent f23e30e commit 81cc1f5

File tree

1 file changed

+5
-32
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+5
-32
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -682,59 +682,32 @@ impl<'hir> LoweringContext<'_, 'hir> {
682682
&mut self,
683683
capture_clause: CaptureBy,
684684
closure_node_id: NodeId,
685-
yield_ty: Option<hir::FnRetTy<'hir>>,
685+
_yield_ty: Option<hir::FnRetTy<'hir>>,
686686
span: Span,
687687
// We re-use the async enum, because we have the same cases.
688688
// FIXME(oli-obk): rename the enum.
689689
gen_kind: hir::AsyncGeneratorKind,
690690
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
691691
) -> hir::ExprKind<'hir> {
692-
let output = yield_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
693-
694-
// Resume argument type: `ResumeTy`
695-
let unstable_span =
696-
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
697-
let resume_ty = hir::QPath::LangItem(hir::LangItem::ResumeTy, unstable_span, None);
698-
let input_ty = hir::Ty {
699-
hir_id: self.next_id(),
700-
kind: hir::TyKind::Path(resume_ty),
701-
span: unstable_span,
702-
};
692+
let output = hir::FnRetTy::DefaultReturn(self.lower_span(span));
703693

704694
// The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`.
705695
let fn_decl = self.arena.alloc(hir::FnDecl {
706-
inputs: arena_vec![self; input_ty],
696+
inputs: &[],
707697
output,
708698
c_variadic: false,
709699
implicit_self: hir::ImplicitSelfKind::None,
710700
lifetime_elision_allowed: false,
711701
});
712702

713-
// Lower the argument pattern/ident. The ident is used again in the `.await` lowering.
714-
let (pat, task_context_hid) = self.pat_ident_binding_mode(
715-
span,
716-
Ident::with_dummy_span(sym::_task_context),
717-
hir::BindingAnnotation::MUT,
718-
);
719-
let param = hir::Param {
720-
hir_id: self.next_id(),
721-
pat,
722-
ty_span: self.lower_span(span),
723-
span: self.lower_span(span),
724-
};
725-
let params = arena_vec![self; param];
726-
727703
let body = self.lower_body(move |this| {
728704
this.generator_kind = Some(hir::GeneratorKind::Iter(gen_kind));
729705

730-
let old_ctx = this.task_context;
731-
this.task_context = Some(task_context_hid);
732706
let res = body(this);
733-
this.task_context = old_ctx;
734-
(params, res)
707+
(&[], res)
735708
});
736709

737-
// `static |_task_context| -> <ret_ty> { body }`:
710+
// `static |()| -> () { body }`:
738711
hir::ExprKind::Closure(self.arena.alloc(hir::Closure {
739712
def_id: self.local_def_id(closure_node_id),
740713
binder: hir::ClosureBinder::Default,

0 commit comments

Comments
 (0)