Skip to content

Commit 2a0323b

Browse files
committed
---
yaml --- r: 31726 b: refs/heads/dist-snap c: 3196586 h: refs/heads/master v: v3
1 parent 3164c07 commit 2a0323b

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 5ce3281a624c0620f1b6f4e21c15e4a6a17a1dc5
10+
refs/heads/dist-snap: 31965860c797d07bc5f9d217874323b4f361bc0c
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/rustc/middle/resolve3.rs

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ import syntax::ast::{lt, method, mul, ne, neg, node_id, pat, pat_enum};
3333
import syntax::ast::{pat_ident, path, prim_ty, pat_box, pat_uniq, pat_lit};
3434
import syntax::ast::{pat_range, pat_rec, pat_struct, pat_tup, pat_wild};
3535
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};
3738
import syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
3839
import syntax::ast::{ty_i16, ty_i32, ty_i64, ty_i8, ty_int, ty_param};
3940
import syntax::ast::{ty_path, ty_str, ty_u, ty_u16, ty_u32, ty_u64, ty_u8};
@@ -1114,10 +1115,8 @@ class Resolver {
11141115
}
11151116
}
11161117

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.
11211120
fn build_reduced_graph_for_variant(variant: variant,
11221121
item_id: def_id,
11231122
parent: ReducedGraphParent,
@@ -1127,8 +1126,19 @@ class Resolver {
11271126
let (child, _) = self.add_child(atom, parent, ~[ValueNS],
11281127
variant.span);
11291128

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+
}
11321142
}
11331143

11341144
/**
@@ -4018,13 +4028,17 @@ class Resolver {
40184028
40194029
pat_struct(path, _, _) => {
40204030
match self.resolve_path(path, TypeNS, false, visitor) {
4021-
some(definition @ def_ty(class_id))
4031+
some(def_ty(class_id))
40224032
if self.structs.contains_key(class_id) => {
40234033
let has_constructor = self.structs.get(class_id);
40244034
let class_def = def_class(class_id,
40254035
has_constructor);
40264036
self.record_def(pattern.id, class_def);
40274037
}
4038+
some(definition @ def_variant(_, variant_id))
4039+
if self.structs.contains_key(variant_id) => {
4040+
self.record_def(pattern.id, definition);
4041+
}
40284042
_ => {
40294043
self.session.span_err(path.span,
40304044
fmt!("`%s` does not name a \
@@ -4450,13 +4464,16 @@ class Resolver {
44504464
// let bar = Bar { ... } // no type parameters
44514465
44524466
match self.resolve_path(path, TypeNS, false, visitor) {
4453-
some(definition @ def_ty(class_id))
4467+
some(def_ty(class_id))
44544468
if self.structs.contains_key(class_id) => {
4455-
44564469
let has_constructor = self.structs.get(class_id);
44574470
let class_def = def_class(class_id, has_constructor);
44584471
self.record_def(expr.id, class_def);
44594472
}
4473+
some(definition @ def_variant(_, class_id))
4474+
if self.structs.contains_key(class_id) => {
4475+
self.record_def(expr.id, definition);
4476+
}
44604477
_ => {
44614478
self.session.span_err(path.span,
44624479
fmt!{"`%s` does not name a \

0 commit comments

Comments
 (0)