@@ -409,6 +409,7 @@ pub enum ParentLink {
409
409
}
410
410
411
411
/// The type of module this is.
412
+ #[ deriving( Eq ) ]
412
413
pub enum ModuleKind {
413
414
NormalModuleKind ,
414
415
ExternModuleKind ,
@@ -1228,25 +1229,34 @@ impl Resolver {
1228
1229
match ( trait_ref_opt, ty) {
1229
1230
( None , @Ty { node : ty_path( path, _) , _ } ) if
1230
1231
has_static_methods && path. idents . len ( ) == 1 => {
1231
- // Create the module.
1232
1232
let name = path_to_ident ( path) ;
1233
- let ( name_bindings, new_parent) =
1234
- self . add_child ( name,
1235
- parent,
1236
- ForbidDuplicateModules ,
1237
- sp) ;
1238
-
1239
- let parent_link = self . get_parent_link ( new_parent,
1240
- ident) ;
1241
- let def_id = local_def ( item. id ) ;
1242
- name_bindings. define_module ( Public ,
1243
- parent_link,
1244
- Some ( def_id) ,
1245
- ImplModuleKind ,
1246
- sp) ;
1247
1233
1248
- let new_parent = ModuleReducedGraphParent (
1249
- name_bindings. get_module ( ) ) ;
1234
+ let new_parent = match parent. children . find ( & name) {
1235
+ // It already exists
1236
+ Some ( & child) if child. get_module_if_available ( ) . is_some ( ) &&
1237
+ child. get_module ( ) . kind == ImplModuleKind => {
1238
+ ModuleReducedGraphParent ( child. get_module ( ) )
1239
+ }
1240
+ // Create the module
1241
+ _ => {
1242
+ let ( name_bindings, new_parent) =
1243
+ self . add_child ( name,
1244
+ parent,
1245
+ ForbidDuplicateModules ,
1246
+ sp) ;
1247
+
1248
+ let parent_link = self . get_parent_link ( new_parent,
1249
+ ident) ;
1250
+ let def_id = local_def ( item. id ) ;
1251
+ name_bindings. define_module ( Public ,
1252
+ parent_link,
1253
+ Some ( def_id) ,
1254
+ ImplModuleKind ,
1255
+ sp) ;
1256
+
1257
+ ModuleReducedGraphParent ( name_bindings. get_module ( ) )
1258
+ }
1259
+ } ;
1250
1260
1251
1261
// For each static method...
1252
1262
for methods. each |method| {
0 commit comments