@@ -875,6 +875,8 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
875875 } ) ;
876876 // Freeze definitions as we don't add new ones at this point.
877877 // We need to wait until now since we synthesize a by-move body
878+ // for all coroutine-closures.
879+ //
878880 // This improves performance by allowing lock-free access to them.
879881 tcx. untracked ( ) . definitions . freeze ( ) ;
880882
@@ -887,7 +889,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
887889 } ) ;
888890 } ) ;
889891 sess. time ( "MIR_effect_checking" , || {
890- for def_id in tcx. hir ( ) . body_owners ( ) {
892+ tcx. hir ( ) . par_body_owners ( |def_id| {
891893 tcx. ensure ( ) . has_ffi_unwind_calls ( def_id) ;
892894
893895 // If we need to codegen, ensure that we emit all errors from
@@ -898,15 +900,17 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
898900 {
899901 tcx. ensure ( ) . mir_drops_elaborated_and_const_checked ( def_id) ;
900902 }
901- }
903+ } ) ;
902904 } ) ;
903- tcx. hir ( ) . par_body_owners ( |def_id| {
904- if tcx. is_coroutine ( def_id. to_def_id ( ) ) {
905- tcx. ensure ( ) . mir_coroutine_witnesses ( def_id) ;
906- tcx. ensure ( ) . check_coroutine_obligations (
907- tcx. typeck_root_def_id ( def_id. to_def_id ( ) ) . expect_local ( ) ,
908- ) ;
909- }
905+ sess. time ( "coroutine_obligations" , || {
906+ tcx. hir ( ) . par_body_owners ( |def_id| {
907+ if tcx. is_coroutine ( def_id. to_def_id ( ) ) {
908+ tcx. ensure ( ) . mir_coroutine_witnesses ( def_id) ;
909+ tcx. ensure ( ) . check_coroutine_obligations (
910+ tcx. typeck_root_def_id ( def_id. to_def_id ( ) ) . expect_local ( ) ,
911+ ) ;
912+ }
913+ } ) ;
910914 } ) ;
911915
912916 sess. time ( "layout_testing" , || layout_test:: test_layout ( tcx) ) ;
0 commit comments