about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-01-27 00:50:31 +0000
committerMichael Goulet <michael@errs.io>2024-01-27 19:39:02 +0000
commit5d8c1780fae725ce02a1c4619809347e55af67eb (patch)
tree14894eeb0f13a4eb46abe6825fb5b4a580d3b071 /compiler/rustc_resolve/src
parent6b4f1c5e782c72a047a23e922decd33e7d462345 (diff)
downloadrust-5d8c1780fae725ce02a1c4619809347e55af67eb.tar.gz
rust-5d8c1780fae725ce02a1c4619809347e55af67eb.zip
Make the coroutine def id of an async closure the child of the closure def id
Diffstat (limited to 'compiler/rustc_resolve/src')
-rw-r--r--compiler/rustc_resolve/src/def_collector.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs
index b77102c085c..42ace9bb22f 100644
--- a/compiler/rustc_resolve/src/def_collector.rs
+++ b/compiler/rustc_resolve/src/def_collector.rs
@@ -289,12 +289,18 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
                 // we must create two defs.
                 let closure_def = self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span);
                 match closure.coroutine_kind {
-                    Some(coroutine_kind) => self.create_def(
-                        coroutine_kind.closure_id(),
-                        kw::Empty,
-                        DefKind::Closure,
-                        expr.span,
-                    ),
+                    Some(coroutine_kind) => {
+                        self.with_parent(closure_def, |this| {
+                            let coroutine_def = this.create_def(
+                                coroutine_kind.closure_id(),
+                                kw::Empty,
+                                DefKind::Closure,
+                                expr.span,
+                            );
+                            this.with_parent(coroutine_def, |this| visit::walk_expr(this, expr));
+                        });
+                        return;
+                    }
                     None => closure_def,
                 }
             }