@@ -33,7 +33,8 @@ import syntax::ast::{lt, method, mul, ne, neg, node_id, pat, pat_enum};
33
33
import syntax:: ast:: { pat_ident, path, prim_ty, pat_box, pat_uniq, pat_lit} ;
34
34
import syntax:: ast:: { pat_range, pat_rec, pat_struct, pat_tup, pat_wild} ;
35
35
import syntax:: ast:: { provided, required, rem, self_ty_, shl, stmt_decl} ;
36
- import syntax:: ast:: { sty_static, subtract, ty} ;
36
+ import syntax:: ast:: { struct_variant_kind, sty_static, subtract} ;
37
+ import syntax:: ast:: { tuple_variant_kind, ty} ;
37
38
import syntax:: ast:: { ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i} ;
38
39
import syntax:: ast:: { ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param} ;
39
40
import syntax:: ast:: { ty_path, ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8} ;
@@ -1114,10 +1115,8 @@ class Resolver {
1114
1115
}
1115
1116
}
1116
1117
1117
- /**
1118
- * Constructs the reduced graph for one variant. Variants exist in the
1119
- * type namespace.
1120
- */
1118
+ // Constructs the reduced graph for one variant. Variants exist in the
1119
+ // type and/or value namespaces.
1121
1120
fn build_reduced_graph_for_variant ( variant : variant ,
1122
1121
item_id : def_id ,
1123
1122
parent : ReducedGraphParent ,
@@ -1127,8 +1126,19 @@ class Resolver {
1127
1126
let ( child, _) = self . add_child ( atom, parent, ~[ ValueNS ] ,
1128
1127
variant. span ) ;
1129
1128
1130
- ( * child) . define_value ( def_variant ( item_id,
1131
- local_def ( variant. node . id ) ) , variant. span ) ;
1129
+ match variant. node . kind {
1130
+ tuple_variant_kind( _) => {
1131
+ ( * child) . define_value ( def_variant ( item_id,
1132
+ local_def ( variant. node . id ) ) ,
1133
+ variant. span ) ;
1134
+ }
1135
+ struct_variant_kind( _) => {
1136
+ ( * child) . define_type ( def_variant ( item_id,
1137
+ local_def ( variant. node . id ) ) ,
1138
+ variant. span ) ;
1139
+ self . structs . insert ( local_def ( variant. node . id ) , false ) ;
1140
+ }
1141
+ }
1132
1142
}
1133
1143
1134
1144
/**
@@ -4018,13 +4028,17 @@ class Resolver {
4018
4028
4019
4029
pat_struct(path, _, _) => {
4020
4030
match self.resolve_path(path, TypeNS, false, visitor) {
4021
- some(definition @ def_ty(class_id))
4031
+ some(def_ty(class_id))
4022
4032
if self.structs.contains_key(class_id) => {
4023
4033
let has_constructor = self.structs.get(class_id);
4024
4034
let class_def = def_class(class_id,
4025
4035
has_constructor);
4026
4036
self.record_def(pattern.id, class_def);
4027
4037
}
4038
+ some(definition @ def_variant(_, variant_id))
4039
+ if self.structs.contains_key(variant_id) => {
4040
+ self.record_def(pattern.id, definition);
4041
+ }
4028
4042
_ => {
4029
4043
self.session.span_err(path.span,
4030
4044
fmt!(" `%s` does not name a \
@@ -4450,13 +4464,16 @@ class Resolver {
4450
4464
// let bar = Bar { ... } // no type parameters
4451
4465
4452
4466
match self.resolve_path(path, TypeNS, false, visitor) {
4453
- some(definition @ def_ty(class_id))
4467
+ some(def_ty(class_id))
4454
4468
if self.structs.contains_key(class_id) => {
4455
-
4456
4469
let has_constructor = self.structs.get(class_id);
4457
4470
let class_def = def_class(class_id, has_constructor);
4458
4471
self.record_def(expr.id, class_def);
4459
4472
}
4473
+ some(definition @ def_variant(_, class_id))
4474
+ if self.structs.contains_key(class_id) => {
4475
+ self.record_def(expr.id, definition);
4476
+ }
4460
4477
_ => {
4461
4478
self.session.span_err(path.span,
4462
4479
fmt!{" `%s` does not name a \
0 commit comments