Skip to content

Commit 2bc0d3f

Browse files
committed
Use a parallel block for coherence checking
1 parent 98d0f7d commit 2bc0d3f

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/librustc_typeck/coherence/mod.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,27 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) {
142142
}
143143

144144
pub fn check_coherence(tcx: TyCtxt<'_>) {
145-
par_for_each(&tcx.hir().krate().trait_impls, |(&trait_def_id, _)| {
146-
tcx.ensure().coherent_trait(trait_def_id);
147-
});
148-
149-
tcx.sess.time("unsafety_checking", || unsafety::check(tcx));
150-
tcx.sess.time("orphan_checking", || orphan::check(tcx));
151-
152-
// these queries are executed for side-effects (error reporting):
153-
tcx.ensure().crate_inherent_impls(LOCAL_CRATE);
154-
tcx.ensure().crate_inherent_impls_overlap_check(LOCAL_CRATE);
145+
parallel!(
146+
{
147+
par_for_each(&tcx.hir().krate().trait_impls, |(&trait_def_id, _)| {
148+
tcx.ensure().coherent_trait(trait_def_id);
149+
});
150+
},
151+
{
152+
tcx.sess.time("unsafety_checking", || unsafety::check(tcx));
153+
},
154+
{
155+
tcx.sess.time("orphan_checking", || orphan::check(tcx));
156+
},
157+
{
158+
// This query is executed for side-effects (error reporting)
159+
tcx.ensure().crate_inherent_impls(LOCAL_CRATE);
160+
},
161+
{
162+
// This query is executed for side-effects (error reporting)
163+
tcx.ensure().crate_inherent_impls_overlap_check(LOCAL_CRATE);
164+
}
165+
);
155166
}
156167

157168
/// Overlap: no two impls for the same trait are implemented for the

src/librustc_typeck/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ extern crate log;
7575
#[macro_use]
7676
extern crate rustc;
7777

78+
#[macro_use]
79+
extern crate rustc_data_structures;
80+
7881
// This is used by Clippy.
7982
pub mod expr_use_visitor;
8083

0 commit comments

Comments
 (0)