Skip to content

Commit 025d866

Browse files
committed
Switch alts to use arrows
1 parent c9d2769 commit 025d866

File tree

329 files changed

+8097
-8425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+8097
-8425
lines changed

src/cargo/cargo.rs

Lines changed: 166 additions & 174 deletions
Large diffs are not rendered by default.

src/compiletest/compiletest.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ fn parse_config(args: ~[~str]) -> config {
4343
let args_ = vec::tail(args);
4444
let matches =
4545
alt getopts::getopts(args_, opts) {
46-
ok(m) { m }
47-
err(f) { fail getopts::fail_str(f) }
46+
ok(m) => m,
47+
err(f) => fail getopts::fail_str(f)
4848
};
4949

5050
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
@@ -85,7 +85,7 @@ fn log_config(config: config) {
8585
}
8686

8787
fn opt_str(maybestr: option<~str>) -> ~str {
88-
alt maybestr { option::some(s) { s } option::none { ~"(none)" } }
88+
alt maybestr { option::some(s) => s, option::none => ~"(none)" }
8989
}
9090

9191
fn str_opt(maybestr: ~str) -> option<~str> {
@@ -94,20 +94,20 @@ fn str_opt(maybestr: ~str) -> option<~str> {
9494

9595
fn str_mode(s: ~str) -> mode {
9696
alt s {
97-
~"compile-fail" { mode_compile_fail }
98-
~"run-fail" { mode_run_fail }
99-
~"run-pass" { mode_run_pass }
100-
~"pretty" { mode_pretty }
101-
_ { fail ~"invalid mode" }
97+
~"compile-fail" => mode_compile_fail,
98+
~"run-fail" => mode_run_fail,
99+
~"run-pass" => mode_run_pass,
100+
~"pretty" => mode_pretty,
101+
_ => fail ~"invalid mode"
102102
}
103103
}
104104

105105
fn mode_str(mode: mode) -> ~str {
106106
alt mode {
107-
mode_compile_fail { ~"compile-fail" }
108-
mode_run_fail { ~"run-fail" }
109-
mode_run_pass { ~"run-pass" }
110-
mode_pretty { ~"pretty" }
107+
mode_compile_fail => ~"compile-fail",
108+
mode_run_fail => ~"run-fail",
109+
mode_run_pass => ~"run-pass",
110+
mode_pretty => ~"pretty"
111111
}
112112
}
113113

@@ -121,14 +121,14 @@ fn run_tests(config: config) {
121121
fn test_opts(config: config) -> test::test_opts {
122122
{filter:
123123
alt config.filter {
124-
option::some(s) { option::some(s) }
125-
option::none { option::none }
124+
option::some(s) => option::some(s),
125+
option::none => option::none
126126
},
127127
run_ignored: config.run_ignored,
128128
logfile:
129129
alt config.logfile {
130-
option::some(s) { option::some(s) }
131-
option::none { option::none }
130+
option::some(s) => option::some(s),
131+
option::none => option::none
132132
}
133133
}
134134
}
@@ -149,7 +149,10 @@ fn make_tests(config: config) -> ~[test::test_desc] {
149149
fn is_test(config: config, testfile: ~str) -> bool {
150150
// Pretty-printer does not work with .rc files yet
151151
let valid_extensions =
152-
alt config.mode { mode_pretty { ~[~".rs"] } _ { ~[~".rc", ~".rs"] } };
152+
alt config.mode {
153+
mode_pretty => ~[~".rs"],
154+
_ => ~[~".rc", ~".rs"]
155+
};
153156
let invalid_prefixes = ~[~".", ~"#", ~"~"];
154157
let name = path::basename(testfile);
155158

src/compiletest/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
2424
let error_tag = ~"//~";
2525
let mut idx;
2626
alt str::find_str(line, error_tag) {
27-
option::none { return ~[]; }
28-
option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
27+
option::none => return ~[],
28+
option::some(nn) => { idx = (nn as uint) + str::len(error_tag); }
2929
}
3030

3131
// "//~^^^ kind msg" denotes a message expected

src/compiletest/header.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ fn load_props(testfile: ~str) -> test_props {
3131
let mut pp_exact = option::none;
3232
for iter_header(testfile) |ln| {
3333
alt parse_error_pattern(ln) {
34-
option::some(ep) { vec::push(error_patterns, ep) }
35-
option::none { }
34+
option::some(ep) => vec::push(error_patterns, ep),
35+
option::none => ()
3636
};
3737

3838
if option::is_none(compile_flags) {
@@ -108,17 +108,17 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
108108
// nv is either FOO or FOO=BAR
109109
let strs = str::splitn_char(nv, '=', 1u);
110110
alt strs.len() {
111-
1u { (strs[0], ~"") }
112-
2u { (strs[0], strs[1]) }
113-
n { fail fmt!{"Expected 1 or 2 strings, not %u", n}; }
111+
1u => (strs[0], ~""),
112+
2u => (strs[0], strs[1]),
113+
n => fail fmt!{"Expected 1 or 2 strings, not %u", n}
114114
}
115115
}
116116
}
117117

118118
fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> {
119119
alt parse_name_value_directive(line, ~"pp-exact") {
120-
option::some(s) { option::some(s) }
121-
option::none {
120+
option::some(s) => option::some(s),
121+
option::none => {
122122
if parse_name_directive(line, ~"pp-exact") {
123123
option::some(path::basename(testfile))
124124
} else {
@@ -136,12 +136,12 @@ fn parse_name_value_directive(line: ~str,
136136
directive: ~str) -> option<~str> unsafe {
137137
let keycolon = directive + ~":";
138138
alt str::find_str(line, keycolon) {
139-
option::some(colon) {
139+
option::some(colon) => {
140140
let value = str::slice(line, colon + str::len(keycolon),
141141
str::len(line));
142142
debug!{"%s: %s", directive, value};
143143
option::some(value)
144144
}
145-
option::none { option::none }
145+
option::none => option::none
146146
}
147147
}

src/compiletest/procsrv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ fn run(lib_path: ~str,
7575
while count > 0 {
7676
let stream = comm::recv(p);
7777
alt check stream {
78-
(1, s) {
78+
(1, s) => {
7979
outs = s;
8080
}
81-
(2, s) {
81+
(2, s) => {
8282
errs = s;
8383
}
8484
};

src/compiletest/runtest.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ fn run(config: config, testfile: ~str) {
1919
debug!{"running %s", testfile};
2020
let props = load_props(testfile);
2121
alt config.mode {
22-
mode_compile_fail { run_cfail_test(config, props, testfile); }
23-
mode_run_fail { run_rfail_test(config, props, testfile); }
24-
mode_run_pass { run_rpass_test(config, props, testfile); }
25-
mode_pretty { run_pretty_test(config, props, testfile); }
22+
mode_compile_fail => run_cfail_test(config, props, testfile),
23+
mode_run_fail => run_rfail_test(config, props, testfile),
24+
mode_run_pass => run_rpass_test(config, props, testfile),
25+
mode_pretty => run_pretty_test(config, props, testfile)
2626
}
2727
}
2828

@@ -90,7 +90,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
9090
} else { logv(config, ~"testing for converging pretty-printing"); }
9191

9292
let rounds =
93-
alt props.pp_exact { option::some(_) { 1 } option::none { 2 } };
93+
alt props.pp_exact { option::some(_) => 1, option::none => 2 };
9494

9595
let mut srcs = ~[result::get(io::read_whole_file_str(testfile))];
9696

@@ -110,11 +110,11 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
110110

111111
let mut expected =
112112
alt props.pp_exact {
113-
option::some(file) {
113+
option::some(file) => {
114114
let filepath = path::connect(path::dirname(testfile), file);
115115
result::get(io::read_whole_file_str(filepath))
116116
}
117-
option::none { srcs[vec::len(srcs) - 2u] }
117+
option::none => { srcs[vec::len(srcs) - 2u] }
118118
};
119119
let mut actual = srcs[vec::len(srcs) - 1u];
120120

@@ -384,8 +384,8 @@ fn make_run_args(config: config, _props: test_props, testfile: ~str) ->
384384
// then split apart its command
385385
let runtool =
386386
alt config.runtool {
387-
option::some(s) { option::some(s) }
388-
option::none { option::none }
387+
option::some(s) => option::some(s),
388+
option::none => option::none
389389
};
390390
split_maybe_args(runtool)
391391
};
@@ -403,8 +403,8 @@ fn split_maybe_args(argstr: option<~str>) -> ~[~str] {
403403
}
404404

405405
alt argstr {
406-
option::some(s) { rm_whitespace(str::split_char(s, ' ')) }
407-
option::none { ~[] }
406+
option::some(s) => rm_whitespace(str::split_char(s, ' ')),
407+
option::none => ~[]
408408
}
409409
}
410410

src/compiletest/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ fn make_new_path(path: ~str) -> ~str {
88
// Windows just uses PATH as the library search path, so we have to
99
// maintain the current value while adding our own
1010
alt getenv(lib_path_env_var()) {
11-
option::some(curr) {
11+
option::some(curr) => {
1212
fmt!{"%s%s%s", path, path_div(), curr}
1313
}
14-
option::none { path }
14+
option::none => path
1515
}
1616
}
1717

src/fuzzer/fuzzer.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -63,39 +63,39 @@ pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
6363

6464
pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
6565
alt tm {
66-
tm_converge {
66+
tm_converge => {
6767
alt e.node {
6868
// If the fuzzer moves a block-ending-in-semicolon into callee
6969
// position, the pretty-printer can't preserve this even by
7070
// parenthesizing!! See email to marijn.
71-
ast::expr_if(_, _, _) { false }
72-
ast::expr_block(_) { false }
73-
ast::expr_alt(_, _, _) { false }
74-
ast::expr_while(_, _) { false }
71+
ast::expr_if(_, _, _) => { false }
72+
ast::expr_block(_) => { false }
73+
ast::expr_alt(_, _, _) => { false }
74+
ast::expr_while(_, _) => { false }
7575

7676
// https://github.com/mozilla/rust/issues/929
77-
ast::expr_cast(_, _) { false }
78-
ast::expr_assert(_) { false }
79-
ast::expr_binary(_, _, _) { false }
80-
ast::expr_assign(_, _) { false }
81-
ast::expr_assign_op(_, _, _) { false }
77+
ast::expr_cast(_, _) => { false }
78+
ast::expr_assert(_) => { false }
79+
ast::expr_binary(_, _, _) => { false }
80+
ast::expr_assign(_, _) => { false }
81+
ast::expr_assign_op(_, _, _) => { false }
8282

83-
ast::expr_fail(option::none) { false }
84-
ast::expr_ret(option::none) { false }
83+
ast::expr_fail(option::none) => { false }
84+
ast::expr_ret(option::none) => { false }
8585

8686
// https://github.com/mozilla/rust/issues/953
87-
ast::expr_fail(option::some(_)) { false }
87+
ast::expr_fail(option::some(_)) => { false }
8888

8989
// https://github.com/mozilla/rust/issues/928
9090
//ast::expr_cast(_, _) { false }
9191

9292
// https://github.com/mozilla/rust/issues/1458
93-
ast::expr_call(_, _, _) { false }
93+
ast::expr_call(_, _, _) => { false }
9494

95-
_ { true }
95+
_ => { true }
9696
}
9797
}
98-
tm_run { true }
98+
tm_run => { true }
9999
}
100100
}
101101

@@ -141,23 +141,23 @@ fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff {
141141
fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
142142
alt e {
143143
// https://github.com/mozilla/rust/issues/652
144-
ast::expr_if(*) { false }
145-
ast::expr_block(_) { false }
144+
ast::expr_if(*) => { false }
145+
ast::expr_block(_) => { false }
146146

147147
// expr_call is also missing a constraint
148-
ast::expr_fn_block(*) { false }
148+
ast::expr_fn_block(*) => { false }
149149

150-
_ { true }
150+
_ => { true }
151151
}
152152
}
153153

154154
fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
155155
alt t {
156-
ast::ty_infer { false } // always implicit, always top level
157-
ast::ty_bot { false } // in source, can only appear
156+
ast::ty_infer => { false } // always implicit, always top level
157+
ast::ty_bot => { false } // in source, can only appear
158158
// as the out type of a function
159-
ast::ty_mac(_) { false }
160-
_ { true }
159+
ast::ty_mac(_) => { false }
160+
_ => { true }
161161
}
162162
}
163163

@@ -273,10 +273,10 @@ fn check_variants_T<T: copy>(
273273
pprust::no_ann(),
274274
false));
275275
alt cx.mode {
276-
tm_converge {
276+
tm_converge => {
277277
check_roundtrip_convergence(str3, 1u);
278278
}
279-
tm_run {
279+
tm_run => {
280280
let file_label = fmt!{"rusttmp/%s_%s_%u_%u",
281281
last_part(filename),
282282
thing_label, i, j};
@@ -315,17 +315,17 @@ fn check_whole_compiler(code: ~str, suggested_filename_prefix: ~str,
315315
let compile_result = check_compiling(filename);
316316

317317
let run_result = alt (compile_result, allow_running) {
318-
(passed, true) { check_running(suggested_filename_prefix) }
319-
(h, _) { h }
318+
(passed, true) => { check_running(suggested_filename_prefix) }
319+
(h, _) => { h }
320320
};
321321

322322
alt run_result {
323-
passed | cleanly_rejected(_) | known_bug(_) {
323+
passed | cleanly_rejected(_) | known_bug(_) => {
324324
removeIfExists(suggested_filename_prefix);
325325
removeIfExists(suggested_filename_prefix + ~".rs");
326326
removeDirIfExists(suggested_filename_prefix + ~".dSYM");
327327
}
328-
failed(s) {
328+
failed(s) => {
329329
log(error, ~"check_whole_compiler failure: " + s);
330330
log(error, ~"Saved as: " + filename);
331331
}
@@ -365,17 +365,17 @@ fn check_running(exe_filename: ~str) -> happiness {
365365
failed(~"Mentioned malloc")
366366
} else {
367367
alt p.status {
368-
0 { passed }
369-
100 { cleanly_rejected(~"running: explicit fail") }
370-
101 | 247 { cleanly_rejected(~"running: timed out") }
371-
245 | 246 | 138 | 252 {
368+
0 => { passed }
369+
100 => { cleanly_rejected(~"running: explicit fail") }
370+
101 | 247 => { cleanly_rejected(~"running: timed out") }
371+
245 | 246 | 138 | 252 => {
372372
known_bug(~"https://github.com/mozilla/rust/issues/1466")
373373
}
374-
136 | 248 {
374+
136 | 248 => {
375375
known_bug(
376376
~"SIGFPE - https://github.com/mozilla/rust/issues/944")
377377
}
378-
rc {
378+
rc => {
379379
failed(~"Rust program ran but exited with status " +
380380
int::str(rc))
381381
}
@@ -442,8 +442,8 @@ fn has_raw_pointers(c: ast::crate) -> bool {
442442
let has_rp = @mut false;
443443
fn visit_ty(flag: @mut bool, t: @ast::ty) {
444444
alt t.node {
445-
ast::ty_ptr(_) { *flag = true; }
446-
_ { }
445+
ast::ty_ptr(_) => { *flag = true; }
446+
_ => { }
447447
}
448448
}
449449
let v =

src/libcore/bool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ pure fn is_false(v: bool) -> bool { !v }
4040
/// Parse logic value from `s`
4141
pure fn from_str(s: ~str) -> option<bool> {
4242
alt check s {
43-
~"true" { some(true) }
44-
~"false" { some(false) }
45-
_ { none }
43+
~"true" => some(true),
44+
~"false" => some(false),
45+
_ => none
4646
}
4747
}
4848

0 commit comments

Comments
 (0)