mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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
This commit is contained in:
parent
03984561d4
commit
48c763c098
@ -190,7 +190,7 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
|
|||||||
%u exprs vs. %u ops",
|
%u exprs vs. %u ops",
|
||||||
vec::len(bs), vec::len(ops)]);
|
vec::len(bs), vec::len(ops)]);
|
||||||
}
|
}
|
||||||
ret find_pre_post_state_exprs(fcx, expr_poststate(fcx.ccx, a), id, ops,
|
ret find_pre_post_state_exprs(fcx, pres, id, ops,
|
||||||
bs, cf) || changed;
|
bs, cf) || changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
src/test/run-pass/issue-1895.rs
Normal file
7
src/test/run-pass/issue-1895.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fn main() {
|
||||||
|
let x = 1;
|
||||||
|
let y = fn@[move x]() -> int {
|
||||||
|
x
|
||||||
|
}();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user