Skip to content

Commit

Permalink
Unrolled build for rust-lang#129858
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rust-timer authored Sep 2, 2024
2 parents 9b82580 + 7ab44cd commit bcb9842
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/async-await/async-closures/mac-body.rs
Original file line number Diff line number Diff line change
@@ -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!();
}

0 comments on commit bcb9842

Please sign in to comment.