Skip to content

Commit 38b6a66

Browse files
authored
Rollup merge of rust-lang#129858 - compiler-errors:async-def, r=cjgillot
Replace walk with visit so we dont skip outermost expr kind in def collector This affects async closures with macros as their body expr. Fixes rust-lang#129855. r? ``@cjgillot`` or anyone else
2 parents 3ea3397 + 7ab44cd commit 38b6a66

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: compiler/rustc_resolve/src/def_collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
223223
// we must create two defs.
224224
let coroutine_def =
225225
self.create_def(coroutine_kind.closure_id(), kw::Empty, DefKind::Closure, span);
226-
self.with_parent(coroutine_def, |this| visit::walk_expr(this, body));
226+
self.with_parent(coroutine_def, |this| this.visit_expr(body));
227227
}
228228
_ => visit::walk_fn(self, fn_kind),
229229
}

Diff for: tests/ui/async-await/async-closures/mac-body.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ edition: 2021
2+
//@ check-pass
3+
4+
#![feature(async_closure)]
5+
6+
// Make sure we don't ICE if an async closure has a macro body.
7+
// This happened because we were calling walk instead of visit
8+
// in the def collector, oops!
9+
10+
fn main() {
11+
let _ = async || println!();
12+
}

0 commit comments

Comments
 (0)