diff options
| author | Patrick Walton <[email protected]> | 2011-02-25 15:49:08 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-02-25 15:49:35 -0800 |
| commit | 6c24d0403b2e8fefecc5eea11933d493a01f1daf (patch) | |
| tree | 9aa52ab73cc0c2f2bc9dfbfe4e403c2d742095ae | |
| parent | Fix typo in crate directive evaluator. (diff) | |
| download | rust-6c24d0403b2e8fefecc5eea11933d493a01f1daf.tar.xz rust-6c24d0403b2e8fefecc5eea11933d493a01f1daf.zip | |
Revert "rustc: Push type parameters down through alt tag patterns; add a test" due to valgrind failures
This reverts commit 7a1d01effcfa5763bc62aefba40f67ad2130d28d.
| -rw-r--r-- | src/comp/middle/typeck.rs | 60 | ||||
| -rw-r--r-- | src/test/run-pass/generic-tag-box-alt.rs | 19 |
2 files changed, 11 insertions, 68 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 472bd8d3..ce1c59ec 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -913,43 +913,15 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat { // of the variant, which is either a tag type in the case of // nullary variants or a function type in the case of n-ary // variants. + // + // TODO: When we have type-parametric tags, this will get a little + // trickier. Basically, we have to instantiate the variant type we + // acquire here with the type parameters provided to us by + // "expected". - // Grab the values for the type parameters of the tag from the - // expected type. - let vec[@ty.t] typaram_bindings = vec(); // FIXME: typestate botch - alt (expected.struct) { - case (ty.ty_tag(_, ?tps)) { typaram_bindings = tps; } - case (_) { - log "tag pattern didn't have tag type?!"; - fail; - } - } - - // Get the item corresponding to the tag and its type. auto vdef = option.get[ast.variant_def](vdef_opt); auto variant_ty = fcx.ccx.item_types.get(vdef._1); - // FIXME: typestate botch - let option.t[@ast.item] item_opt = none[@ast.item]; - alt (fcx.ccx.item_items.get(vdef._0)) { - case (any_item_rust(?it)) { item_opt = some[@ast.item](it); } - case (_) { - log "tag item isn't a Rust item?!"; - fail; - } - } - let @ast.item item = option.get[@ast.item](item_opt); - - // Get the IDs of the type parameters from that item. - let vec[ast.ty_param] ty_params = vec(); // FIXME: typestate botch - alt (item.node) { - case (ast.item_tag(_, _, ?tps, _)) { ty_params = tps; } - case (_) { - log "tag's corresponding item isn't a tag?!"; - fail; - } - } - auto subpats_len = _vec.len[@ast.pat](subpats); alt (variant_ty.struct) { case (ty.ty_tag(_, _)) { @@ -958,14 +930,10 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat { p_1 = ast.pat_tag(id, subpats, vdef_opt, ast.ann_type(t)); } case (ty.ty_fn(_, ?args, ?tag_ty)) { - // N-ary tag variant. let vec[@ast.pat] new_subpats = vec(); auto i = 0u; for (arg a in args) { - auto arg_ty = ty.substitute_ty_params(ty_params, - typaram_bindings, a.ty); - auto new_subpat = demand_pat(fcx, arg_ty, - subpats.(i)); + auto new_subpat = demand_pat(fcx, a.ty, subpats.(i)); new_subpats += vec(new_subpat); i += 1u; } @@ -1292,13 +1260,14 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { new_subpats += vec(check_pat(fcx, subpat)); } - auto tag_ty_g = generalize_ty(fcx.ccx, tag_ty); - auto ann = ast.ann_type(tag_ty_g); + auto ann = ast.ann_type(tag_ty); new_pat = ast.pat_tag(p, new_subpats, vdef_opt, ann); } // Nullary variants have tag types. - case (ty.ty_tag(?tid, ?tps)) { + case (ty.ty_tag(?tid, _)) { + // TODO: ty params + auto subpats_len = _vec.len[@ast.pat](subpats); if (subpats_len > 0u) { // TODO: pluralize properly @@ -1312,14 +1281,7 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { fail; // TODO: recover } - // Add the appropriate number of type variables. - let vec[@ty.t] tys = vec(); - auto i = 0u; - while (i < _vec.len[@ty.t](tps)) { - tys += vec(next_ty_var(fcx.ccx)); - i += 1u; - } - + let vec[@ty.t] tys = vec(); // FIXME auto ann = ast.ann_type(plain_ty(ty.ty_tag(tid, tys))); new_pat = ast.pat_tag(p, subpats, vdef_opt, ann); } diff --git a/src/test/run-pass/generic-tag-box-alt.rs b/src/test/run-pass/generic-tag-box-alt.rs deleted file mode 100644 index 2727885a..00000000 --- a/src/test/run-pass/generic-tag-box-alt.rs +++ /dev/null @@ -1,19 +0,0 @@ -tag foo[T] { - arm(@T); -} - -fn altfoo[T](foo[T] f) { - auto hit = false; - alt (f) { - case (arm[T](?x)) { - log "in arm"; - hit = true; - } - } - check (hit); -} - -fn main() { - altfoo[int](arm[int](@10)); -} - |