@@ -1427,7 +1427,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1427
1427
& adt_def
1428
1428
. variants ( )
1429
1429
. iter ( )
1430
- . map ( |variant| variant. name ( ) )
1430
+ . map ( |variant| variant. name )
1431
1431
. collect :: < Vec < Symbol > > ( ) ,
1432
1432
assoc_ident. name ,
1433
1433
None ,
@@ -2422,6 +2422,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2422
2422
hir:: TyKind :: Tup ( fields) => {
2423
2423
Ty :: new_tup_from_iter ( tcx, fields. iter ( ) . map ( |t| self . ast_ty_to_ty ( t) ) )
2424
2424
}
2425
+ hir:: TyKind :: AnonAdt ( item_id) => {
2426
+ let adt_def = crate :: collect:: adt_def ( tcx, item_id. owner_id . def_id ) ;
2427
+ Ty :: new_adt ( tcx, adt_def, tcx. mk_args ( & [ ] ) )
2428
+ }
2425
2429
hir:: TyKind :: BareFn ( bf) => {
2426
2430
require_c_abi_if_c_variadic ( tcx, bf. decl , bf. abi , ast_ty. span ) ;
2427
2431
@@ -2524,27 +2528,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2524
2528
self . ty_infer ( None , ast_ty. span )
2525
2529
}
2526
2530
hir:: TyKind :: Err ( guar) => Ty :: new_error ( tcx, * guar) ,
2527
- hir:: TyKind :: AnonStruct ( fields, ) | hir:: TyKind :: AnonUnion ( fields) => {
2528
- let repr = tcx. repr_options_of_def ( ast_ty. hir_id . owner . to_def_id ( ) ) ;
2529
- if !repr. c ( ) {
2530
- // tcx.sess.emit_err(todo!());
2531
- }
2532
- let adt_kind = match ast_ty. kind {
2533
- hir:: TyKind :: AnonStruct ( ..) => ty:: AdtKind :: Struct ,
2534
- _ => ty:: AdtKind :: Union ,
2535
- } ;
2536
- let field_def = tcx. hir ( ) . expect_field ( tcx. hir ( ) . parent_id ( ast_ty. hir_id ) ) ;
2537
- let did = field_def. def_id ;
2538
- let variants = std:: iter:: once ( convert_variant (
2539
- tcx,
2540
- did,
2541
- fields,
2542
- adt_kind,
2543
- ) )
2544
- . collect ( ) ;
2545
- let adt_def = tcx. mk_adt_def ( did. to_def_id ( ) , adt_kind, variants, repr) ;
2546
- Ty :: new_adt ( tcx, adt_def, tcx. mk_args ( & [ ] ) )
2547
- }
2548
2531
} ;
2549
2532
2550
2533
self . record_ty ( ast_ty. hir_id , result_ty, ast_ty. span ) ;
@@ -2834,38 +2817,3 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2834
2817
Some ( r)
2835
2818
}
2836
2819
}
2837
-
2838
- fn convert_variant (
2839
- tcx : TyCtxt < ' _ > ,
2840
- did : LocalDefId ,
2841
- fields : & [ hir:: FieldDef < ' _ > ] ,
2842
- adt_kind : ty:: AdtKind ,
2843
- ) -> ty:: VariantDef {
2844
- let mut seen_fields: FxHashMap < Ident , Span > = Default :: default ( ) ;
2845
- let fields = fields
2846
- . iter ( )
2847
- . map ( |f| {
2848
- let dup_span = seen_fields. get ( & f. ident . normalize_to_macros_2_0 ( ) ) . cloned ( ) ;
2849
- if let Some ( prev_span) = dup_span {
2850
- tcx. sess . emit_err ( crate :: errors:: FieldAlreadyDeclared {
2851
- field_name : f. ident ,
2852
- span : f. span ,
2853
- prev_span,
2854
- } ) ;
2855
- } else {
2856
- seen_fields. insert ( f. ident . normalize_to_macros_2_0 ( ) , f. span ) ;
2857
- }
2858
-
2859
- ty:: FieldDef {
2860
- did : f. def_id . to_def_id ( ) ,
2861
- name : f. ident . name ,
2862
- vis : tcx. visibility ( f. def_id ) ,
2863
- }
2864
- } )
2865
- . collect ( ) ;
2866
- ty:: VariantDef :: new_anon (
2867
- did. to_def_id ( ) ,
2868
- fields,
2869
- adt_kind,
2870
- )
2871
- }
0 commit comments