@@ -1535,6 +1535,14 @@ fn describe_enum_variant(
1535
1535
unique_type_id,
1536
1536
Some ( containing_scope) ) ;
1537
1537
1538
+ let arg_name = |i : usize | {
1539
+ if variant. ctor_kind == CtorKind :: Fn {
1540
+ format ! ( "__{}" , i)
1541
+ } else {
1542
+ variant. fields [ i] . ident . to_string ( )
1543
+ }
1544
+ } ;
1545
+
1538
1546
// Build an array of (field name, field type) pairs to be captured in the factory closure.
1539
1547
let ( offsets, args) = if use_enum_fallback ( cx) {
1540
1548
// If this is not a univariant enum, there is also the discriminant field.
@@ -1552,12 +1560,7 @@ fn describe_enum_variant(
1552
1560
layout. fields . offset ( i)
1553
1561
} ) ) . collect ( ) ,
1554
1562
discr_arg. into_iter ( ) . chain ( ( 0 ..layout. fields . count ( ) ) . map ( |i| {
1555
- let name = if variant. ctor_kind == CtorKind :: Fn {
1556
- format ! ( "__{}" , i)
1557
- } else {
1558
- variant. fields [ i] . ident . to_string ( )
1559
- } ;
1560
- ( name, layout. field ( cx, i) . ty )
1563
+ ( arg_name ( i) , layout. field ( cx, i) . ty )
1561
1564
} ) ) . collect ( )
1562
1565
)
1563
1566
} else {
@@ -1566,12 +1569,7 @@ fn describe_enum_variant(
1566
1569
layout. fields . offset ( i)
1567
1570
} ) . collect ( ) ,
1568
1571
( 0 ..layout. fields . count ( ) ) . map ( |i| {
1569
- let name = if variant. ctor_kind == CtorKind :: Fn {
1570
- format ! ( "__{}" , i)
1571
- } else {
1572
- variant. fields [ i] . ident . to_string ( )
1573
- } ;
1574
- ( name, layout. field ( cx, i) . ty )
1572
+ ( arg_name ( i) , layout. field ( cx, i) . ty )
1575
1573
} ) . collect ( )
1576
1574
)
1577
1575
} ;
0 commit comments