Skip to content

Commit 350f72f

Browse files
committed
Make wf checking parallel
1 parent 140a837 commit 350f72f

File tree

5 files changed

+20
-31
lines changed

5 files changed

+20
-31
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -695,26 +695,14 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> {
695695
pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> {
696696
tcx.sess.track_errors(|| {
697697
let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx);
698-
tcx.hir().krate().visit_all_item_likes(&mut visit);
699-
})
700-
}
701-
702-
pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> {
703-
tcx.sess.track_errors(|| {
704-
for &module in tcx.hir().krate().modules.keys() {
705-
tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module));
706-
}
698+
tcx.hir().krate().par_visit_all_item_likes(&mut visit);
707699
})
708700
}
709701

710702
fn check_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
711703
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx });
712704
}
713705

714-
pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> {
715-
tcx.typeck_item_bodies(LOCAL_CRATE)
716-
}
717-
718706
fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum)
719707
-> Result<(), ErrorReported>
720708
{

src/librustc_typeck/check/wfcheck.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use syntax::feature_gate::{self, GateIssue};
1414
use syntax_pos::Span;
1515
use errors::{DiagnosticBuilder, DiagnosticId};
1616

17-
use rustc::hir::itemlikevisit::ItemLikeVisitor;
17+
use rustc::hir::itemlikevisit::ParItemLikeVisitor;
1818
use rustc::hir;
1919

2020
/// Helper type of a temporary returned by `.for_item(...)`.
@@ -1015,20 +1015,20 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> {
10151015
}
10161016
}
10171017

1018-
impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'a, 'tcx> {
1019-
fn visit_item(&mut self, i: &'tcx hir::Item) {
1018+
impl<'a, 'tcx> ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'a, 'tcx> {
1019+
fn visit_item(&self, i: &'tcx hir::Item) {
10201020
debug!("visit_item: {:?}", i);
10211021
let def_id = self.tcx.hir().local_def_id_from_hir_id(i.hir_id);
10221022
self.tcx.ensure().check_item_well_formed(def_id);
10231023
}
10241024

1025-
fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
1025+
fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem) {
10261026
debug!("visit_trait_item: {:?}", trait_item);
10271027
let def_id = self.tcx.hir().local_def_id_from_hir_id(trait_item.hir_id);
10281028
self.tcx.ensure().check_trait_item_well_formed(def_id);
10291029
}
10301030

1031-
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
1031+
fn visit_impl_item(&self, impl_item: &'tcx hir::ImplItem) {
10321032
debug!("visit_impl_item: {:?}", impl_item);
10331033
let def_id = self.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
10341034
self.tcx.ensure().check_impl_item_well_formed(def_id);

src/librustc_typeck/coherence/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
141141
for &impl_id in impls {
142142
check_impl_overlap(tcx, impl_id);
143143
}
144-
use rustc::util::common::time;
145-
time(tcx.sess, "builtin::check_trait checking", ||
146-
builtin::check_trait(tcx, def_id));
144+
builtin::check_trait(tcx, def_id);
147145
}
148146

149147
pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {

src/librustc_typeck/collect.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ struct OnlySelfBounds(bool);
5656
///////////////////////////////////////////////////////////////////////////
5757
// Main entry point
5858

59-
pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
60-
for &module in tcx.hir().krate().modules.keys() {
61-
tcx.ensure().collect_mod_item_types(tcx.hir().local_def_id(module));
62-
}
63-
}
64-
6559
fn collect_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
6660
tcx.hir().visit_item_likes_in_module(
6761
module_def_id,

src/librustc_typeck/lib.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
322322
// this ensures that later parts of type checking can assume that items
323323
// have valid types and not error
324324
tcx.sess.track_errors(|| {
325-
time(tcx.sess, "type collecting", ||
326-
collect::collect_item_types(tcx));
325+
time(tcx.sess, "type collecting", || {
326+
for &module in tcx.hir().krate().modules.keys() {
327+
tcx.ensure().collect_mod_item_types(tcx.hir().local_def_id(module));
328+
}
329+
});
327330
})?;
328331

329332
if tcx.features().rustc_attrs {
@@ -352,9 +355,15 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
352355

353356
time(tcx.sess, "wf checking", || check::check_wf_new(tcx))?;
354357

355-
time(tcx.sess, "item-types checking", || check::check_item_types(tcx))?;
358+
time(tcx.sess, "item-types checking", || {
359+
tcx.sess.track_errors(|| {
360+
for &module in tcx.hir().krate().modules.keys() {
361+
tcx.ensure().check_mod_item_types(tcx.hir().local_def_id(module));
362+
}
363+
})
364+
})?;
356365

357-
time(tcx.sess, "item-bodies checking", || check::check_item_bodies(tcx))?;
366+
time(tcx.sess, "item-bodies checking", || tcx.typeck_item_bodies(LOCAL_CRATE))?;
358367

359368
check_unused::check_crate(tcx);
360369
check_for_entry_fn(tcx);

0 commit comments

Comments
 (0)