@@ -706,14 +706,28 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
706706 CStore :: from_tcx( tcx) . report_unused_deps( tcx) ;
707707 } ,
708708 {
709+ // Prefetch this as it is used later by the loop below
710+ // to prevent multiple threads from blocking on it.
711+ tcx. ensure_with_value( ) . get_lang_items( ( ) ) ;
712+
713+ let _timer = tcx. sess. timer( "misc_module_passes" ) ;
709714 tcx. hir( ) . par_for_each_module( |module| {
710715 tcx. ensure( ) . check_mod_loops( module) ;
711716 tcx. ensure( ) . check_mod_attrs( module) ;
712717 tcx. ensure( ) . check_mod_naked_functions( module) ;
713- tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
714718 tcx. ensure( ) . check_mod_const_bodies( module) ;
715719 } ) ;
716720 } ,
721+ {
722+ // Prefetch this as it is used later by the loop below
723+ // to prevent multiple threads from blocking on it.
724+ tcx. ensure_with_value( ) . stability_index( ( ) ) ;
725+
726+ let _timer = tcx. sess. timer( "check_unstable_api_usage" ) ;
727+ tcx. hir( ) . par_for_each_module( |module| {
728+ tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
729+ } ) ;
730+ } ,
717731 {
718732 sess. time( "unused_lib_feature_checking" , || {
719733 rustc_passes:: stability:: check_unused_or_stable_features( tcx)
@@ -733,32 +747,48 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
733747 // passes are timed inside typeck
734748 rustc_hir_analysis:: check_crate ( tcx) ?;
735749
736- sess. time ( "MIR_borrow_checking" , || {
737- tcx. hir ( ) . par_body_owners ( |def_id| {
738- // Run unsafety check because it's responsible for stealing and
739- // deallocating THIR.
740- tcx. ensure ( ) . check_unsafety ( def_id) ;
741- tcx. ensure ( ) . mir_borrowck ( def_id)
742- } ) ;
743- } ) ;
744-
745- sess. time ( "MIR_effect_checking" , || {
746- for def_id in tcx. hir ( ) . body_owners ( ) {
747- if !tcx. sess . opts . unstable_opts . thir_unsafeck {
748- rustc_mir_transform:: check_unsafety:: check_unsafety ( tcx, def_id) ;
749- }
750- tcx. ensure ( ) . has_ffi_unwind_calls ( def_id) ;
751-
752- // If we need to codegen, ensure that we emit all errors from
753- // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
754- // them later during codegen.
755- if tcx. sess . opts . output_types . should_codegen ( )
756- || tcx. hir ( ) . body_const_context ( def_id) . is_some ( )
750+ sess. time ( "misc_checking_2" , || {
751+ parallel ! (
757752 {
758- tcx. ensure ( ) . mir_drops_elaborated_and_const_checked ( def_id) ;
759- tcx. ensure ( ) . unused_generic_params ( ty:: InstanceDef :: Item ( def_id. to_def_id ( ) ) ) ;
753+ // Prefetch this as it is used later by lint checking and privacy checking.
754+ tcx. ensure_with_value( ) . effective_visibilities( ( ) ) ;
755+ } ,
756+ {
757+ sess. time( "MIR_borrow_checking" , || {
758+ tcx. hir( ) . par_body_owners( |def_id| {
759+ // Run unsafety check because it's responsible for stealing and
760+ // deallocating THIR.
761+ tcx. ensure( ) . check_unsafety( def_id) ;
762+ tcx. ensure( ) . mir_borrowck( def_id)
763+ } ) ;
764+ } ) ;
765+ } ,
766+ {
767+ sess. time( "MIR_effect_checking" , || {
768+ for def_id in tcx. hir( ) . body_owners( ) {
769+ if !tcx. sess. opts. unstable_opts. thir_unsafeck {
770+ rustc_mir_transform:: check_unsafety:: check_unsafety( tcx, def_id) ;
771+ }
772+ tcx. ensure( ) . has_ffi_unwind_calls( def_id) ;
773+
774+ // If we need to codegen, ensure that we emit all errors from
775+ // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
776+ // them later during codegen.
777+ if tcx. sess. opts. output_types. should_codegen( )
778+ || tcx. hir( ) . body_const_context( def_id) . is_some( )
779+ {
780+ tcx. ensure( ) . mir_drops_elaborated_and_const_checked( def_id) ;
781+ tcx. ensure( )
782+ . unused_generic_params( ty:: InstanceDef :: Item ( def_id. to_def_id( ) ) ) ;
783+ }
784+ }
785+ } ) ;
786+ } ,
787+ {
788+ sess. time( "layout_testing" , || layout_test:: test_layout( tcx) ) ;
789+ sess. time( "abi_testing" , || abi_test:: test_abi( tcx) ) ;
760790 }
761- }
791+ )
762792 } ) ;
763793
764794 tcx. hir ( ) . par_body_owners ( |def_id| {
@@ -768,9 +798,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
768798 }
769799 } ) ;
770800
771- sess. time ( "layout_testing" , || layout_test:: test_layout ( tcx) ) ;
772- sess. time ( "abi_testing" , || abi_test:: test_abi ( tcx) ) ;
773-
774801 // Avoid overwhelming user with errors if borrow checking failed.
775802 // I'm not sure how helpful this is, to be honest, but it avoids a
776803 // lot of annoying errors in the ui tests (basically,
@@ -783,25 +810,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
783810 sess. time ( "misc_checking_3" , || {
784811 parallel ! (
785812 {
786- tcx. ensure( ) . effective_visibilities( ( ) ) ;
787-
788- parallel!(
789- {
790- tcx. ensure( ) . check_private_in_public( ( ) ) ;
791- } ,
792- {
793- tcx. hir( )
794- . par_for_each_module( |module| tcx. ensure( ) . check_mod_deathness( module) ) ;
795- } ,
796- {
797- sess. time( "lint_checking" , || {
798- rustc_lint:: check_crate( tcx) ;
799- } ) ;
800- } ,
801- {
802- tcx. ensure( ) . clashing_extern_declarations( ( ) ) ;
803- }
804- ) ;
813+ tcx. ensure( ) . check_private_in_public( ( ) ) ;
814+ } ,
815+ {
816+ tcx. hir( ) . par_for_each_module( |module| tcx. ensure( ) . check_mod_deathness( module) ) ;
817+ } ,
818+ {
819+ sess. time( "lint_checking" , || {
820+ rustc_lint:: check_crate( tcx) ;
821+ } ) ;
822+ } ,
823+ {
824+ tcx. ensure( ) . clashing_extern_declarations( ( ) ) ;
805825 } ,
806826 {
807827 sess. time( "privacy_checking_modules" , || {
0 commit comments