about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-31 22:34:41 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-01 12:14:36 -0700
commit792436826892d61ca16797fe3d26b1f202f6702a (patch)
treed95244927d1c1bc25abe1d01070541302aefbccf /src/comp
parent4c25d810415b01b7c2ed250952b8fe3b039f29bf (diff)
downloadrust-792436826892d61ca16797fe3d26b1f202f6702a.tar.gz
rust-792436826892d61ca16797fe3d26b1f202f6702a.zip
Allow istrs as patterns. Issue #855
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans_alt.rs14
-rw-r--r--src/comp/syntax/parse/parser.rs16
2 files changed, 25 insertions, 5 deletions
diff --git a/src/comp/middle/trans_alt.rs b/src/comp/middle/trans_alt.rs
index 76f4ef1ec0b..6dddf42caeb 100644
--- a/src/comp/middle/trans_alt.rs
+++ b/src/comp/middle/trans_alt.rs
@@ -296,9 +296,9 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
         let data = m[0].data;
         alt data.guard {
           some(e) {
-            let guard_cx = new_scope_block_ctxt(bcx, ~"guard");
-            let next_cx = new_sub_block_ctxt(bcx, ~"next");
-            let else_cx = new_sub_block_ctxt(bcx, ~"else");
+            let guard_cx = new_scope_block_ctxt(bcx, ~"submatch_guard");
+            let next_cx = new_sub_block_ctxt(bcx, ~"submatch_next");
+            let else_cx = new_sub_block_ctxt(bcx, ~"submatch_else");
             Br(bcx, guard_cx.llbb);
             // Temporarily set bindings. They'll be rewritten to PHI nodes for
             // the actual arm block.
@@ -431,13 +431,17 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
             llvm::LLVMAddCase(sw, r.val, opt_cx.llbb);
           }
           compare. {
+            let compare_cx = new_scope_block_ctxt(bcx, ~"compare_scope");
+            Br(bcx, compare_cx.llbb);
+            bcx = compare_cx;
             let r = trans_opt(bcx, opt);
             bcx = r.bcx;
             let t = ty::node_id_to_type(ccx.tcx, pat_id);
             let eq =
                 trans::trans_compare(bcx, ast::eq, test_val, t, r.val, t);
-            bcx = new_sub_block_ctxt(bcx, ~"next");
-            CondBr(eq.bcx, eq.val, opt_cx.llbb, bcx.llbb);
+            let cleanup_cx = trans::trans_block_cleanups(bcx, compare_cx);
+            bcx = new_sub_block_ctxt(bcx, ~"compare_next");
+            CondBr(cleanup_cx, eq.val, opt_cx.llbb, bcx.llbb);
           }
           _ { }
         }
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 369e07080f4..9c61f569e21 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -1497,6 +1497,22 @@ fn parse_pat(p: &parser) -> @ast::pat {
             pat = ast::pat_tup(fields);
         }
       }
+      token::TILDE. {
+        p.bump();
+        alt p.peek() {
+          token::LIT_STR(s) {
+            let sp = p.get_span();
+            p.bump();
+            let lit =
+                @{node: ast::lit_str(p.get_str(s),
+                                     ast::sk_unique),
+                  span: sp};
+            hi = lit.span.hi;
+            pat = ast::pat_lit(lit);
+          }
+          _ { p.fatal(~"expected string literal"); }
+        }
+      }
       tok {
         if !is_ident(tok) || is_word(p, ~"true") || is_word(p, ~"false") {
             let lit = parse_lit(p);