Skip to content

Commit b68fd6c

Browse files
committed
---
yaml --- r: 14778 b: refs/heads/try c: 205cefd h: refs/heads/master v: v3
1 parent f2cce7a commit b68fd6c

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 35400e13ada84aeb578e37262a6bf16c48d128d7
5+
refs/heads/try: 205cefdc6e0e53c6df8075b5c37edd4e0803a598
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/tstate/states.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,9 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
550550
/* conservative approximation: if a loop contains a break
551551
or cont, we assume nothing about the poststate */
552552
/* which is still unsound -- see [Break-unsound] */
553-
if has_nonlocal_exits(body) {
553+
if may_break(body) {
554+
/* Only do this if there are *breaks* not conts.
555+
An infinite loop with conts is still an infinite loop. */
554556
ret changed | set_poststate_ann(fcx.ccx, e.id, pres);
555557
} else {
556558
ret changed | set_poststate_ann(fcx.ccx, e.id,

branches/try/src/rustc/util/common.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ fn has_nonlocal_exits(b: ast::blk) -> bool {
8383
ret *has_exits;
8484
}
8585

86+
/* FIXME: copy/paste, yuck */
87+
fn may_break(b: ast::blk) -> bool {
88+
let has_exits = @mutable false;
89+
fn visit_expr(flag: @mutable bool, e: @ast::expr) {
90+
alt e.node {
91+
ast::expr_break { *flag = true; }
92+
_ { }
93+
}
94+
}
95+
let v =
96+
visit::mk_simple_visitor(@{visit_expr: bind visit_expr(has_exits, _)
97+
with *visit::default_simple_visitor()});
98+
visit::visit_block(b, (), v);
99+
ret *has_exits;
100+
}
101+
86102
fn local_rhs_span(l: @ast::local, def: span) -> span {
87103
alt l.node.init { some(i) { ret i.expr.span; } _ { ret def; } }
88104
}

0 commit comments

Comments
 (0)