@@ -702,14 +702,28 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
702
702
CStore :: from_tcx( tcx) . report_unused_deps( tcx) ;
703
703
} ,
704
704
{
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" ) ;
705
710
tcx. hir( ) . par_for_each_module( |module| {
706
711
tcx. ensure( ) . check_mod_loops( module) ;
707
712
tcx. ensure( ) . check_mod_attrs( module) ;
708
713
tcx. ensure( ) . check_mod_naked_functions( module) ;
709
- tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
710
714
tcx. ensure( ) . check_mod_const_bodies( module) ;
711
715
} ) ;
712
716
} ,
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
+ } ,
713
727
{
714
728
sess. time( "unused_lib_feature_checking" , || {
715
729
rustc_passes:: stability:: check_unused_or_stable_features( tcx)
@@ -729,32 +743,48 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
729
743
// passes are timed inside typeck
730
744
rustc_hir_analysis:: check_crate ( tcx) ?;
731
745
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 ! (
753
748
{
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) ) ;
756
786
}
757
- }
787
+ )
758
788
} ) ;
759
789
760
790
tcx. hir ( ) . par_body_owners ( |def_id| {
@@ -764,9 +794,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
764
794
}
765
795
} ) ;
766
796
767
- sess. time ( "layout_testing" , || layout_test:: test_layout ( tcx) ) ;
768
- sess. time ( "abi_testing" , || abi_test:: test_abi ( tcx) ) ;
769
-
770
797
// Avoid overwhelming user with errors if borrow checking failed.
771
798
// I'm not sure how helpful this is, to be honest, but it avoids a
772
799
// lot of annoying errors in the ui tests (basically,
@@ -782,25 +809,18 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
782
809
sess. time ( "misc_checking_3" , || {
783
810
parallel ! (
784
811
{
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( ( ) ) ;
804
824
} ,
805
825
{
806
826
sess. time( "privacy_checking_modules" , || {
0 commit comments