Skip to content

Move coroutine_by_move_body_def_id into the big check_crate body owner loop #141950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
let _: R = tcx.ensure_ok().crate_inherent_impls_overlap_check(());
});

// Make sure we evaluate all static and (non-associated) const items, even if unused.
// If any of these fail to evaluate, we do not want this crate to pass compilation.
tcx.par_hir_body_owners(|item_def_id| {
let def_kind = tcx.def_kind(item_def_id);
// Make sure we evaluate all static and (non-associated) const items, even if unused.
// If any of these fail to evaluate, we do not want this crate to pass compilation.
match def_kind {
DefKind::Static { .. } => {
tcx.ensure_ok().eval_static_initializer(item_def_id);
Expand All @@ -217,6 +217,11 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
if !matches!(def_kind, DefKind::AnonConst) {
tcx.ensure_ok().typeck(item_def_id);
}
// Ensure we generate the new `DefId` before finishing `check_crate`.
// Afterwards we freeze the list of `DefId`s.
if tcx.needs_coroutine_by_move_body_def_id(item_def_id.to_def_id()) {
tcx.ensure_done().coroutine_by_move_body_def_id(item_def_id);
}
});

if tcx.features().rustc_attrs() {
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,13 +981,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
});

rustc_hir_analysis::check_crate(tcx);
sess.time("MIR_coroutine_by_move_body", || {
tcx.par_hir_body_owners(|def_id| {
if tcx.needs_coroutine_by_move_body_def_id(def_id.to_def_id()) {
tcx.ensure_done().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
// for all coroutine-closures.
Expand Down
Loading