Skip to content

Commit

Permalink
Change all uses of 'when' in alt-patterns to 'if'
Browse files Browse the repository at this point in the history
Issue #1396
  • Loading branch information
Austin Seipp authored and brson committed Jan 10, 2012
1 parent aeae04c commit a94b1cc
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/comp/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->

if is_test_fn(i) {
alt i.node {
ast::item_fn(decl, _, _) when decl.purity == ast::unsafe_fn {
ast::item_fn(decl, _, _) if decl.purity == ast::unsafe_fn {
cx.sess.span_fatal(
i.span,
"unsafe functions cannot be used for tests");
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/last_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
for arg in args {
alt arg.node {
expr_fn(proto_block., _, _, _) { fns += [arg]; }
expr_fn_block(_, _) when is_block(cx, arg.id) { fns += [arg]; }
expr_fn_block(_, _) if is_block(cx, arg.id) { fns += [arg]; }
_ {
alt arg_ts[i].mode {
by_mut_ref. { clear_if_path(cx, arg, v, false); }
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
ty::ty_opaque_closure_ptr(ck) {
trans_closure::make_opaque_cbox_take_glue(bcx, ck, v)
}
_ when ty::type_is_structural(bcx_tcx(bcx), t) {
_ if ty::type_is_structural(bcx_tcx(bcx), t) {
iter_structural_ty(bcx, v, t, take_ty)
}
_ { bcx }
Expand Down
8 changes: 4 additions & 4 deletions src/comp/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1953,9 +1953,9 @@ mod unify {
}

ret alt variance {
invariant. when e_proto == a_proto { none }
covariant. when sub_proto(a_proto, e_proto) { none }
contravariant. when sub_proto(e_proto, a_proto) { none }
invariant. if e_proto == a_proto { none }
covariant. if sub_proto(a_proto, e_proto) { none }
contravariant. if sub_proto(e_proto, a_proto) { none }
_ { some(ures_err(terr_mismatch)) }
};
}
Expand Down Expand Up @@ -2220,7 +2220,7 @@ mod unify {
}
ty::ty_param(expected_n, _) {
alt struct(cx.tcx, actual) {
ty::ty_param(actual_n, _) when expected_n == actual_n {
ty::ty_param(actual_n, _) if expected_n == actual_n {
ret ures_ok(expected);
}
_ { ret ures_err(terr_mismatch); }
Expand Down
2 changes: 1 addition & 1 deletion src/comp/syntax/parse/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ fn scan_digits(rdr: reader, radix: uint) -> str {
let c = rdr.curr();
if c == '_' { rdr.bump(); cont; }
alt char::maybe_digit(c) {
some(d) when (d as uint) < radix {
some(d) if (d as uint) < radix {
str::push_byte(rslt, c as u8);
rdr.bump();
}
Expand Down
6 changes: 3 additions & 3 deletions src/comp/syntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ fn mk_pexpr(p: parser, lo: uint, hi: uint, node: ast::expr_) -> pexpr {

fn to_expr(e: pexpr) -> @ast::expr {
alt e.node {
ast::expr_tup(es) when vec::len(es) == 1u { es[0u] }
ast::expr_tup(es) if vec::len(es) == 1u { es[0u] }
_ { *e }
}
}
Expand Down Expand Up @@ -1020,7 +1020,7 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
while !expr_is_complete(p, e) {
alt p.peek() {
// expr(...)
token::LPAREN. when permits_call(p) {
token::LPAREN. if permits_call(p) {
let es = parse_seq(token::LPAREN, token::RPAREN,
seq_sep(token::COMMA), parse_expr, p);
hi = es.span.hi;
Expand All @@ -1029,7 +1029,7 @@ fn parse_dot_or_call_expr_with(p: parser, e0: pexpr) -> pexpr {
}

// expr {|| ... }
token::LBRACE. when is_bar(p.look_ahead(1u)) && permits_call(p) {
token::LBRACE. if is_bar(p.look_ahead(1u)) && permits_call(p) {
p.bump();
let blk = parse_fn_block_expr(p);
alt e.node {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/block-arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
false { }
}
alt 3 {
_ when vec::any(v) { |e| float::is_negative(e) } {
_ if vec::any(v) { |e| float::is_negative(e) } {
}
_ {
fail "wrong answer.";
Expand Down
6 changes: 3 additions & 3 deletions src/test/run-pass/guards.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
fn main() {
let a =
alt 10 { x when x < 7 { 1 } x when x < 11 { 2 } 10 { 3 } _ { 4 } };
alt 10 { x if x < 7 { 1 } x if x < 11 { 2 } 10 { 3 } _ { 4 } };
assert (a == 2);

let b =
alt {x: 10, y: 20} {
x when x.x < 5 && x.y < 5 { 1 }
{x: x, y: y} when x == 10 && y == 20 { 2 }
x if x.x < 5 && x.y < 5 { 1 }
{x: x, y: y} if x == 10 && y == 20 { 2 }
{x: x, y: y} { 3 }
};
assert (b == 2);
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/unreachable-code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn ret_ret() -> int { ret (ret 2) + 3; }

fn ret_guard() {
alt 2 {
x when (ret) { x; }
x if (ret) { x; }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/stdtest/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ fn test_sqrt() {
fn test_angle() {
fn angle(vec: (float, float)) -> float {
alt vec {
(0f, y) when y < 0f { 1.5 * consts::pi }
(0f, y) if y < 0f { 1.5 * consts::pi }
(0f, y) { 0.5 * consts::pi }
(x, y) { float::atan(y / x) }
}
Expand Down

0 comments on commit a94b1cc

Please sign in to comment.