diff options
| author | Eric Holk <ericholk@microsoft.com> | 2023-11-30 14:54:39 -0800 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2023-12-04 12:48:01 -0800 |
| commit | 48d5f1f0f26b78f76c5fcf0dda5ac93b8754aeb6 (patch) | |
| tree | 09280f2a00a4e2fd4e7a8f3a3c49062239a64409 /compiler/rustc_resolve/src | |
| parent | 3887b1645aaa85e2755a54ab91f40c4fedc1dc0f (diff) | |
| download | rust-48d5f1f0f26b78f76c5fcf0dda5ac93b8754aeb6.tar.gz rust-48d5f1f0f26b78f76c5fcf0dda5ac93b8754aeb6.zip | |
Merge Async and Gen into CoroutineKind
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/def_collector.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/late.rs | 6 |
2 files changed, 9 insertions, 8 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 306492eaa96..c43ec99f42a 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -157,8 +157,8 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { if let FnKind::Fn(_, _, sig, _, generics, body) = fn_kind { // FIXME(eholk): handle `async gen fn` - if let (Async::Yes { closure_id, .. }, _) | (_, Gen::Yes { closure_id, .. }) = - (sig.header.asyncness, sig.header.genness) + if let CoroutineKind::Async { closure_id, .. } | CoroutineKind::Gen { closure_id, .. } = + sig.header.coro_kind { self.visit_generics(generics); @@ -284,11 +284,12 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> { // Async closures desugar to closures inside of closures, so // we must create two defs. let closure_def = self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span); - match closure.asyncness { - Async::Yes { closure_id, .. } => { + match closure.coro_kind { + CoroutineKind::Async { closure_id, .. } + | CoroutineKind::Gen { closure_id, .. } => { self.create_def(closure_id, kw::Empty, DefKind::Closure, expr.span) } - Async::No => closure_def, + CoroutineKind::None => closure_def, } } ExprKind::Gen(_, _, _) => { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index f20d5829030..2f7d1835113 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -916,7 +916,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast, &sig.decl.output, ); - if let Some((async_node_id, _)) = sig.header.asyncness.opt_return_id() { + if let Some((async_node_id, _)) = sig.header.coro_kind.opt_return_id() { this.record_lifetime_params_for_impl_trait(async_node_id); } }, @@ -940,7 +940,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast, this.visit_generics(generics); let declaration = &sig.decl; - let async_node_id = sig.header.asyncness.opt_return_id(); + let async_node_id = sig.header.coro_kind.opt_return_id(); this.with_lifetime_rib( LifetimeRibKind::AnonymousCreateParameter { @@ -4289,7 +4289,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { // resolve the arguments within the proper scopes so that usages of them inside the // closure are detected as upvars rather than normal closure arg usages. ExprKind::Closure(box ast::Closure { - asyncness: Async::Yes { .. }, + coro_kind: CoroutineKind::Async { .. }, ref fn_decl, ref body, .. |
