Support async gen fn
This commit is contained in:
parent
2806c2df7b
commit
a208bae00e
16 changed files with 115 additions and 104 deletions
|
@ -2415,10 +2415,12 @@ pub enum Unsafe {
|
|||
/// Iterator`.
|
||||
#[derive(Copy, Clone, Encodable, Decodable, Debug)]
|
||||
pub enum CoroutineKind {
|
||||
/// `async`, which evaluates to `impl Future`
|
||||
/// `async`, which returns an `impl Future`
|
||||
Async { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
|
||||
/// `gen`, which evaluates to `impl Iterator`
|
||||
/// `gen`, which returns an `impl Iterator`
|
||||
Gen { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
|
||||
/// `async gen`, which returns an `impl AsyncIterator`
|
||||
AsyncGen { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
|
||||
}
|
||||
|
||||
impl CoroutineKind {
|
||||
|
@ -2435,7 +2437,10 @@ impl CoroutineKind {
|
|||
pub fn return_id(self) -> (NodeId, Span) {
|
||||
match self {
|
||||
CoroutineKind::Async { return_impl_trait_id, span, .. }
|
||||
| CoroutineKind::Gen { return_impl_trait_id, span, .. } => (return_impl_trait_id, span),
|
||||
| CoroutineKind::Gen { return_impl_trait_id, span, .. }
|
||||
| CoroutineKind::AsyncGen { return_impl_trait_id, span, .. } => {
|
||||
(return_impl_trait_id, span)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -874,7 +874,8 @@ pub fn noop_visit_closure_binder<T: MutVisitor>(binder: &mut ClosureBinder, vis:
|
|||
pub fn noop_visit_coroutine_kind<T: MutVisitor>(coroutine_kind: &mut CoroutineKind, vis: &mut T) {
|
||||
match coroutine_kind {
|
||||
CoroutineKind::Async { span, closure_id, return_impl_trait_id }
|
||||
| CoroutineKind::Gen { span, closure_id, return_impl_trait_id } => {
|
||||
| CoroutineKind::Gen { span, closure_id, return_impl_trait_id }
|
||||
| CoroutineKind::AsyncGen { span, closure_id, return_impl_trait_id } => {
|
||||
vis.visit_span(span);
|
||||
vis.visit_id(closure_id);
|
||||
vis.visit_id(return_impl_trait_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue