Skip to content

Commit f07365d

Browse files
committed
Run item-types checking and item-bodies checking in parallel
1 parent b80fe0f commit f07365d

File tree

1 file changed

+23
-15
lines changed
  • compiler/rustc_hir_analysis/src

1 file changed

+23
-15
lines changed

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ mod outlives;
9595
pub mod structured_errors;
9696
mod variance;
9797

98+
use rustc_data_structures::sync::join;
9899
use rustc_errors::ErrorGuaranteed;
99100
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
100101
use rustc_fluent_macro::fluent_messages;
@@ -212,26 +213,33 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
212213
});
213214
})?;
214215

215-
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
216-
tcx.sess.time("item_types_checking", || {
217-
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
216+
tcx.sess.time("item_types_and_item_bodies_checking", || {
217+
join(
218+
|| {
219+
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
220+
tcx.sess.time("item_types_checking", || {
221+
tcx.hir()
222+
.par_for_each_module(|module| tcx.ensure().check_mod_item_types(module))
223+
});
224+
},
225+
|| {
226+
// FIXME: Remove this when we implement creating `DefId`s
227+
// for anon constants during their parents' typeck.
228+
// Typeck all body owners in parallel will produce queries
229+
// cycle errors because it may typeck on anon constants directly.
230+
tcx.hir().par_body_owners(|item_def_id| {
231+
let def_kind = tcx.def_kind(item_def_id);
232+
if !matches!(def_kind, DefKind::AnonConst) {
233+
tcx.ensure().typeck(item_def_id);
234+
}
235+
});
236+
},
237+
)
218238
});
219239

220240
// Freeze definitions as we don't add new ones at this point. This improves performance by
221241
// allowing lock-free access to them.
222242
tcx.untracked().definitions.freeze();
223-
224-
// FIXME: Remove this when we implement creating `DefId`s
225-
// for anon constants during their parents' typeck.
226-
// Typeck all body owners in parallel will produce queries
227-
// cycle errors because it may typeck on anon constants directly.
228-
tcx.hir().par_body_owners(|item_def_id| {
229-
let def_kind = tcx.def_kind(item_def_id);
230-
if !matches!(def_kind, DefKind::AnonConst) {
231-
tcx.ensure().typeck(item_def_id);
232-
}
233-
});
234-
235243
tcx.ensure().check_unused_traits(());
236244

237245
if let Some(reported) = tcx.sess.has_errors() { Err(reported) } else { Ok(()) }

0 commit comments

Comments
 (0)