Skip to content

Commit ef739f1

Browse files
committed
---
yaml --- r: 987 b: refs/heads/master c: fd600ba h: refs/heads/master i: 985: bab19e4 983: 11ca011 v: v3
1 parent 44ed69b commit ef739f1

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cd97b9d965ada49ed07af7ee651b2b2266df4cec
2+
refs/heads/master: fd600bad4666758088ec69a355a0dbd86bb11c22

trunk/src/comp/front/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ tag mod_index_entry {
183183
type _mod = rec(vec[@item] items,
184184
hashmap[ident,mod_index_entry] index);
185185

186-
type variant = rec(str name, vec[@ty] args, def_id id);
186+
type variant = rec(str name, vec[@ty] args, def_id id, ann ann);
187187

188188
type item = spanned[item_];
189189
tag item_ {

trunk/src/comp/front/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,8 @@ impure fn parse_item_tag(parser p) -> @ast.item {
12831283
expect(p, token.SEMI);
12841284

12851285
auto id = p.next_def_id();
1286-
variants += vec(rec(name=name, args=args, id=id));
1286+
variants += vec(rec(name=name, args=args, id=id,
1287+
ann=ast.ann_none));
12871288
}
12881289
case (token.RBRACE) { /* empty */ }
12891290
case (_) {

trunk/src/comp/middle/fold.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
591591
for (@ast.ty t in v.args) {
592592
new_args += vec(fold_ty[ENV](env_, fld, t));
593593
}
594-
new_variants += rec(name=v.name, args=new_args, id=v.id);
594+
new_variants += rec(name=v.name, args=new_args, id=v.id,
595+
ann=v.ann);
595596
}
596597
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
597598
ty_params, id);

trunk/src/comp/middle/typeck.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,12 @@ fn collect_item_types(@ast.crate crate) -> tup(@ast.crate, @ty_table) {
402402
}
403403
}
404404

405-
fn add_tag_variant_types(@hashmap[ast.def_id,@ast.item] id_to_ty_item,
405+
fn get_tag_variant_types(@hashmap[ast.def_id,@ast.item] id_to_ty_item,
406406
@ty_table item_to_ty,
407407
&ast.def_id tag_id,
408-
&vec[ast.variant] variants) {
408+
&vec[ast.variant] variants) -> vec[ast.variant] {
409+
let vec[ast.variant] result = vec();
410+
409411
for (ast.variant variant in variants) {
410412
// Nullary tag constructors get turned into constants; n-ary tag
411413
// constructors get turned into functions.
@@ -427,7 +429,12 @@ fn collect_item_types(@ast.crate crate) -> tup(@ast.crate, @ty_table) {
427429
}
428430

429431
item_to_ty.insert(variant.id, result_ty);
432+
433+
auto variant_t = rec(ann=ast.ann_type(result_ty) with variant);
434+
result += vec(variant_t);
430435
}
436+
437+
ret result;
431438
}
432439

433440
// First pass: collect all type item IDs.
@@ -463,10 +470,12 @@ fn collect_item_types(@ast.crate crate) -> tup(@ast.crate, @ty_table) {
463470
case (ast.item_mod(_, _, _)) {
464471
result = it.node;
465472
}
466-
case (ast.item_tag(_, ?variants, _, ?tag_id)) {
467-
add_tag_variant_types(id_to_ty_item, item_to_ty, tag_id,
468-
variants);
469-
result = it.node;
473+
case (ast.item_tag(?ident, ?variants, ?tps, ?tag_id)) {
474+
auto variants_t = get_tag_variant_types(id_to_ty_item,
475+
item_to_ty,
476+
tag_id,
477+
variants);
478+
result = ast.item_tag(ident, variants_t, tps, tag_id);
470479
}
471480
}
472481
items_t += vec(@fold.respan[ast.item_](it.span, result));

0 commit comments

Comments
 (0)