about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-09-01 11:16:50 -0400
committerMichael Goulet <michael@errs.io>2024-09-01 11:16:50 -0400
commit7ab44cddc9320f1dfdef40916f33c6f3e83876e6 (patch)
tree0846cdcaafa7a1fe8a7e4ec2a84fa365eadd8a77
parent1a1cc050d8efc906ede39f444936ade1fdc9c6cb (diff)
downloadrust-7ab44cddc9320f1dfdef40916f33c6f3e83876e6.tar.gz
rust-7ab44cddc9320f1dfdef40916f33c6f3e83876e6.zip
Replace walk with visit so we dont skip outermost expr kind in def collector
-rw-r--r--compiler/rustc_resolve/src/def_collector.rs2
-rw-r--r--tests/ui/async-await/async-closures/mac-body.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs
index a70d51606f7..0fedb998463 100644
--- a/compiler/rustc_resolve/src/def_collector.rs
+++ b/compiler/rustc_resolve/src/def_collector.rs
@@ -223,7 +223,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
                 // we must create two defs.
                 let coroutine_def =
                     self.create_def(coroutine_kind.closure_id(), kw::Empty, DefKind::Closure, span);
-                self.with_parent(coroutine_def, |this| visit::walk_expr(this, body));
+                self.with_parent(coroutine_def, |this| this.visit_expr(body));
             }
             _ => visit::walk_fn(self, fn_kind),
         }
diff --git a/tests/ui/async-await/async-closures/mac-body.rs b/tests/ui/async-await/async-closures/mac-body.rs
new file mode 100644
index 00000000000..a416227c390
--- /dev/null
+++ b/tests/ui/async-await/async-closures/mac-body.rs
@@ -0,0 +1,12 @@
+//@ edition: 2021
+//@ check-pass
+
+#![feature(async_closure)]
+
+// Make sure we don't ICE if an async closure has a macro body.
+// This happened because we were calling walk instead of visit
+// in the def collector, oops!
+
+fn main() {
+    let _ = async || println!();
+}