Skip to content

Commit 3f283bb

Browse files
committed
rustc: Don't recurse in seq_preconds. Consumes too much stack
1 parent afca68b commit 3f283bb

File tree

2 files changed

+2020
-15
lines changed

2 files changed

+2020
-15
lines changed

src/rustc/middle/tstate/bitvectors.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,26 @@ fn seq_preconds(fcx: fn_ctxt, pps: [pre_and_post]) -> precond {
8282

8383
fn seq_preconds_go(fcx: fn_ctxt, pps: [pre_and_post], first: pre_and_post)
8484
-> precond {
85-
let sz: uint = vec::len(pps);
86-
if sz >= 1u {
87-
let second = pps[0];
88-
assert (pps_len(second) == num_constraints(fcx.enclosing));
89-
let second_pre = clone(second.precondition);
90-
difference(second_pre, first.postcondition);
91-
let next_first = clone(first.precondition);
92-
union(next_first, second_pre);
93-
let next_first_post = clone(first.postcondition);
94-
seq_tritv(next_first_post, second.postcondition);
95-
ret seq_preconds_go(fcx, vec::slice(pps, 1u, sz),
96-
@{precondition: next_first,
97-
postcondition: next_first_post});
98-
} else { ret first.precondition; }
85+
let mut pps = pps;
86+
let mut first = first;
87+
loop {
88+
let sz: uint = vec::len(pps);
89+
if sz >= 1u {
90+
let second = pps[0];
91+
assert (pps_len(second) == num_constraints(fcx.enclosing));
92+
let second_pre = clone(second.precondition);
93+
difference(second_pre, first.postcondition);
94+
let next_first = clone(first.precondition);
95+
union(next_first, second_pre);
96+
let next_first_post = clone(first.postcondition);
97+
seq_tritv(next_first_post, second.postcondition);
98+
pps = vec::slice(pps, 1u, sz);
99+
first = @{precondition: next_first,
100+
postcondition: next_first_post};
101+
} else { ret first.precondition; }
102+
}
99103
}
100104

101-
102105
if sz >= 1u {
103106
let first = pps[0];
104107
assert (pps_len(first) == num_vars);

0 commit comments

Comments
 (0)