@@ -416,37 +416,35 @@ enum MonoItemPlacement {
416
416
fn place_inlined_mono_items < ' tcx > (
417
417
cx : & PartitioningCx < ' _ , ' tcx > ,
418
418
codegen_units : & mut [ CodegenUnit < ' tcx > ] ,
419
- roots : FxHashSet < MonoItem < ' tcx > > ,
419
+ _roots : FxHashSet < MonoItem < ' tcx > > ,
420
420
) -> FxHashMap < MonoItem < ' tcx > , MonoItemPlacement > {
421
- let mut mono_item_placements = FxHashMap :: default ( ) ;
422
-
423
- let single_codegen_unit = codegen_units. len ( ) == 1 ;
424
-
425
421
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 ( ) ;
428
424
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) ;
433
428
}
434
429
435
430
// 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) ) ;
441
433
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 ;
445
441
442
+ for cgu in codegen_units. iter_mut ( ) {
443
+ for item in cgu. items ( ) . keys ( ) {
446
444
if !single_codegen_unit {
447
445
// If there is more than one codegen unit, we need to keep track
448
446
// in which codegen units each monomorphization is placed.
449
- match mono_item_placements. entry ( mono_item ) {
447
+ match mono_item_placements. entry ( * item ) {
450
448
Entry :: Occupied ( e) => {
451
449
let placement = e. into_mut ( ) ;
452
450
debug_assert ! ( match * placement {
0 commit comments