Skip to content

Commit b6542e4

Browse files
committed
---
yaml --- r: 1442 b: refs/heads/master c: 6c24d04 h: refs/heads/master v: v3
1 parent 0505c77 commit b6542e4

File tree

3 files changed

+12
-69
lines changed

3 files changed

+12
-69
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: 7a6ac1c00041fc8043e240c8fb7255251fea63f4
2+
refs/heads/master: 6c24d0403b2e8fefecc5eea11933d493a01f1daf

trunk/src/comp/middle/typeck.rs

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -913,43 +913,15 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
913913
// of the variant, which is either a tag type in the case of
914914
// nullary variants or a function type in the case of n-ary
915915
// variants.
916+
//
917+
// TODO: When we have type-parametric tags, this will get a little
918+
// trickier. Basically, we have to instantiate the variant type we
919+
// acquire here with the type parameters provided to us by
920+
// "expected".
916921

917-
// Grab the values for the type parameters of the tag from the
918-
// expected type.
919-
let vec[@ty.t] typaram_bindings = vec(); // FIXME: typestate botch
920-
alt (expected.struct) {
921-
case (ty.ty_tag(_, ?tps)) { typaram_bindings = tps; }
922-
case (_) {
923-
log "tag pattern didn't have tag type?!";
924-
fail;
925-
}
926-
}
927-
928-
// Get the item corresponding to the tag and its type.
929922
auto vdef = option.get[ast.variant_def](vdef_opt);
930923
auto variant_ty = fcx.ccx.item_types.get(vdef._1);
931924

932-
// FIXME: typestate botch
933-
let option.t[@ast.item] item_opt = none[@ast.item];
934-
alt (fcx.ccx.item_items.get(vdef._0)) {
935-
case (any_item_rust(?it)) { item_opt = some[@ast.item](it); }
936-
case (_) {
937-
log "tag item isn't a Rust item?!";
938-
fail;
939-
}
940-
}
941-
let @ast.item item = option.get[@ast.item](item_opt);
942-
943-
// Get the IDs of the type parameters from that item.
944-
let vec[ast.ty_param] ty_params = vec(); // FIXME: typestate botch
945-
alt (item.node) {
946-
case (ast.item_tag(_, _, ?tps, _)) { ty_params = tps; }
947-
case (_) {
948-
log "tag's corresponding item isn't a tag?!";
949-
fail;
950-
}
951-
}
952-
953925
auto subpats_len = _vec.len[@ast.pat](subpats);
954926
alt (variant_ty.struct) {
955927
case (ty.ty_tag(_, _)) {
@@ -958,14 +930,10 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
958930
p_1 = ast.pat_tag(id, subpats, vdef_opt, ast.ann_type(t));
959931
}
960932
case (ty.ty_fn(_, ?args, ?tag_ty)) {
961-
// N-ary tag variant.
962933
let vec[@ast.pat] new_subpats = vec();
963934
auto i = 0u;
964935
for (arg a in args) {
965-
auto arg_ty = ty.substitute_ty_params(ty_params,
966-
typaram_bindings, a.ty);
967-
auto new_subpat = demand_pat(fcx, arg_ty,
968-
subpats.(i));
936+
auto new_subpat = demand_pat(fcx, a.ty, subpats.(i));
969937
new_subpats += vec(new_subpat);
970938
i += 1u;
971939
}
@@ -1292,13 +1260,14 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
12921260
new_subpats += vec(check_pat(fcx, subpat));
12931261
}
12941262

1295-
auto tag_ty_g = generalize_ty(fcx.ccx, tag_ty);
1296-
auto ann = ast.ann_type(tag_ty_g);
1263+
auto ann = ast.ann_type(tag_ty);
12971264
new_pat = ast.pat_tag(p, new_subpats, vdef_opt, ann);
12981265
}
12991266

13001267
// Nullary variants have tag types.
1301-
case (ty.ty_tag(?tid, ?tps)) {
1268+
case (ty.ty_tag(?tid, _)) {
1269+
// TODO: ty params
1270+
13021271
auto subpats_len = _vec.len[@ast.pat](subpats);
13031272
if (subpats_len > 0u) {
13041273
// TODO: pluralize properly
@@ -1312,14 +1281,7 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
13121281
fail; // TODO: recover
13131282
}
13141283

1315-
// Add the appropriate number of type variables.
1316-
let vec[@ty.t] tys = vec();
1317-
auto i = 0u;
1318-
while (i < _vec.len[@ty.t](tps)) {
1319-
tys += vec(next_ty_var(fcx.ccx));
1320-
i += 1u;
1321-
}
1322-
1284+
let vec[@ty.t] tys = vec(); // FIXME
13231285
auto ann = ast.ann_type(plain_ty(ty.ty_tag(tid, tys)));
13241286
new_pat = ast.pat_tag(p, subpats, vdef_opt, ann);
13251287
}

trunk/src/test/run-pass/generic-tag-box-alt.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)