@@ -416,37 +416,35 @@ enum MonoItemPlacement {
416416fn place_inlined_mono_items < ' tcx > (
417417 cx : & PartitioningCx < ' _ , ' tcx > ,
418418 codegen_units : & mut [ CodegenUnit < ' tcx > ] ,
419- roots : FxHashSet < MonoItem < ' tcx > > ,
419+ _roots : FxHashSet < MonoItem < ' tcx > > ,
420420) -> FxHashMap < MonoItem < ' tcx > , MonoItemPlacement > {
421- let mut mono_item_placements = FxHashMap :: default ( ) ;
422-
423- let single_codegen_unit = codegen_units. len ( ) == 1 ;
424-
425421 for cgu in codegen_units. iter_mut ( ) {
426- // Collect all items that need to be available in this codegen unit.
427- let mut reachable = FxHashSet :: default ( ) ;
422+ // Collect all inlined items that need to be available in this codegen unit.
423+ let mut reachable_inlined_items = FxHashSet :: default ( ) ;
428424 for root in cgu. items ( ) . keys ( ) {
429- // Insert the root item itself, plus all inlined items that are
430- // reachable from it without going via another root item.
431- reachable. insert ( * root) ;
432- get_reachable_inlined_items ( cx. tcx , * root, cx. usage_map , & mut reachable) ;
425+ // Get all inlined items that are reachable from it without going
426+ // via another root item.
427+ get_reachable_inlined_items ( cx. tcx , * root, cx. usage_map , & mut reachable_inlined_items) ;
433428 }
434429
435430 // Add all monomorphizations that are not already there.
436- for mono_item in reachable {
437- if !cgu. items ( ) . contains_key ( & mono_item) {
438- if roots. contains ( & mono_item) {
439- bug ! ( "GloballyShared mono-item inlined into other CGU: {:?}" , mono_item) ;
440- }
431+ for inlined_item in reachable_inlined_items {
432+ assert ! ( !cgu. items( ) . contains_key( & inlined_item) ) ;
441433
442- // This is a CGU-private copy.
443- cgu. items_mut ( ) . insert ( mono_item, ( Linkage :: Internal , Visibility :: Default ) ) ;
444- }
434+ // This is a CGU-private copy.
435+ cgu. items_mut ( ) . insert ( inlined_item, ( Linkage :: Internal , Visibility :: Default ) ) ;
436+ }
437+ }
438+
439+ let mut mono_item_placements = FxHashMap :: default ( ) ;
440+ let single_codegen_unit = codegen_units. len ( ) == 1 ;
445441
442+ for cgu in codegen_units. iter_mut ( ) {
443+ for item in cgu. items ( ) . keys ( ) {
446444 if !single_codegen_unit {
447445 // If there is more than one codegen unit, we need to keep track
448446 // in which codegen units each monomorphization is placed.
449- match mono_item_placements. entry ( mono_item ) {
447+ match mono_item_placements. entry ( * item ) {
450448 Entry :: Occupied ( e) => {
451449 let placement = e. into_mut ( ) ;
452450 debug_assert ! ( match * placement {
0 commit comments