@@ -702,14 +702,28 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
702702 CStore :: from_tcx( tcx) . report_unused_deps( tcx) ;
703703 } ,
704704 {
705+ // Prefetch this as it is used later by the loop below
706+ // to prevent multiple threads from blocking on it.
707+ tcx. ensure_with_value( ) . get_lang_items( ( ) ) ;
708+
709+ let _timer = tcx. sess. timer( "misc_module_passes" ) ;
705710 tcx. hir( ) . par_for_each_module( |module| {
706711 tcx. ensure( ) . check_mod_loops( module) ;
707712 tcx. ensure( ) . check_mod_attrs( module) ;
708713 tcx. ensure( ) . check_mod_naked_functions( module) ;
709- tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
710714 tcx. ensure( ) . check_mod_const_bodies( module) ;
711715 } ) ;
712716 } ,
717+ {
718+ // Prefetch this as it is used later by the loop below
719+ // to prevent multiple threads from blocking on it.
720+ tcx. ensure_with_value( ) . stability_index( ( ) ) ;
721+
722+ let _timer = tcx. sess. timer( "check_unstable_api_usage" ) ;
723+ tcx. hir( ) . par_for_each_module( |module| {
724+ tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
725+ } ) ;
726+ } ,
713727 {
714728 sess. time( "unused_lib_feature_checking" , || {
715729 rustc_passes:: stability:: check_unused_or_stable_features( tcx)
@@ -729,32 +743,48 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
729743 // passes are timed inside typeck
730744 rustc_hir_analysis:: check_crate ( tcx) ?;
731745
732- sess. time ( "MIR_borrow_checking" , || {
733- tcx. hir ( ) . par_body_owners ( |def_id| {
734- // Run unsafety check because it's responsible for stealing and
735- // deallocating THIR.
736- tcx. ensure ( ) . check_unsafety ( def_id) ;
737- tcx. ensure ( ) . mir_borrowck ( def_id)
738- } ) ;
739- } ) ;
740-
741- sess. time ( "MIR_effect_checking" , || {
742- for def_id in tcx. hir ( ) . body_owners ( ) {
743- if !tcx. sess . opts . unstable_opts . thir_unsafeck {
744- rustc_mir_transform:: check_unsafety:: check_unsafety ( tcx, def_id) ;
745- }
746- tcx. ensure ( ) . has_ffi_unwind_calls ( def_id) ;
747-
748- // If we need to codegen, ensure that we emit all errors from
749- // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
750- // them later during codegen.
751- if tcx. sess . opts . output_types . should_codegen ( )
752- || tcx. hir ( ) . body_const_context ( def_id) . is_some ( )
746+ sess. time ( "misc_checking_2" , || {
747+ parallel ! (
753748 {
754- tcx. ensure ( ) . mir_drops_elaborated_and_const_checked ( def_id) ;
755- tcx. ensure ( ) . unused_generic_params ( ty:: InstanceDef :: Item ( def_id. to_def_id ( ) ) ) ;
749+ // Prefetch this as it is used later by lint checking and privacy checking.
750+ tcx. ensure_with_value( ) . effective_visibilities( ( ) ) ;
751+ } ,
752+ {
753+ sess. time( "MIR_borrow_checking" , || {
754+ tcx. hir( ) . par_body_owners( |def_id| {
755+ // Run unsafety check because it's responsible for stealing and
756+ // deallocating THIR.
757+ tcx. ensure( ) . check_unsafety( def_id) ;
758+ tcx. ensure( ) . mir_borrowck( def_id)
759+ } ) ;
760+ } ) ;
761+ } ,
762+ {
763+ sess. time( "MIR_effect_checking" , || {
764+ for def_id in tcx. hir( ) . body_owners( ) {
765+ if !tcx. sess. opts. unstable_opts. thir_unsafeck {
766+ rustc_mir_transform:: check_unsafety:: check_unsafety( tcx, def_id) ;
767+ }
768+ tcx. ensure( ) . has_ffi_unwind_calls( def_id) ;
769+
770+ // If we need to codegen, ensure that we emit all errors from
771+ // `mir_drops_elaborated_and_const_checked` now, to avoid discovering
772+ // them later during codegen.
773+ if tcx. sess. opts. output_types. should_codegen( )
774+ || tcx. hir( ) . body_const_context( def_id) . is_some( )
775+ {
776+ tcx. ensure( ) . mir_drops_elaborated_and_const_checked( def_id) ;
777+ tcx. ensure( )
778+ . unused_generic_params( ty:: InstanceDef :: Item ( def_id. to_def_id( ) ) ) ;
779+ }
780+ }
781+ } ) ;
782+ } ,
783+ {
784+ sess. time( "layout_testing" , || layout_test:: test_layout( tcx) ) ;
785+ sess. time( "abi_testing" , || abi_test:: test_abi( tcx) ) ;
756786 }
757- }
787+ )
758788 } ) ;
759789
760790 tcx. hir ( ) . par_body_owners ( |def_id| {
@@ -764,9 +794,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
764794 }
765795 } ) ;
766796
767- sess. time ( "layout_testing" , || layout_test:: test_layout ( tcx) ) ;
768- sess. time ( "abi_testing" , || abi_test:: test_abi ( tcx) ) ;
769-
770797 // Avoid overwhelming user with errors if borrow checking failed.
771798 // I'm not sure how helpful this is, to be honest, but it avoids a
772799 // lot of annoying errors in the ui tests (basically,
@@ -782,25 +809,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
782809 sess. time ( "misc_checking_3" , || {
783810 parallel ! (
784811 {
785- tcx. ensure( ) . effective_visibilities( ( ) ) ;
786-
787- parallel!(
788- {
789- tcx. ensure( ) . check_private_in_public( ( ) ) ;
790- } ,
791- {
792- tcx. hir( )
793- . par_for_each_module( |module| tcx. ensure( ) . check_mod_deathness( module) ) ;
794- } ,
795- {
796- sess. time( "lint_checking" , || {
797- rustc_lint:: check_crate( tcx) ;
798- } ) ;
799- } ,
800- {
801- tcx. ensure( ) . clashing_extern_declarations( ( ) ) ;
802- }
803- ) ;
812+ tcx. ensure( ) . check_private_in_public( ( ) ) ;
813+ } ,
814+ {
815+ tcx. hir( ) . par_for_each_module( |module| tcx. ensure( ) . check_mod_deathness( module) ) ;
816+ } ,
817+ {
818+ sess. time( "lint_checking" , || {
819+ rustc_lint:: check_crate( tcx) ;
820+ } ) ;
821+ } ,
822+ {
823+ tcx. ensure( ) . clashing_extern_declarations( ( ) ) ;
804824 } ,
805825 {
806826 sess. time( "privacy_checking_modules" , || {
0 commit comments