From a94b1ccacbc2869b6a67afcda98d7495c0086eb3 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Mon, 9 Jan 2012 19:15:17 -0600 Subject: [PATCH] Change all uses of 'when' in alt-patterns to 'if' Issue #1396 --- src/comp/front/test.rs | 2 +- src/comp/middle/last_use.rs | 2 +- src/comp/middle/trans.rs | 2 +- src/comp/middle/ty.rs | 8 ++++---- src/comp/syntax/parse/lexer.rs | 2 +- src/comp/syntax/parse/parser.rs | 6 +++--- src/test/run-pass/block-arg.rs | 2 +- src/test/run-pass/guards.rs | 6 +++--- src/test/run-pass/unreachable-code.rs | 2 +- src/test/stdtest/math.rs | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/comp/front/test.rs b/src/comp/front/test.rs index bb2e542693891..79d4523b14bda 100644 --- a/src/comp/front/test.rs +++ b/src/comp/front/test.rs @@ -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"); diff --git a/src/comp/middle/last_use.rs b/src/comp/middle/last_use.rs index 075c40ccfa5ac..5c9e298bcfb2c 100644 --- a/src/comp/middle/last_use.rs +++ b/src/comp/middle/last_use.rs @@ -153,7 +153,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt) { 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); } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 108f2c5b1c57d..c884daacf5813 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -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 } diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index f1a1858267aa5..e0c6d6f4ba2ce 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -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)) } }; } @@ -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); } diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index bee3d7783cbf5..21340168a230e 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -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(); } diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 2eeb5cbf136ee..b163ae172da7a 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -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 } } } @@ -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; @@ -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 { diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index ebbcc65d1580a..94e1973bbe72a 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -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."; diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 2da4a0296fd66..2dc646ee82391 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -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); diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index 2ccf2394beda6..2570e598b0872 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -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; } } } diff --git a/src/test/stdtest/math.rs b/src/test/stdtest/math.rs index c8335718da9af..adb68e4198c26 100644 --- a/src/test/stdtest/math.rs +++ b/src/test/stdtest/math.rs @@ -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) } }