From 7b81cd8930079684d8b66bd7086931c969ef43a3 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 7 Mar 2012 09:19:29 +0100 Subject: [PATCH] Fix #1503 in a saner way Closes #1933 --- src/rustc/middle/trans/alt.rs | 14 +++++--------- src/rustc/middle/typeck.rs | 10 +--------- 2 files changed, 6 insertions(+), 18 deletions(-) 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);