From e800b2fb57aa42003a80d68a502bd99c85e3dae4 Mon Sep 17 00:00:00 2001 From: Moritz Hedtke Date: Mon, 25 Dec 2023 00:51:32 +0100 Subject: [PATCH] wip --- crates/hir-def/src/body.rs | 2 +- crates/hir-def/src/body/lower.rs | 22 +--------------------- crates/hir-ty/src/tests/simple.rs | 4 ++-- 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs index d8749a97aabf..920cc23e3005 100644 --- a/crates/hir-def/src/body.rs +++ b/crates/hir-def/src/body.rs @@ -147,7 +147,7 @@ impl Body { }), ) }); - // TODO FIXME from here we know this only happens for functions, so maybe we can get the blockexpr directly and also onlive provide the keyword values then + // FIXME from here we know this only happens for functions, so maybe we can get the blockexpr directly and also onlive provide the keyword values then is_async_fn = data.has_async_kw(); is_gen_fn = data.has_gen_kw(); src.map(|it| it.body().map(ast::Expr::from)) diff --git a/crates/hir-def/src/body/lower.rs b/crates/hir-def/src/body/lower.rs index 25e1a69f9e61..da93e644bb79 100644 --- a/crates/hir-def/src/body/lower.rs +++ b/crates/hir-def/src/body/lower.rs @@ -217,27 +217,7 @@ impl ExprCollector<'_> { self.body.body_expr = self.with_label_rib(RibKind::Closure, |this| match (is_async_fn, is_gen_fn) { (false, false) => this.collect_expr_opt(body), - (false, true) => match body { - Some(e) => { - let expr = this.collect_expr(e); - - this.alloc_expr_desugared(Expr::Closure { - args: Box::new([]), - arg_types: Box::new([]), - ret_type: None, // FIXME maybe unspecified? - body: expr, - closure_kind: ClosureKind::Coroutine( - crate::hir::CoroutineKind::Desugared( - crate::hir::CoroutineDesugaring::Gen, - crate::hir::CoroutineSource::Fn, - ), - Movability::Movable, - ), - capture_by: CaptureBy::Ref, - }) - } - None => this.missing_expr(), - }, + (false, true) => this.collect_expr_opt(body), (true, false) => match body { Some(e) => { let expr = this.collect_expr(e); diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs index 874511b47c2d..722208f00a82 100644 --- a/crates/hir-ty/src/tests/simple.rs +++ b/crates/hir-ty/src/tests/simple.rs @@ -2149,7 +2149,7 @@ fn gen_yield_return_unit() { let mut g = gen { let () = yield; }; - + match g.next() { Some(()) => {} None => {} @@ -2186,7 +2186,7 @@ fn async_gen_yield_return_unit() { let mut g = async gen { let () = yield; }; - + match g.poll_next(&mut context) { Poll::Ready(()) => {} // FIXME test with 1 there I think this infers stuff it should not Poll::Pending => {}