diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-05-18 14:28:34 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-05-18 14:28:39 -0700 |
| commit | 3f283bb168564b365cd361d8afff7d3809f02f02 (patch) | |
| tree | 1abc09a5a22dc3a1082ea63d697747ff1466d792 /src/rustc | |
| parent | afca68b82089db479594c1d012375c7791cb5bd5 (diff) | |
| download | rust-3f283bb168564b365cd361d8afff7d3809f02f02.tar.gz rust-3f283bb168564b365cd361d8afff7d3809f02f02.zip | |
rustc: Don't recurse in seq_preconds. Consumes too much stack
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/middle/tstate/bitvectors.rs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/rustc/middle/tstate/bitvectors.rs b/src/rustc/middle/tstate/bitvectors.rs index f1be864f48a..95bc4302035 100644 --- a/src/rustc/middle/tstate/bitvectors.rs +++ b/src/rustc/middle/tstate/bitvectors.rs @@ -82,23 +82,26 @@ fn seq_preconds(fcx: fn_ctxt, pps: [pre_and_post]) -> precond { fn seq_preconds_go(fcx: fn_ctxt, pps: [pre_and_post], first: pre_and_post) -> precond { - let sz: uint = vec::len(pps); - if sz >= 1u { - let second = pps[0]; - assert (pps_len(second) == num_constraints(fcx.enclosing)); - let second_pre = clone(second.precondition); - difference(second_pre, first.postcondition); - let next_first = clone(first.precondition); - union(next_first, second_pre); - let next_first_post = clone(first.postcondition); - seq_tritv(next_first_post, second.postcondition); - ret seq_preconds_go(fcx, vec::slice(pps, 1u, sz), - @{precondition: next_first, - postcondition: next_first_post}); - } else { ret first.precondition; } + let mut pps = pps; + let mut first = first; + loop { + let sz: uint = vec::len(pps); + if sz >= 1u { + let second = pps[0]; + assert (pps_len(second) == num_constraints(fcx.enclosing)); + let second_pre = clone(second.precondition); + difference(second_pre, first.postcondition); + let next_first = clone(first.precondition); + union(next_first, second_pre); + let next_first_post = clone(first.postcondition); + seq_tritv(next_first_post, second.postcondition); + pps = vec::slice(pps, 1u, sz); + first = @{precondition: next_first, + postcondition: next_first_post}; + } else { ret first.precondition; } + } } - if sz >= 1u { let first = pps[0]; assert (pps_len(first) == num_vars); |
