@@ -1326,18 +1326,42 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1326
1326
TyKind :: Err => {
1327
1327
hir:: TyKind :: Err ( self . tcx . sess . span_delayed_bug ( t. span , "TyKind::Err lowered" ) )
1328
1328
}
1329
- // FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
1330
- #[ allow( rustc:: untranslatable_diagnostic) ]
1331
- #[ allow( rustc:: diagnostic_outside_of_impl) ]
1332
- TyKind :: AnonStruct ( ref _fields) => hir:: TyKind :: Err (
1333
- self . tcx . sess . span_err ( t. span , "anonymous structs are unimplemented" ) ,
1334
- ) ,
1335
- // FIXME(unnamed_fields): IMPLEMENTATION IN PROGRESS
1336
- #[ allow( rustc:: untranslatable_diagnostic) ]
1337
- #[ allow( rustc:: diagnostic_outside_of_impl) ]
1338
- TyKind :: AnonUnion ( ref _fields) => hir:: TyKind :: Err (
1339
- self . tcx . sess . span_err ( t. span , "anonymous unions are unimplemented" ) ,
1340
- ) ,
1329
+ TyKind :: AnonStruct ( def_node_id, fields) | TyKind :: AnonUnion ( def_node_id, fields) => {
1330
+ let def_kind = match t. kind {
1331
+ TyKind :: AnonStruct ( ..) => DefKind :: Struct ,
1332
+ TyKind :: AnonUnion ( ..) => DefKind :: Union ,
1333
+ _ => unreachable ! ( ) ,
1334
+ } ;
1335
+ let def_id = self . create_def (
1336
+ self . current_hir_id_owner . def_id ,
1337
+ * def_node_id,
1338
+ sym:: anon,
1339
+ def_kind,
1340
+ t. span ,
1341
+ ) ;
1342
+ debug ! ( ?def_id) ;
1343
+ let owner_id = hir:: OwnerId { def_id } ;
1344
+ self . with_hir_id_owner ( * def_node_id, |this| {
1345
+ let fields = this. arena . alloc_from_iter (
1346
+ fields. iter ( ) . enumerate ( ) . map ( |f| this. lower_field_def ( f) ) ,
1347
+ ) ;
1348
+ let span = t. span ;
1349
+ let variant_data = hir:: VariantData :: Struct ( fields, false ) ;
1350
+ let generics = hir:: Generics :: empty ( ) ;
1351
+ let kind = match & t. kind {
1352
+ TyKind :: AnonStruct ( ..) => hir:: ItemKind :: Struct ( variant_data, generics) ,
1353
+ _ => hir:: ItemKind :: Union ( variant_data, generics) ,
1354
+ } ;
1355
+ hir:: OwnerNode :: Item ( this. arena . alloc ( hir:: Item {
1356
+ ident : Ident :: with_dummy_span ( sym:: anon) ,
1357
+ owner_id,
1358
+ kind,
1359
+ span : this. lower_span ( span) ,
1360
+ vis_span : this. lower_span ( span. shrink_to_lo ( ) ) ,
1361
+ } ) )
1362
+ } ) ;
1363
+ hir:: TyKind :: AnonAdt ( hir:: ItemId { owner_id } )
1364
+ }
1341
1365
TyKind :: Slice ( ty) => hir:: TyKind :: Slice ( self . lower_ty ( ty, itctx) ) ,
1342
1366
TyKind :: Ptr ( mt) => hir:: TyKind :: Ptr ( self . lower_mt ( mt, itctx) ) ,
1343
1367
TyKind :: Ref ( region, mt) => {
0 commit comments