diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index f95f54f697b..6ada125be07 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -258,9 +258,9 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, vdefs: {enm: def_id, var: def_id}, val: ValueRef) -> {vals: [ValueRef], bcx: block} { let ccx = bcx.fcx.ccx, bcx = bcx; - // invariant: - // pat_id must have the same length ty_param_substs as vdefs? - let ty_param_substs = node_id_type_params(bcx, pat_id); + let enum_ty_substs = alt check ty::get(node_id_type(bcx, pat_id)).struct { + ty::ty_enum(id, tps) { assert id == vdefs.enm; tps } + }; let blobptr = val; let variants = ty::enum_variants(ccx.tcx, vdefs.enm); let args = []; @@ -275,12 +275,8 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, let vdefs_tg = vdefs.enm; let vdefs_var = vdefs.var; while i < size { - let r = - // invariant needed: - // how do we know it even makes sense to pass in ty_param_substs - // here? What if it's [] and the enum type has variables in it? - GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var, - ty_param_substs, i); + let r = GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var, + enum_ty_substs, i); bcx = r.bcx; args += [r.val]; i += 1u; diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 33be02a1586..88911e2eae7 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -1445,15 +1445,7 @@ fn check_pat(fcx: @fn_ctxt, map: pat_util::pat_id_map, pat: @ast::pat, let tcx = fcx.ccx.tcx; alt pat.node { ast::pat_wild { - alt structure_of(fcx, pat.span, expected) { - ty::ty_enum(_, expected_tps) { - write_ty_substs(tcx, pat.id, expected, - expected_tps); - } - _ { - write_ty(tcx, pat.id, expected); - } - } + write_ty(tcx, pat.id, expected); } ast::pat_lit(lt) { check_expr_with(fcx, lt, expected);