@@ -492,6 +492,7 @@ enum ModuleKind {
492
492
NormalModuleKind ,
493
493
TraitModuleKind ,
494
494
ImplModuleKind ,
495
+ EnumModuleKind ,
495
496
AnonymousModuleKind ,
496
497
}
497
498
@@ -1282,7 +1283,25 @@ impl<'a> Resolver<'a> {
1282
1283
name_bindings. define_type
1283
1284
( DefTy ( local_def ( item. id ) , true ) , sp, is_public) ;
1284
1285
1286
+ let parent_link = self . get_parent_link ( parent. clone ( ) , ident) ;
1287
+ // We want to make sure the module type is EnumModuleKind
1288
+ // even if there's already an ImplModuleKind module defined,
1289
+ // since that's how we prevent duplicate enum definitions
1290
+ name_bindings. set_module_kind ( parent_link,
1291
+ Some ( local_def ( item. id ) ) ,
1292
+ EnumModuleKind ,
1293
+ false ,
1294
+ is_public,
1295
+ sp) ;
1296
+
1285
1297
for variant in ( * enum_definition) . variants . iter ( ) {
1298
+ self . build_reduced_graph_for_variant (
1299
+ & * * variant,
1300
+ local_def ( item. id ) ,
1301
+ ModuleReducedGraphParent ( name_bindings. get_module ( ) ) ,
1302
+ is_public) ;
1303
+
1304
+ // Temporary staging hack
1286
1305
self . build_reduced_graph_for_variant (
1287
1306
& * * variant,
1288
1307
local_def ( item. id ) ,
@@ -1347,6 +1366,12 @@ impl<'a> Resolver<'a> {
1347
1366
ImplModuleKind => {
1348
1367
ModuleReducedGraphParent ( child. get_module ( ) )
1349
1368
}
1369
+ Some ( ref child) if child. get_module_if_available ( )
1370
+ . is_some ( ) &&
1371
+ child. get_module ( ) . kind . get ( ) ==
1372
+ EnumModuleKind => {
1373
+ ModuleReducedGraphParent ( child. get_module ( ) )
1374
+ }
1350
1375
// Create the module
1351
1376
_ => {
1352
1377
let name_bindings =
@@ -3400,6 +3425,7 @@ impl<'a> Resolver<'a> {
3400
3425
}
3401
3426
TraitModuleKind |
3402
3427
ImplModuleKind |
3428
+ EnumModuleKind |
3403
3429
AnonymousModuleKind => {
3404
3430
search_module = parent_module_node. upgrade ( ) . unwrap ( ) ;
3405
3431
}
@@ -3497,6 +3523,7 @@ impl<'a> Resolver<'a> {
3497
3523
NormalModuleKind => return Some ( new_module) ,
3498
3524
TraitModuleKind |
3499
3525
ImplModuleKind |
3526
+ EnumModuleKind |
3500
3527
AnonymousModuleKind => module_ = new_module,
3501
3528
}
3502
3529
}
@@ -3512,6 +3539,7 @@ impl<'a> Resolver<'a> {
3512
3539
NormalModuleKind => return module_,
3513
3540
TraitModuleKind |
3514
3541
ImplModuleKind |
3542
+ EnumModuleKind |
3515
3543
AnonymousModuleKind => {
3516
3544
match self . get_nearest_normal_module_parent ( module_. clone ( ) ) {
3517
3545
None => module_,
0 commit comments