Skip to content

Commit 3d04a46

Browse files
committed
---
yaml --- r: 5107 b: refs/heads/master c: 7924368 h: refs/heads/master i: 5105: fabd3c7 5103: f971929 v: v3
1 parent 13a3270 commit 3d04a46

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 4c25d810415b01b7c2ed250952b8fe3b039f29bf
2+
refs/heads/master: 792436826892d61ca16797fe3d26b1f202f6702a

trunk/src/comp/middle/trans_alt.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
296296
let data = m[0].data;
297297
alt data.guard {
298298
some(e) {
299-
let guard_cx = new_scope_block_ctxt(bcx, ~"guard");
300-
let next_cx = new_sub_block_ctxt(bcx, ~"next");
301-
let else_cx = new_sub_block_ctxt(bcx, ~"else");
299+
let guard_cx = new_scope_block_ctxt(bcx, ~"submatch_guard");
300+
let next_cx = new_sub_block_ctxt(bcx, ~"submatch_next");
301+
let else_cx = new_sub_block_ctxt(bcx, ~"submatch_else");
302302
Br(bcx, guard_cx.llbb);
303303
// Temporarily set bindings. They'll be rewritten to PHI nodes for
304304
// the actual arm block.
@@ -431,13 +431,17 @@ fn compile_submatch(bcx: @block_ctxt, m: &match, vals: [ValueRef],
431431
llvm::LLVMAddCase(sw, r.val, opt_cx.llbb);
432432
}
433433
compare. {
434+
let compare_cx = new_scope_block_ctxt(bcx, ~"compare_scope");
435+
Br(bcx, compare_cx.llbb);
436+
bcx = compare_cx;
434437
let r = trans_opt(bcx, opt);
435438
bcx = r.bcx;
436439
let t = ty::node_id_to_type(ccx.tcx, pat_id);
437440
let eq =
438441
trans::trans_compare(bcx, ast::eq, test_val, t, r.val, t);
439-
bcx = new_sub_block_ctxt(bcx, ~"next");
440-
CondBr(eq.bcx, eq.val, opt_cx.llbb, bcx.llbb);
442+
let cleanup_cx = trans::trans_block_cleanups(bcx, compare_cx);
443+
bcx = new_sub_block_ctxt(bcx, ~"compare_next");
444+
CondBr(cleanup_cx, eq.val, opt_cx.llbb, bcx.llbb);
441445
}
442446
_ { }
443447
}

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,22 @@ fn parse_pat(p: &parser) -> @ast::pat {
14971497
pat = ast::pat_tup(fields);
14981498
}
14991499
}
1500+
token::TILDE. {
1501+
p.bump();
1502+
alt p.peek() {
1503+
token::LIT_STR(s) {
1504+
let sp = p.get_span();
1505+
p.bump();
1506+
let lit =
1507+
@{node: ast::lit_str(p.get_str(s),
1508+
ast::sk_unique),
1509+
span: sp};
1510+
hi = lit.span.hi;
1511+
pat = ast::pat_lit(lit);
1512+
}
1513+
_ { p.fatal(~"expected string literal"); }
1514+
}
1515+
}
15001516
tok {
15011517
if !is_ident(tok) || is_word(p, ~"true") || is_word(p, ~"false") {
15021518
let lit = parse_lit(p);

trunk/src/test/run-pass/alt-str.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
// Issue #53
22

33
fn main() {
4-
alt "test" { "not-test" { fail; } "test" { } _ { fail; } }
4+
alt ~"test" {
5+
~"not-test" { fail; }
6+
~"test" { }
7+
_ { fail; }
8+
}
59

6-
tag t { tag1(str); tag2; }
10+
tag t { tag1(istr); tag2; }
711

812

9-
alt tag1("test") {
13+
alt tag1(~"test") {
1014
tag2. { fail; }
11-
tag1("not-test") { fail; }
12-
tag1("test") { }
15+
tag1(~"not-test") { fail; }
16+
tag1(~"test") { }
1317
_ { fail; }
1418
}
19+
20+
let x = alt ~"a" {
21+
~"a" { 1 }
22+
~"b" { 2 }
23+
};
24+
assert x == 1;
25+
26+
alt ~"a" {
27+
~"a" { }
28+
~"b" { }
29+
}
30+
1531
}

0 commit comments

Comments
 (0)