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>(
14471447
14481448pub ( super ) fn check_mod_item_types ( tcx : TyCtxt < ' _ > , module_def_id : LocalModDefId ) {
14491449 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) ) ;
14531451 if module_def_id == LocalModDefId :: CRATE_DEF_ID {
14541452 super :: entry:: check_for_entry_fn ( tcx) ;
14551453 }
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ mod type_of;
5050// Main entry point
5151
5252fn 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 } ) ;
5454}
5555
5656pub 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> {
168168 // FIXME(matthewjasper) We shouldn't need to use `track_errors`.
169169 tcx. sess . track_errors ( || {
170170 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) ) ;
172176 } ) ;
173177 } ) ?;
174178
Original file line number Diff line number Diff line change @@ -619,6 +619,34 @@ impl<'hir> Map<'hir> {
619619 }
620620 }
621621
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+
622650 pub fn for_each_module ( self , mut f : impl FnMut ( LocalModDefId ) ) {
623651 let crate_items = self . tcx . hir_crate_items ( ( ) ) ;
624652 for module in crate_items. submodules . iter ( ) {
You can’t perform that action at this time.
0 commit comments