@@ -1479,10 +1479,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1479
1479
// re-link the regions that EIfEO can erase.
1480
1480
self . demand_eqtype ( span, adt_ty_hint, adt_ty) ;
1481
1481
1482
- let ( substs, adt_kind, kind_name) = match adt_ty. kind ( ) {
1483
- ty:: Adt ( adt, substs) => ( substs, adt. adt_kind ( ) , adt. variant_descr ( ) ) ,
1484
- _ => span_bug ! ( span, "non-ADT passed to check_expr_struct_fields" ) ,
1482
+ let ty:: Adt ( adt, substs) = adt_ty. kind ( ) else {
1483
+ span_bug ! ( span, "non-ADT passed to check_expr_struct_fields" ) ;
1485
1484
} ;
1485
+ let adt_kind = adt. adt_kind ( ) ;
1486
1486
1487
1487
let mut remaining_fields = variant
1488
1488
. fields
@@ -1520,7 +1520,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1520
1520
} ) ;
1521
1521
} else {
1522
1522
self . report_unknown_field (
1523
- adt_ty, variant, field, ast_fields, kind_name, expr_span,
1523
+ adt_ty,
1524
+ variant,
1525
+ field,
1526
+ ast_fields,
1527
+ adt. variant_descr ( ) ,
1528
+ expr_span,
1524
1529
) ;
1525
1530
}
1526
1531
@@ -1533,7 +1538,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1533
1538
}
1534
1539
1535
1540
// Make sure the programmer specified correct number of fields.
1536
- if kind_name == "union" {
1541
+ if adt_kind == AdtKind :: Union {
1537
1542
if ast_fields. len ( ) != 1 {
1538
1543
struct_span_err ! (
1539
1544
tcx. sess,
@@ -1666,7 +1671,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1666
1671
}
1667
1672
} ;
1668
1673
self . typeck_results . borrow_mut ( ) . fru_field_types_mut ( ) . insert ( expr_id, fru_tys) ;
1669
- } else if kind_name != "union" && !remaining_fields. is_empty ( ) {
1674
+ } else if adt_kind != AdtKind :: Union && !remaining_fields. is_empty ( ) {
1670
1675
let inaccessible_remaining_fields = remaining_fields. iter ( ) . any ( |( _, ( _, field) ) | {
1671
1676
!field. vis . is_accessible_from ( tcx. parent_module ( expr_id) . to_def_id ( ) , tcx)
1672
1677
} ) ;
0 commit comments