From 4609841c078cde37c0e2ffb481059cb1bd330233 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 1 Aug 2024 13:05:17 -0400 Subject: Stop using a special inner body for the coroutine by-move body for async closures --- compiler/rustc_interface/src/passes.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 96a6f52d60b..2a4367965ee 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -784,7 +784,22 @@ fn run_required_analyses(tcx: TyCtxt<'_>) { } ); }); + rustc_hir_analysis::check_crate(tcx); + sess.time("MIR_coroutine_by_move_body", || { + tcx.hir().par_body_owners(|def_id| { + if tcx.needs_coroutine_by_move_body_def_id(def_id) { + tcx.ensure_with_value().coroutine_by_move_body_def_id(def_id); + } + }); + }); + // Freeze definitions as we don't add new ones at this point. + // We need to wait until now since we synthesize a by-move body + // This improves performance by allowing lock-free access to them. + // FIXME(async_closures): We could force `coroutine_by_move_body_def_id` + // immediately after typeck, then freeze after that. + tcx.untracked().definitions.freeze(); + sess.time("MIR_borrow_checking", || { tcx.hir().par_body_owners(|def_id| { // Run unsafety check because it's responsible for stealing and @@ -816,6 +831,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) { ); } }); + sess.time("layout_testing", || layout_test::test_layout(tcx)); sess.time("abi_testing", || abi_test::test_abi(tcx)); -- cgit 1.4.1-3-g733a5 From 93295ff6dc48782ea3114e98313836b266f3e54a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 7 Aug 2024 13:24:46 -0400 Subject: Remove some unnecessary TODOs --- compiler/rustc_interface/src/passes.rs | 2 -- compiler/rustc_metadata/src/rmeta/encoder.rs | 5 ----- 2 files changed, 7 deletions(-) (limited to 'compiler/rustc_interface/src') diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 2a4367965ee..779b98d073d 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -796,8 +796,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) { // Freeze definitions as we don't add new ones at this point. // We need to wait until now since we synthesize a by-move body // This improves performance by allowing lock-free access to them. - // FIXME(async_closures): We could force `coroutine_by_move_body_def_id` - // immediately after typeck, then freeze after that. tcx.untracked().definitions.freeze(); sess.time("MIR_borrow_checking", || { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 3125fb245e7..9c93726ca37 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1066,7 +1066,6 @@ fn should_encode_mir( } // Coroutines require optimized MIR to compute layout. DefKind::Closure if tcx.is_coroutine(def_id.to_def_id()) => (false, true), - // FIXME: lol DefKind::SyntheticCoroutineBody => (false, true), // Full-fledged functions + closures DefKind::AssocFn | DefKind::Fn | DefKind::Closure => { @@ -1379,10 +1378,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let def_span = tcx.def_span(local_id); record!(self.tables.def_span[def_id] <- def_span); } - // FIXME(async_closures): We should just use `tcx.attrs` rather than going - // through the HIR. Historically, though, this has been inefficient apparently. - // For now, it's kind of pointless to fix, because coroutine-closures' coroutine - // bodies have no attrs anyways. if should_encode_attrs(def_kind) { self.encode_attrs(local_id); } -- cgit 1.4.1-3-g733a5