@@ -746,6 +746,8 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
746746 tcx. ensure ( ) . hir_crate_items ( ( ) ) ;
747747 tcx. ensure ( ) . stability_index ( ( ) ) ;
748748
749+ let has_cache = tcx. query_system . on_disk_cache . as_ref ( ) . map ( |cache| cache. has_cache ( ) ) . unwrap_or ( false ) ;
750+
749751 rustc_passes:: hir_id_validator:: check_crate ( tcx) ;
750752
751753 let sess = tcx. sess ;
@@ -763,13 +765,24 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
763765 CStore :: from_tcx( tcx) . report_unused_deps( tcx) ;
764766 } ,
765767 {
766- tcx. hir( ) . par_for_each_module( |module| {
768+ if has_cache {
769+ tcx. hir( ) . for_each_module( |module| {
770+ tcx. ensure( ) . check_mod_loops( module) ;
771+ tcx. ensure( ) . check_mod_attrs( module) ;
772+ tcx. ensure( ) . check_mod_naked_functions( module) ;
773+ tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
774+ tcx. ensure( ) . check_mod_const_bodies( module) ;
775+ } ) ;
776+ } else {
777+ tcx. hir( ) . par_for_each_module( |module| {
767778 tcx. ensure( ) . check_mod_loops( module) ;
768779 tcx. ensure( ) . check_mod_attrs( module) ;
769780 tcx. ensure( ) . check_mod_naked_functions( module) ;
770781 tcx. ensure( ) . check_mod_unstable_api_usage( module) ;
771782 tcx. ensure( ) . check_mod_const_bodies( module) ;
772783 } ) ;
784+ }
785+
773786 } ,
774787 {
775788 sess. time( "unused_lib_feature_checking" , || {
@@ -790,8 +803,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
790803 // passes are timed inside typeck
791804 rustc_hir_analysis:: check_crate ( tcx) ?;
792805
793- let has_cache = tcx. query_system . on_disk_cache . as_ref ( ) . map ( |cache| cache. has_cache ( ) ) . unwrap_or ( false ) ;
794-
795806 sess. time ( "MIR_borrow_checking" , || {
796807 if has_cache {
797808 for def_id in tcx. hir ( ) . body_owners ( ) {
@@ -872,7 +883,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
872883 } ) ;
873884 }
874885 ) ;
875-
876886 // This check has to be run after all lints are done processing. We don't
877887 // define a lint filter, as all lint checks should have finished at this point.
878888 sess. time ( "check_lint_expectations" , || tcx. check_expectations ( None ) ) ;
0 commit comments