-
Notifications
You must be signed in to change notification settings - Fork 73
Desugar async blocks in HIR instead of MIR #997
Copy link
Copy link
Open
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teamfinal-comment-periodThe FCP has started, most (if not all) team members are in agreementThe FCP has started, most (if not all) team members are in agreementhas-concernsThere are active concernsThere are active concernsmajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustc
Metadata
Metadata
Assignees
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teamfinal-comment-periodThe FCP has started, most (if not all) team members are in agreementThe FCP has started, most (if not all) team members are in agreementhas-concernsThere are active concernsThere are active concernsmajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustc
Type
Fields
Give feedbackNo fields configured for issues without a type.
Proposal
In the current implementation,
gen/async/async genblocks and closures have typeCoroutine(..)andCoroutineClosure(..). Those types implementIterator,FutureorAsyncIteratordepending on the initial desugaring.This creates a lot of complexity:
I propose to change the desugaring for coroutines to:
gen { .. }becomesCoroutineIterator::from_coroutine(#[coroutine] { .. });async { .. }becomesCoroutineFuture::from_coroutine(#[coroutine] { .. });async gen { .. }becomesCoroutineAsyncIterator::from_coroutine(#[coroutine] { .. }).This way, all coroutines implement
std::ops::Coroutineandcoreis responsible for translating this to user-friendly traits. All the complexity is pushed to error-reporting code, which is not soundness-critical.Coroutine closures are a little more complex, as we need to keep the
CoroutineClosuretype for borrow-checking.Mentors or Reviewers
This involves MIR manipulation and trait solving, so @oli-obk and @lcnr need to know.
Process
The main points of the Major Change Process are as follows:
@rustbot secondor kickoff a team FCP with@rfcbot fcp $RESOLUTION.You can read more about Major Change Proposals on forge.
Caution
Concerns (1 active)
Managed by
@rustbot—see help for details.