@@ -307,7 +307,7 @@ enum BareIdentifierPatternResolution {
307
307
#[ deriving( PartialEq ) ]
308
308
enum DuplicateCheckingMode {
309
309
ForbidDuplicateModules ,
310
- ForbidDuplicateTypes ,
310
+ ForbidDuplicateTypesAndModules ,
311
311
ForbidDuplicateValues ,
312
312
ForbidDuplicateTypesAndValues ,
313
313
OverwriteDuplicates
@@ -792,10 +792,9 @@ impl PrimitiveTypeTable {
792
792
793
793
fn namespace_error_to_str ( ns : NamespaceError ) -> & ' static str {
794
794
match ns {
795
- NoError => "" ,
796
- ModuleError => "module" ,
797
- TypeError => "type" ,
798
- ValueError => "value" ,
795
+ NoError => "" ,
796
+ ModuleError | TypeError => "type or module" ,
797
+ ValueError => "value" ,
799
798
}
800
799
}
801
800
@@ -1033,9 +1032,12 @@ impl<'a> Resolver<'a> {
1033
1032
}
1034
1033
Some ( TypeNS )
1035
1034
}
1036
- ForbidDuplicateTypes => {
1035
+ ForbidDuplicateTypesAndModules => {
1037
1036
match child. def_for_namespace ( TypeNS ) {
1038
- Some ( DefMod ( _) ) | None => { }
1037
+ None => { }
1038
+ Some ( _) if child. get_module_if_available ( )
1039
+ . map ( |m| m. kind . get ( ) ) ==
1040
+ Some ( ImplModuleKind ) => { }
1039
1041
Some ( _) => duplicate_type = TypeError
1040
1042
}
1041
1043
Some ( TypeNS )
@@ -1177,7 +1179,10 @@ impl<'a> Resolver<'a> {
1177
1179
// These items live in the type namespace.
1178
1180
ItemTy ( ..) => {
1179
1181
let name_bindings =
1180
- self . add_child ( ident, parent. clone ( ) , ForbidDuplicateTypes , sp) ;
1182
+ self . add_child ( ident,
1183
+ parent. clone ( ) ,
1184
+ ForbidDuplicateTypesAndModules ,
1185
+ sp) ;
1181
1186
1182
1187
name_bindings. define_type
1183
1188
( DefTy ( local_def ( item. id ) ) , sp, is_public) ;
@@ -1186,7 +1191,10 @@ impl<'a> Resolver<'a> {
1186
1191
1187
1192
ItemEnum ( ref enum_definition, _) => {
1188
1193
let name_bindings =
1189
- self . add_child ( ident, parent. clone ( ) , ForbidDuplicateTypes , sp) ;
1194
+ self . add_child ( ident,
1195
+ parent. clone ( ) ,
1196
+ ForbidDuplicateTypesAndModules ,
1197
+ sp) ;
1190
1198
1191
1199
name_bindings. define_type
1192
1200
( DefTy ( local_def ( item. id ) ) , sp, is_public) ;
@@ -1206,7 +1214,7 @@ impl<'a> Resolver<'a> {
1206
1214
// Adding to both Type and Value namespaces or just Type?
1207
1215
let ( forbid, ctor_id) = match struct_def. ctor_id {
1208
1216
Some ( ctor_id) => ( ForbidDuplicateTypesAndValues , Some ( ctor_id) ) ,
1209
- None => ( ForbidDuplicateTypes , None )
1217
+ None => ( ForbidDuplicateTypesAndModules , None )
1210
1218
} ;
1211
1219
1212
1220
let name_bindings = self . add_child ( ident, parent. clone ( ) , forbid, sp) ;
@@ -1327,7 +1335,10 @@ impl<'a> Resolver<'a> {
1327
1335
1328
1336
ItemTrait ( _, _, _, ref methods) => {
1329
1337
let name_bindings =
1330
- self . add_child ( ident, parent. clone ( ) , ForbidDuplicateTypes , sp) ;
1338
+ self . add_child ( ident,
1339
+ parent. clone ( ) ,
1340
+ ForbidDuplicateTypesAndModules ,
1341
+ sp) ;
1331
1342
1332
1343
// Add all the methods within to a new module.
1333
1344
let parent_link = self . get_parent_link ( parent. clone ( ) , ident) ;
0 commit comments