Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mohe2015 committed Dec 24, 2023
1 parent 273734d commit bbe7ffa
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,30 @@ impl ExprCollector<'_> {
};
ClosureKind::Coroutine(crate::hir::CoroutineKind::Coroutine, movability)
} else if e.async_token().is_some() {
ClosureKind::Coroutine(
// https://github.com/compiler-errors/rust/blob/bd0eec74026d5f967afeadc3611bdb674a7b9de4/compiler/rustc_ast_lowering/src/expr.rs#L1199 ?

let capture_by =
if e.move_token().is_some() { CaptureBy::Value } else { CaptureBy::Ref };

let inner = Expr::Closure { args: Box::new([]), arg_types: Box::new([]), ret_type: ret_type.clone(), body, closure_kind: ClosureKind::Coroutine(
crate::hir::CoroutineKind::Desugared(
crate::hir::CoroutineDesugaring::Async,
crate::hir::CoroutineSource::Closure,
),
Movability::Movable,
)
), capture_by };
this.is_lowering_generator = prev_is_lowering_generator;
this.current_binding_owner = prev_binding_owner;
this.current_try_block_label = prev_try_block_label;
this.body.exprs[result_expr_id] = Expr::Closure {
args: args.into(),
arg_types: arg_types.into(),
ret_type,
body: this.alloc_expr_desugared(inner),
closure_kind: ClosureKind::Closure,
capture_by,
};
return result_expr_id
} else {
ClosureKind::Closure
};
Expand Down

0 comments on commit bbe7ffa

Please sign in to comment.