Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mohe2015 committed Dec 24, 2023
1 parent a02385a commit e800b2f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
22 changes: 1 addition & 21 deletions crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/tests/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2149,7 +2149,7 @@ fn gen_yield_return_unit() {
let mut g = gen {
let () = yield;
};
match g.next() {
Some(()) => {}
None => {}
Expand Down Expand Up @@ -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 => {}
Expand Down

0 comments on commit e800b2f

Please sign in to comment.