@@ -1195,22 +1195,22 @@ impl Resolver {
11951195
11961196 // These items live in both the type and value namespaces.
11971197 item_struct( struct_def, _) => {
1198- let ( name_bindings, new_parent) =
1199- self . add_child ( ident, parent, ForbidDuplicateTypes , sp) ;
1198+ // Adding to both Type and Value namespaces or just Type?
1199+ let ( forbid, ctor_id) = match struct_def. ctor_id {
1200+ Some ( ctor_id) => ( ForbidDuplicateTypesAndValues , Some ( ctor_id) ) ,
1201+ None => ( ForbidDuplicateTypes , None )
1202+ } ;
12001203
1201- name_bindings. define_type (
1202- privacy, def_ty ( local_def ( item. id ) ) , sp) ;
1204+ let ( name_bindings, new_parent) = self . add_child ( ident, parent, forbid, sp) ;
12031205
1204- // If this struct is tuple-like or enum-like, define a name
1205- // in the value namespace.
1206- match struct_def. ctor_id {
1207- None => { }
1208- Some ( ctor_id) => {
1209- name_bindings. define_value (
1210- privacy,
1211- def_struct ( local_def ( ctor_id) ) ,
1212- sp) ;
1213- }
1206+ // Define a name in the type namespace.
1207+ name_bindings. define_type ( privacy, def_ty ( local_def ( item. id ) ) , sp) ;
1208+
1209+ // If this is a newtype or unit-like struct, define a name
1210+ // in the value namespace as well
1211+ do ctor_id. while_some |cid| {
1212+ name_bindings. define_value ( privacy, def_struct ( local_def ( cid) ) , sp) ;
1213+ None
12141214 }
12151215
12161216 // Record the def ID of this struct.
0 commit comments