From 26e1cacb216fc754650a58b22bbbd91ab945089d Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Fri, 26 Aug 2011 00:39:50 -0700 Subject: [PATCH] Let typestate constraints mention pattern-bound vars --- src/comp/middle/tstate/auxiliary.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/comp/middle/tstate/auxiliary.rs b/src/comp/middle/tstate/auxiliary.rs index 6aab9e5aed4..03d31c67369 100644 --- a/src/comp/middle/tstate/auxiliary.rs +++ b/src/comp/middle/tstate/auxiliary.rs @@ -621,9 +621,18 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: &@expr) -> @constr_arg_use { carg_ident({ident: p.node.idents[0], node: a_id.node})); } - _ { + some (def_binding(b_id)) { + ret @respan(p.span, + carg_ident({ident: p.node.idents[0], + node: b_id.node})); + } + some(_) { tcx.sess.bug("exprs_to_constr_args: non-local variable " + "as pred arg"); + } + none { + tcx.sess.bug("exprs_to_constr_args: NONE " + + "as pred arg"); } } @@ -646,10 +655,6 @@ fn exprs_to_constr_args(tcx: ty::ctxt, args: &[@expr]) -> [@constr_arg_use] { fn expr_to_constr(tcx: ty::ctxt, e: &@expr) -> sp_constr { alt e.node { - - - // FIXME change the first pattern to expr_path to test a - // typechecker bug expr_call(operator, args) { alt operator.node { expr_path(p) {