summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-12-07 14:09:45 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-12-07 14:09:45 +0100
commitd28e0c0c0ae329705a063a025b853b292ff033a7 (patch)
tree3f9f2dd83bb681777104fe77d5fc20e0903b6a42 /src/comp
parent9656ceac60258c4189c31b402def67039ae17822 (diff)
downloadrust-d28e0c0c0ae329705a063a025b853b292ff033a7.tar.gz
rust-d28e0c0c0ae329705a063a025b853b292ff033a7.zip
Make typestate properly descend pattern guards
Closes #1265
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/tstate/pre_post_conditions.rs4
-rw-r--r--src/comp/middle/tstate/states.rs6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/comp/middle/tstate/pre_post_conditions.rs b/src/comp/middle/tstate/pre_post_conditions.rs
index d0ac63704d7..d8e57c90986 100644
--- a/src/comp/middle/tstate/pre_post_conditions.rs
+++ b/src/comp/middle/tstate/pre_post_conditions.rs
@@ -452,6 +452,10 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
       expr_alt(ex, alts) {
         find_pre_post_expr(fcx, ex);
         fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post {
+            alt an_alt.guard {
+              some(e) { find_pre_post_expr(fcx, e); }
+              _ {}
+            }
             find_pre_post_block(fcx, an_alt.body);
             ret block_pp(fcx.ccx, an_alt.body);
         }
diff --git a/src/comp/middle/tstate/states.rs b/src/comp/middle/tstate/states.rs
index ed84520a6b9..aa7977d142d 100644
--- a/src/comp/middle/tstate/states.rs
+++ b/src/comp/middle/tstate/states.rs
@@ -530,6 +530,12 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
         if vec::len(alts) > 0u {
             a_post = false_postcond(num_constrs);
             for an_alt: arm in alts {
+                alt an_alt.guard {
+                  some(e) {
+                    changed |= find_pre_post_state_expr(fcx, e_post, e);
+                  }
+                  _ {}
+                }
                 changed |=
                     find_pre_post_state_block(fcx, e_post, an_alt.body);
                 intersect(a_post, block_poststate(fcx.ccx, an_alt.body));