9494
9595use std:: cmp;
9696use std:: collections:: hash_map:: Entry ;
97- use std:: sync:: Arc ;
9897
9998use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
10099use rustc_data_structures:: sync;
@@ -883,7 +882,7 @@ where
883882fn collect_and_partition_mono_items (
884883 tcx : TyCtxt < ' _ > ,
885884 cnum : CrateNum ,
886- ) -> ( Arc < DefIdSet > , Arc < Vec < Arc < CodegenUnit < ' _ > > > > ) {
885+ ) -> ( & ' tcx DefIdSet , & ' tcx [ CodegenUnit < ' _ > ] ) {
887886 assert_eq ! ( cnum, LOCAL_CRATE ) ;
888887
889888 let collection_mode = match tcx. sess . opts . debugging_opts . print_mono_items {
@@ -921,10 +920,12 @@ fn collect_and_partition_mono_items(
921920 let ( codegen_units, _) = tcx. sess . time ( "partition_and_assert_distinct_symbols" , || {
922921 sync:: join (
923922 || {
924- partition ( tcx, items. iter ( ) . cloned ( ) , tcx. sess . codegen_units ( ) , & inlining_map)
925- . into_iter ( )
926- . map ( Arc :: new)
927- . collect :: < Vec < _ > > ( )
923+ & * tcx. arena . alloc_from_iter ( partition (
924+ tcx,
925+ items. iter ( ) . cloned ( ) ,
926+ tcx. sess . codegen_units ( ) ,
927+ & inlining_map,
928+ ) )
928929 } ,
929930 || assert_symbols_are_distinct ( tcx, items. iter ( ) ) ,
930931 )
@@ -942,7 +943,7 @@ fn collect_and_partition_mono_items(
942943 if tcx. sess . opts . debugging_opts . print_mono_items . is_some ( ) {
943944 let mut item_to_cgus: FxHashMap < _ , Vec < _ > > = Default :: default ( ) ;
944945
945- for cgu in & codegen_units {
946+ for cgu in codegen_units {
946947 for ( & mono_item, & linkage) in cgu. items ( ) {
947948 item_to_cgus. entry ( mono_item) . or_default ( ) . push ( ( cgu. name ( ) , linkage) ) ;
948949 }
@@ -990,7 +991,7 @@ fn collect_and_partition_mono_items(
990991 }
991992 }
992993
993- ( Arc :: new ( mono_items) , Arc :: new ( codegen_units) )
994+ ( tcx . arena . alloc ( mono_items) , codegen_units)
994995}
995996
996997pub fn provide ( providers : & mut Providers < ' _ > ) {
@@ -1005,7 +1006,6 @@ pub fn provide(providers: &mut Providers<'_>) {
10051006 let ( _, all) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
10061007 all. iter ( )
10071008 . find ( |cgu| cgu. name ( ) == name)
1008- . cloned ( )
10091009 . unwrap_or_else ( || panic ! ( "failed to find cgu with name {:?}" , name) )
10101010 } ;
10111011}
0 commit comments