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