diff options
| author | Patrick Walton <[email protected]> | 2011-03-09 11:08:59 -0800 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-03-09 11:08:59 -0800 |
| commit | 50da3ea5bcf31d3c4784f2e5158fd1e7d74aa2d6 (patch) | |
| tree | 5ccc74aac133abf4bb0ed9e1a8e480cdfc4f8f21 | |
| parent | rustc: Factor the type parameter and type lookup out of instantiate_path(), a... (diff) | |
| download | rust-50da3ea5bcf31d3c4784f2e5158fd1e7d74aa2d6.tar.xz rust-50da3ea5bcf31d3c4784f2e5158fd1e7d74aa2d6.zip | |
rustc: Instantiate tag patterns with the type parameters supplied by the programmer. size-and-align.rs typechecks now.
| -rw-r--r-- | src/comp/middle/typeck.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 0fc99204..50ac6bb7 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1461,6 +1461,12 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { auto t = fcx.ccx.item_types.get(vdef._1); auto len = _vec.len[ast.ident](p.node.idents); auto last_id = p.node.idents.(len - 1u); + + auto ty_params = fcx.ccx.item_ty_params.get(vdef._0); + auto tag_ty = fcx.ccx.item_types.get(vdef._0); + auto tpt = tup(some(ty_params), tag_ty); + auto ann = instantiate_path(fcx, p, tpt, pat.span); + alt (t.struct) { // N-ary variants have function types. case (ty.ty_fn(_, ?args, ?tag_ty)) { @@ -1483,14 +1489,11 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { new_subpats += vec(check_pat(fcx, subpat)); } - auto ann = ast.ann_type(tag_ty, none[vec[@ty.t]]); new_pat = ast.pat_tag(p, new_subpats, vdef_opt, ann); } // Nullary variants have tag types. case (ty.ty_tag(?tid, _)) { - // TODO: ty params - auto subpats_len = _vec.len[@ast.pat](subpats); if (subpats_len > 0u) { // TODO: pluralize properly @@ -1504,9 +1507,6 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat { fail; // TODO: recover } - let vec[@ty.t] tys = vec(); // FIXME - auto ann = ast.ann_type(plain_ty(ty.ty_tag(tid, tys)), - none[vec[@ty.t]]); new_pat = ast.pat_tag(p, subpats, vdef_opt, ann); } } |