diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-03-01 09:13:46 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-03-01 09:16:26 -0800 |
| commit | 48c763c098a5609a52862ff57401087b9f162bec (patch) | |
| tree | d61f12aa4f89f0a98b543a6715bf5ae3cb02931c | |
| parent | 03984561d43130cb8d51025604ac882470d47e3c (diff) | |
| download | rust-48c763c098a5609a52862ff57401087b9f162bec.tar.gz rust-48c763c098a5609a52862ff57401087b9f162bec.zip | |
Use the correct prestate for calls
The prestate for calls was getting set incorrectly to the poststate for the operator in the call. This worked before since most of the time, operator expressions are pure. Issue 1895 shows how this breaks when the operator is a closure that has a move-in capture clause. (I had a several-day, multi-file patch for this that didn't work... and then it turned out to be a one-line fix. The joys of programming.) Closes #1895
| -rw-r--r-- | src/comp/middle/tstate/states.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/issue-1895.rs | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs index bba7b4c4834..b90e39f2b23 100644 --- a/src/comp/middle/tstate/states.rs +++ b/src/comp/middle/tstate/states.rs @@ -190,8 +190,8 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr, %u exprs vs. %u ops", vec::len(bs), vec::len(ops)]); } - ret find_pre_post_state_exprs(fcx, expr_poststate(fcx.ccx, a), id, ops, - bs, cf) || changed; + ret find_pre_post_state_exprs(fcx, pres, id, ops, + bs, cf) || changed; } fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id, diff --git a/src/test/run-pass/issue-1895.rs b/src/test/run-pass/issue-1895.rs new file mode 100644 index 00000000000..3be9fa65b83 --- /dev/null +++ b/src/test/run-pass/issue-1895.rs @@ -0,0 +1,7 @@ +fn main() { + let x = 1; + let y = fn@[move x]() -> int { + x + }(); +} + |
