@@ -307,7 +307,7 @@ enum BareIdentifierPatternResolution {
307307#[ deriving( PartialEq ) ]
308308enum DuplicateCheckingMode {
309309 ForbidDuplicateModules ,
310- ForbidDuplicateTypes ,
310+ ForbidDuplicateTypesAndModules ,
311311 ForbidDuplicateValues ,
312312 ForbidDuplicateTypesAndValues ,
313313 OverwriteDuplicates
@@ -792,10 +792,9 @@ impl PrimitiveTypeTable {
792792
793793fn namespace_error_to_str ( ns : NamespaceError ) -> & ' static str {
794794 match ns {
795- NoError => "" ,
796- ModuleError => "module" ,
797- TypeError => "type" ,
798- ValueError => "value" ,
795+ NoError => "" ,
796+ ModuleError | TypeError => "type or module" ,
797+ ValueError => "value" ,
799798 }
800799}
801800
@@ -1033,9 +1032,12 @@ impl<'a> Resolver<'a> {
10331032 }
10341033 Some ( TypeNS )
10351034 }
1036- ForbidDuplicateTypes => {
1035+ ForbidDuplicateTypesAndModules => {
10371036 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 ) => { }
10391041 Some ( _) => duplicate_type = TypeError
10401042 }
10411043 Some ( TypeNS )
@@ -1177,7 +1179,10 @@ impl<'a> Resolver<'a> {
11771179 // These items live in the type namespace.
11781180 ItemTy ( ..) => {
11791181 let name_bindings =
1180- self . add_child ( ident, parent. clone ( ) , ForbidDuplicateTypes , sp) ;
1182+ self . add_child ( ident,
1183+ parent. clone ( ) ,
1184+ ForbidDuplicateTypesAndModules ,
1185+ sp) ;
11811186
11821187 name_bindings. define_type
11831188 ( DefTy ( local_def ( item. id ) ) , sp, is_public) ;
@@ -1186,7 +1191,10 @@ impl<'a> Resolver<'a> {
11861191
11871192 ItemEnum ( ref enum_definition, _) => {
11881193 let name_bindings =
1189- self . add_child ( ident, parent. clone ( ) , ForbidDuplicateTypes , sp) ;
1194+ self . add_child ( ident,
1195+ parent. clone ( ) ,
1196+ ForbidDuplicateTypesAndModules ,
1197+ sp) ;
11901198
11911199 name_bindings. define_type
11921200 ( DefTy ( local_def ( item. id ) ) , sp, is_public) ;
@@ -1206,7 +1214,7 @@ impl<'a> Resolver<'a> {
12061214 // Adding to both Type and Value namespaces or just Type?
12071215 let ( forbid, ctor_id) = match struct_def. ctor_id {
12081216 Some ( ctor_id) => ( ForbidDuplicateTypesAndValues , Some ( ctor_id) ) ,
1209- None => ( ForbidDuplicateTypes , None )
1217+ None => ( ForbidDuplicateTypesAndModules , None )
12101218 } ;
12111219
12121220 let name_bindings = self . add_child ( ident, parent. clone ( ) , forbid, sp) ;
@@ -1327,7 +1335,10 @@ impl<'a> Resolver<'a> {
13271335
13281336 ItemTrait ( _, _, _, ref methods) => {
13291337 let name_bindings =
1330- self . add_child ( ident, parent. clone ( ) , ForbidDuplicateTypes , sp) ;
1338+ self . add_child ( ident,
1339+ parent. clone ( ) ,
1340+ ForbidDuplicateTypesAndModules ,
1341+ sp) ;
13311342
13321343 // Add all the methods within to a new module.
13331344 let parent_link = self . get_parent_link ( parent. clone ( ) , ident) ;
0 commit comments