Skip to content

Commit f8eb8b8

Browse files
committed
---
yaml --- r: 1953 b: refs/heads/master c: c66edca h: refs/heads/master i: 1951: 4c138ff v: v3
1 parent a4e378b commit f8eb8b8

File tree

10 files changed

+36
-37
lines changed

10 files changed

+36
-37
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: 1eeedbd00865fbc8c2650b8e2feba0b6e7f290dc
2+
refs/heads/master: c66edca83d04c5be5c27629b43c2c180a67f2d63

trunk/src/comp/front/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ tag item_ {
404404
item_mod(ident, _mod, def_id);
405405
item_native_mod(ident, native_mod, def_id);
406406
item_ty(ident, @ty, vec[ty_param], def_id, ann);
407-
item_tag(ident, vec[variant], vec[ty_param], def_id);
407+
item_tag(ident, vec[variant], vec[ty_param], def_id, ann);
408408
item_obj(ident, _obj, vec[ty_param], obj_def_ids, ann);
409409
}
410410
@@ -448,7 +448,7 @@ fn index_item(mod_index index, @item it) {
448448
case (ast.item_ty(?id, _, _, _, _)) {
449449
index.insert(id, ast.mie_item(it));
450450
}
451-
case (ast.item_tag(?id, ?variants, _, _)) {
451+
case (ast.item_tag(?id, ?variants, _, _, _)) {
452452
index.insert(id, ast.mie_item(it));
453453
let uint variant_idx = 0u;
454454
for (ast.variant v in variants) {
@@ -505,7 +505,7 @@ fn index_stmt(block_index index, @stmt s) {
505505
case (ast.item_ty(?i, _, _, _, _)) {
506506
index.insert(i, ast.bie_item(it));
507507
}
508-
case (ast.item_tag(?i, ?variants, _, _)) {
508+
case (ast.item_tag(?i, ?variants, _, _, _)) {
509509
index.insert(i, ast.bie_item(it));
510510
let uint vid = 0u;
511511
for (ast.variant v in variants) {

trunk/src/comp/front/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,8 @@ impure fn parse_item_tag(parser p) -> @ast.item {
20712071
p.bump();
20722072

20732073
auto hi = p.get_span();
2074-
auto item = ast.item_tag(id, variants, ty_params, p.next_def_id());
2074+
auto item = ast.item_tag(id, variants, ty_params, p.next_def_id(),
2075+
ast.ann_none);
20752076
ret @spanned(lo, hi, item);
20762077
}
20772078

trunk/src/comp/middle/fold.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ type ast_fold[ENV] =
269269
(fn(&ENV e, &span sp, ident ident,
270270
vec[ast.variant] variants,
271271
vec[ast.ty_param] ty_params,
272-
def_id id) -> @item) fold_item_tag,
272+
def_id id, ann a) -> @item) fold_item_tag,
273273

274274
(fn(&ENV e, &span sp, ident ident,
275275
&ast._obj ob,
@@ -971,7 +971,7 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
971971
ret fld.fold_item_ty(env_, i.span, ident, ty_, params, id, ann);
972972
}
973973

974-
case (ast.item_tag(?ident, ?variants, ?ty_params, ?id)) {
974+
case (ast.item_tag(?ident, ?variants, ?ty_params, ?id, ?ann)) {
975975
let vec[ast.variant] new_variants = vec();
976976
for (ast.variant v in variants) {
977977
let vec[ast.variant_arg] new_args = vec();
@@ -984,7 +984,7 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
984984
new_variants += vec(respan[ast.variant_](v.span, new_v));
985985
}
986986
ret fld.fold_item_tag(env_, i.span, ident, new_variants,
987-
ty_params, id);
987+
ty_params, id, ann);
988988
}
989989

990990
case (ast.item_obj(?ident, ?ob, ?tps, ?odid, ?ann)) {
@@ -1440,8 +1440,8 @@ fn identity_fold_native_item_ty[ENV](&ENV e, &span sp, ident i,
14401440
fn identity_fold_item_tag[ENV](&ENV e, &span sp, ident i,
14411441
vec[ast.variant] variants,
14421442
vec[ast.ty_param] ty_params,
1443-
def_id id) -> @item {
1444-
ret @respan(sp, ast.item_tag(i, variants, ty_params, id));
1443+
def_id id, ann a) -> @item {
1444+
ret @respan(sp, ast.item_tag(i, variants, ty_params, id, a));
14451445
}
14461446

14471447
fn identity_fold_item_obj[ENV](&ENV e, &span sp, ident i,
@@ -1654,7 +1654,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
16541654
fold_item_ty = bind identity_fold_item_ty[ENV](_,_,_,_,_,_,_),
16551655
fold_native_item_ty =
16561656
bind identity_fold_native_item_ty[ENV](_,_,_,_),
1657-
fold_item_tag = bind identity_fold_item_tag[ENV](_,_,_,_,_,_),
1657+
fold_item_tag = bind identity_fold_item_tag[ENV](_,_,_,_,_,_,_),
16581658
fold_item_obj = bind identity_fold_item_obj[ENV](_,_,_,_,_,_,_),
16591659

16601660
fold_view_item_use =

trunk/src/comp/middle/metadata.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn encode_module_item_paths(&ebml.writer ebml_w,
262262
encode_def_id(ebml_w, did);
263263
ebml.end_tag(ebml_w);
264264
}
265-
case (ast.item_tag(?id, ?variants, ?tps, ?did)) {
265+
case (ast.item_tag(?id, ?variants, ?tps, ?did, _)) {
266266
add_to_index(ebml_w, path, index, id);
267267
ebml.start_tag(ebml_w, tag_paths_data_item);
268268
encode_name(ebml_w, id);
@@ -403,11 +403,12 @@ fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w,
403403
encode_type(ebml_w, trans.node_ann_type(cx, ann));
404404
ebml.end_tag(ebml_w);
405405
}
406-
case (ast.item_tag(?id, ?variants, ?tps, ?did)) {
406+
case (ast.item_tag(?id, ?variants, ?tps, ?did, ?ann)) {
407407
ebml.start_tag(ebml_w, tag_items_data_item);
408408
encode_def_id(ebml_w, did);
409409
encode_kind(ebml_w, 't' as u8);
410410
encode_type_params(ebml_w, tps);
411+
encode_type(ebml_w, trans.node_ann_type(cx, ann));
411412
ebml.end_tag(ebml_w);
412413

413414
encode_tag_variant_info(cx, ebml_w, did, variants);

trunk/src/comp/middle/resolve.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns)
319319
case (ast.item_ty(_, _, _, ?id, _)) {
320320
ret def_wrap_other(ast.def_ty(id));
321321
}
322-
case (ast.item_tag(_, _, _, ?id)) {
322+
case (ast.item_tag(_, _, _, ?id, _)) {
323323
ret def_wrap_other(ast.def_ty(id));
324324
}
325325
case (ast.item_obj(_, _, _, ?odid, _)) {
@@ -388,7 +388,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns)
388388
}
389389
case (ast.mie_tag_variant(?item, ?variant_idx)) {
390390
alt (item.node) {
391-
case (ast.item_tag(_, ?variants, _, ?tid)) {
391+
case (ast.item_tag(_, ?variants, _, ?tid, _)) {
392392
auto vid = variants.(variant_idx).node.id;
393393
auto t = ast.def_variant(tid, vid);
394394
ret some[def_wrap](def_wrap_other(t));
@@ -445,7 +445,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns)
445445

446446
fn found_tag(@ast.item item, uint variant_idx) -> def_wrap {
447447
alt (item.node) {
448-
case (ast.item_tag(_, ?variants, _, ?tid)) {
448+
case (ast.item_tag(_, ?variants, _, ?tid, _)) {
449449
auto vid = variants.(variant_idx).node.id;
450450
auto t = ast.def_variant(tid, vid);
451451
ret def_wrap_other(t);
@@ -505,7 +505,7 @@ fn lookup_name_wrapped(&env e, ast.ident i, namespace ns)
505505
}
506506
}
507507
}
508-
case (ast.item_tag(_, ?variants, ?ty_params, ?tag_id)) {
508+
case (ast.item_tag(_,?variants,?ty_params,?tag_id,_)) {
509509
for (ast.ty_param tp in ty_params) {
510510
if (_str.eq(tp.ident, i)) {
511511
auto t = ast.def_ty_arg(tp.id);

trunk/src/comp/middle/trans.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ fn tag_ty_params(@crate_ctxt cx, ast.def_id id) -> vec[ast.def_id] {
19131913
fn tag_variants(@crate_ctxt cx, ast.def_id id) -> vec[ast.variant] {
19141914
check (cx.items.contains_key(id));
19151915
alt (cx.items.get(id).node) {
1916-
case (ast.item_tag(_, ?variants, _, _)) { ret variants; }
1916+
case (ast.item_tag(_, ?variants, _, _, _)) { ret variants; }
19171917
}
19181918
fail; // not reached
19191919
}
@@ -3703,7 +3703,7 @@ fn trans_path(@block_ctxt cx, &ast.path p, &option.t[ast.def] dopt,
37033703
auto params = ty.item_ty(tag_item)._0;
37043704
auto fty = plain_ty(ty.ty_nil);
37053705
alt (tag_item.node) {
3706-
case (ast.item_tag(_, ?variants, _, _)) {
3706+
case (ast.item_tag(_, ?variants, _, _, _)) {
37073707
for (ast.variant v in variants) {
37083708
if (v.node.id == vid) {
37093709
fty = node_ann_type(cx.fcx.ccx,
@@ -5943,7 +5943,7 @@ fn trans_item(@crate_ctxt cx, &ast.item item) {
59435943
auto sub_cx = extend_path(cx, name);
59445944
trans_mod(sub_cx, m);
59455945
}
5946-
case (ast.item_tag(?name, ?variants, ?tps, ?tag_id)) {
5946+
case (ast.item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
59475947
auto sub_cx = extend_path(cx, name);
59485948
auto i = 0;
59495949
for (ast.variant variant in variants) {
@@ -6162,7 +6162,7 @@ fn item_name(@ast.item i) -> str {
61626162
case (ast.item_mod(?name, _, _)) {
61636163
ret name;
61646164
}
6165-
case (ast.item_tag(?name, _, _, _)) {
6165+
case (ast.item_tag(?name, _, _, _, _)) {
61666166
ret name;
61676167
}
61686168
case (ast.item_const(?name, _, _, _, _)) {
@@ -6211,7 +6211,7 @@ fn collect_item(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
62116211
cx.items.insert(did, i);
62126212
}
62136213

6214-
case (ast.item_tag(?name, ?variants, ?tps, ?tag_id)) {
6214+
case (ast.item_tag(?name, ?variants, ?tps, ?tag_id, _)) {
62156215
cx.items.insert(tag_id, i);
62166216
}
62176217

@@ -6272,7 +6272,7 @@ fn collect_tag_ctor(&@crate_ctxt cx, @ast.item i) -> @crate_ctxt {
62726272

62736273
alt (i.node) {
62746274

6275-
case (ast.item_tag(_, ?variants, ?tps, _)) {
6275+
case (ast.item_tag(_, ?variants, ?tps, _, _)) {
62766276
for (ast.variant variant in variants) {
62776277
if (_vec.len[ast.variant_arg](variant.node.args) != 0u) {
62786278
decl_fn_and_pair(extend_path(cx, variant.node.name),
@@ -6302,7 +6302,7 @@ fn collect_tag_ctors(@crate_ctxt cx, @ast.crate crate) {
63026302

63036303
fn trans_constant(&@crate_ctxt cx, @ast.item it) -> @crate_ctxt {
63046304
alt (it.node) {
6305-
case (ast.item_tag(_, ?variants, _, ?tag_id)) {
6305+
case (ast.item_tag(_, ?variants, _, ?tag_id, _)) {
63066306
auto i = 0u;
63076307
auto n_variants = _vec.len[ast.variant](variants);
63086308
while (i < n_variants) {

trunk/src/comp/middle/ty.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,14 +706,9 @@ fn item_ty(@ast.item it) -> ty_params_and_ty {
706706
ty_params = tps;
707707
result_ty = ann_to_type(ann);
708708
}
709-
case (ast.item_tag(_, _, ?tps, ?did)) {
710-
// Create a new generic polytype.
709+
case (ast.item_tag(_, _, ?tps, ?did, ?ann)) {
711710
ty_params = tps;
712-
let vec[@t] subtys = vec();
713-
for (ast.ty_param tp in tps) {
714-
subtys += vec(plain_ty(ty_param(tp.id)));
715-
}
716-
result_ty = plain_ty(ty_tag(did, subtys));
711+
result_ty = ann_to_type(ann);
717712
}
718713
case (ast.item_obj(_, _, ?tps, _, ?ann)) {
719714
ty_params = tps;

trunk/src/comp/middle/typeck.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
586586
ret tpt;
587587
}
588588

589-
case (ast.item_tag(_, _, ?tps, ?def_id)) {
589+
case (ast.item_tag(_, _, ?tps, ?def_id, _)) {
590590
// Create a new generic polytype.
591591
let vec[@ty.t] subtys = vec();
592592
for (ast.ty_param tp in tps) {
@@ -694,7 +694,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
694694
case (ast.item_ty(_, _, _, ?def_id, _)) {
695695
id_to_ty_item.insert(def_id, any_item_rust(i));
696696
}
697-
case (ast.item_tag(_, _, _, ?def_id)) {
697+
case (ast.item_tag(_, _, _, ?def_id, _)) {
698698
id_to_ty_item.insert(def_id, any_item_rust(i));
699699
}
700700
case (ast.item_obj(_, _, _, ?odid, _)) {
@@ -870,14 +870,16 @@ fn collect_item_types(session.session sess, @ast.crate crate)
870870
fn fold_item_tag(&@env e, &span sp, ast.ident i,
871871
vec[ast.variant] variants,
872872
vec[ast.ty_param] ty_params,
873-
ast.def_id id) -> @ast.item {
873+
ast.def_id id, ast.ann a) -> @ast.item {
874874
auto variants_t = get_tag_variant_types(e.sess,
875875
e.id_to_ty_item,
876876
e.type_cache,
877877
id,
878878
variants,
879879
ty_params);
880-
auto item = ast.item_tag(i, variants_t, ty_params, id);
880+
auto typ = e.type_cache.get(id)._1;
881+
auto item = ast.item_tag(i, variants_t, ty_params, id,
882+
ast.ann_type(typ, none[vec[@ty.t]]));
881883
ret @fold.respan[ast.item_](sp, item);
882884
}
883885

@@ -890,7 +892,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
890892
fold_native_item_fn = bind fold_native_item_fn(_,_,_,_,_,_,_,_),
891893
fold_item_obj = bind fold_item_obj(_,_,_,_,_,_,_),
892894
fold_item_ty = bind fold_item_ty(_,_,_,_,_,_,_),
893-
fold_item_tag = bind fold_item_tag(_,_,_,_,_,_)
895+
fold_item_tag = bind fold_item_tag(_,_,_,_,_,_,_)
894896
with *fld_2);
895897
auto crate_ = fold.fold_crate[@env](e, fld_2, crate);
896898
ret tup(crate_, type_cache, id_to_ty_item);

trunk/src/comp/pretty/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impure fn print_item(ps s, @ast.item item) {
240240
print_type(s, ty);
241241
wrd(s.s, ";");
242242
}
243-
case (ast.item_tag(?id,?variants,?params,_)) {
243+
case (ast.item_tag(?id,?variants,?params,_,_)) {
244244
wrd1(s, "tag");
245245
wrd(s.s, id);
246246
print_type_params(s, params);

0 commit comments

Comments
 (0)