Skip to content

Commit 0fdcfe1

Browse files
committed
Check Copy impls in parallel
1 parent 20fd50d commit 0fdcfe1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/librustc_typeck/coherence/builtin.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ use rustc::traits::{self, ObligationCause, TraitEngine};
1212
use rustc::ty::adjustment::CoerceUnsizedInfo;
1313
use rustc::ty::TypeFoldable;
1414
use rustc::ty::{self, Ty, TyCtxt};
15+
use rustc_data_structures::sync::par_for_each;
1516
use rustc_error_codes::*;
1617
use rustc_errors::struct_span_err;
1718
use rustc_hir as hir;
1819
use rustc_hir::def_id::DefId;
1920
use rustc_hir::ItemKind;
2021

2122
pub fn check_trait(tcx: TyCtxt<'_>, trait_def_id: DefId) {
23+
if Some(trait_def_id) == tcx.lang_items().copy_trait() {
24+
// Checking `Copy` impls can be expensive. Do it in parallel.
25+
let _timer = tcx.prof.generic_activity("check_implementations_of_copy");
26+
par_for_each(tcx.hir().trait_impls(trait_def_id), |&impl_id| {
27+
visit_implementation_of_copy(tcx, tcx.hir().local_def_id(impl_id));
28+
});
29+
}
30+
2231
Checker { tcx, trait_def_id }
2332
.check(tcx.lang_items().drop_trait(), visit_implementation_of_drop)
24-
.check(tcx.lang_items().copy_trait(), visit_implementation_of_copy)
2533
.check(tcx.lang_items().coerce_unsized_trait(), visit_implementation_of_coerce_unsized)
2634
.check(
2735
tcx.lang_items().dispatch_from_dyn_trait(),

0 commit comments

Comments
 (0)