File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -1447,9 +1447,7 @@ pub(super) fn check_type_params_are_used<'tcx>(
1447
1447
1448
1448
pub ( super ) fn check_mod_item_types ( tcx : TyCtxt < ' _ > , module_def_id : LocalModDefId ) {
1449
1449
let module = tcx. hir_module_items ( module_def_id) ;
1450
- for id in module. items ( ) {
1451
- check_item_type ( tcx, id) ;
1452
- }
1450
+ module. par_items ( |id| check_item_type ( tcx, id) ) ;
1453
1451
if module_def_id == LocalModDefId :: CRATE_DEF_ID {
1454
1452
super :: entry:: check_for_entry_fn ( tcx) ;
1455
1453
}
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ mod type_of;
50
50
// Main entry point
51
51
52
52
fn collect_mod_item_types ( tcx : TyCtxt < ' _ > , module_def_id : LocalModDefId ) {
53
- tcx. hir ( ) . visit_item_likes_in_module ( module_def_id, & mut CollectItemTypesVisitor { tcx } ) ;
53
+ tcx. hir ( ) . par_visit_item_likes_in_module ( module_def_id, || CollectItemTypesVisitor { tcx } ) ;
54
54
}
55
55
56
56
pub fn provide ( providers : & mut Providers ) {
Original file line number Diff line number Diff line change @@ -168,7 +168,11 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
168
168
// FIXME(matthewjasper) We shouldn't need to use `track_errors`.
169
169
tcx. sess . track_errors ( || {
170
170
tcx. sess . time ( "type_collecting" , || {
171
- tcx. hir ( ) . for_each_module ( |module| tcx. ensure ( ) . collect_mod_item_types ( module) )
171
+ // Run dependencies of type collecting before entering the loop
172
+ tcx. ensure_with_value ( ) . inferred_outlives_crate ( ( ) ) ;
173
+
174
+ let _prof_timer = tcx. sess . timer ( "type_collecting_loop" ) ;
175
+ tcx. hir ( ) . par_for_each_module ( |module| tcx. ensure ( ) . collect_mod_item_types ( module) ) ;
172
176
} ) ;
173
177
} ) ?;
174
178
Original file line number Diff line number Diff line change @@ -619,6 +619,34 @@ impl<'hir> Map<'hir> {
619
619
}
620
620
}
621
621
622
+ /// A parallel version of `visit_item_likes_in_module`.
623
+ pub fn par_visit_item_likes_in_module < V > (
624
+ & self ,
625
+ module : LocalModDefId ,
626
+ make_visitor : impl Fn ( ) -> V + DynSync ,
627
+ ) where
628
+ V : Visitor < ' hir > ,
629
+ {
630
+ let module = self . tcx . hir_module_items ( module) ;
631
+
632
+ parallel ! (
633
+ {
634
+ module. par_items( |id| make_visitor( ) . visit_item( self . item( id) ) ) ;
635
+ } ,
636
+ {
637
+ module. par_trait_items( |id| make_visitor( ) . visit_trait_item( self . trait_item( id) ) ) ;
638
+ } ,
639
+ {
640
+ module. par_impl_items( |id| make_visitor( ) . visit_impl_item( self . impl_item( id) ) ) ;
641
+ } ,
642
+ {
643
+ module. par_foreign_items( |id| {
644
+ make_visitor( ) . visit_foreign_item( self . foreign_item( id) )
645
+ } ) ;
646
+ }
647
+ ) ;
648
+ }
649
+
622
650
pub fn for_each_module ( self , mut f : impl FnMut ( LocalModDefId ) ) {
623
651
let crate_items = self . tcx . hir_crate_items ( ( ) ) ;
624
652
for module in crate_items. submodules . iter ( ) {
You can’t perform that action at this time.
0 commit comments