Skip to content

Commit 98260a2

Browse files
committed
Handle infinite-loop poststate correctly in typestate
If control passes an infinite loop (that doesn't have non-local exits), then everything is true.
1 parent e34fad7 commit 98260a2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/rustc/middle/tstate/states.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
554554
ret changed | set_poststate_ann(fcx.ccx, e.id, pres);
555555
} else {
556556
ret changed | set_poststate_ann(fcx.ccx, e.id,
557-
block_poststate(fcx.ccx, body));
557+
false_postcond(num_constrs));
558558
}
559559
}
560560
expr_for(d, index, body) {

src/test/compile-fail/while-loop-pred-constraints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ fn main() {
1111
check (even(y));
1212
loop {
1313
print_even(y);
14-
loop { loop { loop { y += x; } } }
14+
while true { while true { while true { y += x; } } }
1515
}
1616
}

0 commit comments

Comments
 (0)