Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch alts to use arrows

  • Loading branch information...
commit 025d86624de982cdab7e6b13600fec1499c02b56 1 parent c9d2769
@brson brson authored
Showing with 6,183 additions and 6,504 deletions.
  1. +166 −174 src/cargo/cargo.rs
  2. +20 −17 src/compiletest/compiletest.rs
  3. +2 −2 src/compiletest/errors.rs
  4. +9 −9 src/compiletest/header.rs
  5. +2 −2 src/compiletest/procsrv.rs
  6. +11 −11 src/compiletest/runtest.rs
  7. +2 −2 src/compiletest/util.rs
  8. +38 −38 src/fuzzer/fuzzer.rs
  9. +3 −3 src/libcore/bool.rs
  10. +12 −12 src/libcore/char.rs
  11. +2 −2 src/libcore/comm.rs
  12. +24 −36 src/libcore/dlist.rs
  13. +20 −11 src/libcore/either.rs
  14. +33 −32 src/libcore/extfmt.rs
  15. +18 −28 src/libcore/float.rs
  16. +3 −3 src/libcore/future.rs
  17. +2 −2 src/libcore/int-template.rs
  18. +34 −34 src/libcore/io.rs
  19. +4 −4 src/libcore/iter-trait/option.rs
  20. +8 −8 src/libcore/iter.rs
  21. +13 −10 src/libcore/option.rs
  22. +13 −19 src/libcore/os.rs
  23. +5 −5 src/libcore/path.rs
  24. +66 −84 src/libcore/pipes.rs
  25. +2 −2 src/libcore/priv.rs
  26. +41 −45 src/libcore/result.rs
  27. +8 −12 src/libcore/run.rs
  28. +4 −8 src/libcore/send_map.rs
  29. +29 −31 src/libcore/str.rs
  30. +31 −32 src/libcore/task.rs
  31. +4 −4 src/libcore/uint-template.rs
  32. +64 −70 src/libcore/unicode.rs
  33. +10 −10 src/libcore/vec.rs
  34. +6 −8 src/libstd/base64.rs
  35. +38 −60 src/libstd/bitv.rs
  36. +2 −2 src/libstd/c_vec.rs
  37. +20 −30 src/libstd/deque.rs
  38. +14 −23 src/libstd/ebml.rs
  39. +6 −6 src/libstd/fun_treemap.rs
  40. +113 −113 src/libstd/getopts.rs
  41. +85 −94 src/libstd/json.rs
  42. +16 −13 src/libstd/list.rs
  43. +19 −19 src/libstd/map.rs
  44. +24 −36 src/libstd/net_ip.rs
  45. +67 −90 src/libstd/net_tcp.rs
  46. +51 −51 src/libstd/net_url.rs
  47. +86 −104 src/libstd/rope.rs
  48. +6 −16 src/libstd/serialization.rs
  49. +13 −11 src/libstd/smallintmap.rs
  50. +2 −2 src/libstd/tempfile.rs
  51. +2 −2 src/libstd/term.rs
  52. +31 −31 src/libstd/test.rs
  53. +209 −237 src/libstd/time.rs
  54. +7 −4 src/libstd/timer.rs
  55. +6 −6 src/libstd/treemap.rs
  56. +2 −2 src/libstd/uv_global_loop.rs
  57. +2 −6 src/libstd/uv_iotask.rs
  58. +2 −6 src/libstd/uv_ll.rs
  59. +2 −2 src/libsyntax/ast.rs
  60. +44 −46 src/libsyntax/ast_map.rs
  61. +157 −151 src/libsyntax/ast_util.rs
  62. +38 −49 src/libsyntax/attr.rs
  63. +8 −8 src/libsyntax/codemap.rs
  64. +20 −18 src/libsyntax/diagnostic.rs
  65. +38 −38 src/libsyntax/ext/auto_serialize.rs
  66. +33 −39 src/libsyntax/ext/base.rs
  67. +2 −2 src/libsyntax/ext/env.rs
  68. +39 −46 src/libsyntax/ext/expand.rs
  69. +79 −92 src/libsyntax/ext/fmt.rs
  70. +2 −2 src/libsyntax/ext/pipes/check.rs
  71. +8 −10 src/libsyntax/ext/pipes/parse_proto.rs
  72. +27 −26 src/libsyntax/ext/pipes/pipec.rs
  73. +9 −15 src/libsyntax/ext/pipes/proto.rs
  74. +34 −34 src/libsyntax/ext/qquote.rs
  75. +141 −166 src/libsyntax/ext/simplext.rs
  76. +4 −4 src/libsyntax/ext/source_util.rs
  77. +43 −44 src/libsyntax/ext/tt/earley_parser.rs
  78. +12 −13 src/libsyntax/ext/tt/macro_rules.rs
  79. +34 −38 src/libsyntax/ext/tt/transcribe.rs
  80. +98 −100 src/libsyntax/fold.rs
  81. +2 −2 src/libsyntax/parse.rs
  82. +16 −20 src/libsyntax/parse/attr.rs
  83. +26 −33 src/libsyntax/parse/classify.rs
  84. +19 −15 src/libsyntax/parse/common.rs
  85. +10 −12 src/libsyntax/parse/eval.rs
  86. +72 −72 src/libsyntax/parse/lexer.rs
  87. +181 −193 src/libsyntax/parse/parser.rs
  88. +19 −19 src/libsyntax/parse/prec.rs
  89. +102 −97 src/libsyntax/parse/token.rs
  90. +24 −24 src/libsyntax/print/pp.rs
  91. +245 −249 src/libsyntax/print/pprust.rs
  92. +2 −2 src/libsyntax/util/interner.rs
  93. +97 −103 src/libsyntax/visit.rs
  94. +36 −37 src/rustc/back/link.rs
  95. +6 −6 src/rustc/back/rpath.rs
  96. +8 −8 src/rustc/back/x86.rs
  97. +8 −8 src/rustc/back/x86_64.rs
  98. +67 −74 src/rustc/driver/driver.rs
  99. +15 −15 src/rustc/driver/rustc.rs
  100. +12 −12 src/rustc/driver/session.rs
  101. +4 −4 src/rustc/front/config.rs
  102. +2 −2 src/rustc/front/intrinsic_inject.rs
  103. +8 −8 src/rustc/front/test.rs
  104. +23 −23 src/rustc/lib/llvm.rs
  105. +16 −16 src/rustc/metadata/creader.rs
  106. +1 −1  src/rustc/metadata/csearch.rs
  107. +1 −1  src/rustc/metadata/cstore.rs
  108. +84 −82 src/rustc/metadata/decoder.rs
  109. +73 −75 src/rustc/metadata/encoder.rs
  110. +12 −16 src/rustc/metadata/filesearch.rs
  111. +20 −20 src/rustc/metadata/loader.rs
  112. +91 −91 src/rustc/metadata/tydecode.rs
  113. +90 −90 src/rustc/metadata/tyencode.rs
  114. +44 −44 src/rustc/middle/astencode.rs
  115. +5 −5 src/rustc/middle/block_use.rs
  116. +59 −65 src/rustc/middle/borrowck.rs
  117. +48 −50 src/rustc/middle/borrowck/categorization.rs
  118. +84 −85 src/rustc/middle/borrowck/check_loans.rs
  119. +39 −38 src/rustc/middle/borrowck/gather_loans.rs
  120. +10 −10 src/rustc/middle/borrowck/loan.rs
  121. +15 −15 src/rustc/middle/borrowck/preserve.rs
  122. +4 −4 src/rustc/middle/capture.rs
  123. +79 −77 src/rustc/middle/check_alt.rs
  124. +27 −27 src/rustc/middle/check_const.rs
  125. +9 −9 src/rustc/middle/check_loop.rs
  126. +111 −89 src/rustc/middle/const_eval.rs
  127. +10 −10 src/rustc/middle/freevars.rs
  128. +49 −49 src/rustc/middle/kind.rs
  129. +2 −2 src/rustc/middle/lang_items.rs
  130. +43 −43 src/rustc/middle/lint.rs
  131. +144 −162 src/rustc/middle/liveness.rs
  132. +7 −9 src/rustc/middle/pat_util.rs
  133. +23 −23 src/rustc/middle/region.rs
  134. +365 −379 src/rustc/middle/resolve3.rs
  135. +92 −83 src/rustc/middle/trans/alt.rs
  136. +518 −510 src/rustc/middle/trans/base.rs
  137. +4 −1 src/rustc/middle/trans/build.rs
  138. +51 −59 src/rustc/middle/trans/closure.rs
  139. +59 −46 src/rustc/middle/trans/common.rs
  140. +49 −52 src/rustc/middle/trans/consts.rs
  141. +74 −73 src/rustc/middle/trans/debuginfo.rs
  142. +80 −92 src/rustc/middle/trans/foreign.rs
  143. +22 −24 src/rustc/middle/trans/impl.rs
  144. +39 −37 src/rustc/middle/trans/reachable.rs
  145. +61 −63 src/rustc/middle/trans/reflect.rs
  146. +57 −57 src/rustc/middle/trans/shape.rs
  147. +18 −19 src/rustc/middle/trans/tvec.rs
  148. +40 −44 src/rustc/middle/trans/type_of.rs
  149. +44 −40 src/rustc/middle/trans/type_use.rs
  150. +2 −2 src/rustc/middle/trans/uniq.rs
Sorry, we could not display the entire diff because too many files (328) changed.
View
340 src/cargo/cargo.rs
@@ -129,22 +129,22 @@ fn is_uuid(id: ~str) -> bool {
}
alt i {
- 0u {
+ 0u => {
if str::len(part) == 8u {
correct += 1u;
}
}
- 1u | 2u | 3u {
+ 1u | 2u | 3u => {
if str::len(part) == 4u {
correct += 1u;
}
}
- 4u {
+ 4u => {
if str::len(part) == 12u {
correct += 1u;
}
}
- _ { }
+ _ => { }
}
}
if correct >= 5u {
@@ -193,8 +193,8 @@ fn is_archive_url(u: ~str) -> bool {
// url parsing, we wouldn't need it
alt str::find_str(u, ~"://") {
- option::some(i) { has_archive_extension(u) }
- _ { false }
+ option::some(i) => has_archive_extension(u),
+ _ => false
}
}
@@ -224,15 +224,15 @@ fn load_link(mis: ~[@ast::meta_item]) -> (option<~str>,
let mut uuid = none;
for mis.each |a| {
alt a.node {
- ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
+ ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) => {
alt *v {
- ~"name" { name = some(*s); }
- ~"vers" { vers = some(*s); }
- ~"uuid" { uuid = some(*s); }
- _ { }
+ ~"name" => name = some(*s),
+ ~"vers" => vers = some(*s),
+ ~"uuid" => uuid = some(*s),
+ _ => { }
}
}
- _ { fail ~"load_link: meta items must be name-values"; }
+ _ => fail ~"load_link: meta items must be name-values"
}
}
(name, vers, uuid)
@@ -251,15 +251,15 @@ fn load_crate(filename: ~str) -> option<crate> {
for c.node.attrs.each |a| {
alt a.node.value.node {
- ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
+ ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) => {
alt *v {
- ~"desc" { desc = some(*v); }
- ~"sigs" { sigs = some(*v); }
- ~"crate_type" { crate_type = some(*v); }
- _ { }
+ ~"desc" => desc = some(*v),
+ ~"sigs" => sigs = some(*v),
+ ~"crate_type" => crate_type = some(*v),
+ _ => { }
}
}
- ast::meta_list(v, mis) {
+ ast::meta_list(v, mis) => {
if *v == ~"link" {
let (n, v, u) = load_link(mis);
name = n;
@@ -267,7 +267,7 @@ fn load_crate(filename: ~str) -> option<crate> {
uuid = u;
}
}
- _ {
+ _ => {
fail ~"crate attributes may not contain " +
~"meta_words";
}
@@ -280,7 +280,7 @@ fn load_crate(filename: ~str) -> option<crate> {
fn goto_view_item(e: env, i: @ast::view_item) {
alt i.node {
- ast::view_item_use(ident, metas, id) {
+ ast::view_item_use(ident, metas, id) => {
let name_items =
attr::find_meta_items_by_name(metas, ~"name");
let m = if name_items.is_empty() {
@@ -294,16 +294,16 @@ fn load_crate(filename: ~str) -> option<crate> {
for m.each |item| {
alt attr::get_meta_item_value_str(item) {
- some(value) {
+ some(value) => {
let name = attr::get_meta_item_name(item);
alt *name {
- ~"vers" { attr_vers = *value; }
- ~"from" { attr_from = *value; }
- _ {}
+ ~"vers" => attr_vers = *value,
+ ~"from" => attr_from = *value,
+ _ => ()
}
}
- none {}
+ none => ()
}
}
@@ -316,11 +316,11 @@ fn load_crate(filename: ~str) -> option<crate> {
};
alt *attr_name {
- ~"std" | ~"core" { }
- _ { vec::push(e.deps, query); }
+ ~"std" | ~"core" => (),
+ _ => vec::push(e.deps, query)
}
}
- _ { }
+ _ => ()
}
}
fn goto_item(_e: env, _i: @ast::item) {
@@ -340,7 +340,7 @@ fn load_crate(filename: ~str) -> option<crate> {
let deps = copy e.deps;
alt (name, vers, uuid) {
- (some(name0), some(vers0), some(uuid0)) {
+ (some(name0), some(vers0), some(uuid0)) => {
some({
name: name0,
vers: vers0,
@@ -350,7 +350,7 @@ fn load_crate(filename: ~str) -> option<crate> {
crate_type: crate_type,
deps: deps })
}
- _ { return none; }
+ _ => return none
}
}
@@ -391,30 +391,22 @@ fn parse_source(name: ~str, j: json::json) -> source {
}
alt j {
- json::dict(j) {
+ json::dict(j) => {
let mut url = alt j.find(~"url") {
- some(json::string(u)) {
- *u
- }
- _ { fail ~"needed 'url' field in source"; }
+ some(json::string(u)) => *u,
+ _ => fail ~"needed 'url' field in source"
};
let method = alt j.find(~"method") {
- some(json::string(u)) {
- *u
- }
- _ { assume_source_method(url) }
+ some(json::string(u)) => *u,
+ _ => assume_source_method(url)
};
let key = alt j.find(~"key") {
- some(json::string(u)) {
- some(*u)
- }
- _ { none }
+ some(json::string(u)) => some(*u),
+ _ => none
};
let keyfp = alt j.find(~"keyfp") {
- some(json::string(u)) {
- some(*u)
- }
- _ { none }
+ some(json::string(u)) => some(*u),
+ _ => none
};
if method == ~"file" {
url = os::make_absolute(url);
@@ -427,7 +419,7 @@ fn parse_source(name: ~str, j: json::json) -> source {
mut keyfp: keyfp,
mut packages: ~[mut] };
}
- _ { fail ~"needed dict value in source"; }
+ _ => fail ~"needed dict value in source"
};
}
@@ -435,20 +427,20 @@ fn try_parse_sources(filename: ~str, sources: map::hashmap<~str, source>) {
if !os::path_exists(filename) { return; }
let c = io::read_whole_file_str(filename);
alt json::from_str(result::get(c)) {
- ok(json::dict(j)) {
+ ok(json::dict(j)) => {
for j.each |k, v| {
sources.insert(k, parse_source(k, v));
debug!{"source: %s", k};
}
}
- ok(_) { fail ~"malformed sources.json"; }
- err(e) { fail fmt!{"%s:%s", filename, e.to_str()}; }
+ ok(_) => fail ~"malformed sources.json",
+ err(e) => fail fmt!{"%s:%s", filename, e.to_str()}
}
}
fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
let name = alt p.find(~"name") {
- some(json::string(n)) {
+ some(json::string(n)) => {
if !valid_pkg_name(*n) {
warn(~"malformed source json: "
+ src.name + ~", '" + *n + ~"'"+
@@ -458,14 +450,14 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
}
*n
}
- _ {
+ _ => {
warn(~"malformed source json: " + src.name + ~" (missing name)");
return;
}
};
let uuid = alt p.find(~"uuid") {
- some(json::string(n)) {
+ some(json::string(n)) => {
if !is_uuid(*n) {
warn(~"malformed source json: "
+ src.name + ~", '" + *n + ~"'"+
@@ -474,23 +466,23 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
}
*n
}
- _ {
+ _ => {
warn(~"malformed source json: " + src.name + ~" (missing uuid)");
return;
}
};
let url = alt p.find(~"url") {
- some(json::string(n)) { *n }
- _ {
+ some(json::string(n)) => *n,
+ _ => {
warn(~"malformed source json: " + src.name + ~" (missing url)");
return;
}
};
let method = alt p.find(~"method") {
- some(json::string(n)) { *n }
- _ {
+ some(json::string(n)) => *n,
+ _ => {
warn(~"malformed source json: "
+ src.name + ~" (missing method)");
return;
@@ -498,26 +490,26 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
};
let reference = alt p.find(~"ref") {
- some(json::string(n)) { some(*n) }
- _ { none }
+ some(json::string(n)) => some(*n),
+ _ => none
};
let mut tags = ~[];
alt p.find(~"tags") {
- some(json::list(js)) {
+ some(json::list(js)) => {
for (*js).each |j| {
alt j {
- json::string(j) { vec::grow(tags, 1u, *j); }
- _ { }
+ json::string(j) => vec::grow(tags, 1u, *j),
+ _ => ()
}
}
}
- _ { }
+ _ => ()
}
let description = alt p.find(~"description") {
- some(json::string(n)) { *n }
- _ {
+ some(json::string(n)) => *n,
+ _ => {
warn(~"malformed source json: " + src.name
+ ~" (missing description)");
return;
@@ -536,11 +528,11 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) {
};
alt vec::position(src.packages, |pkg| pkg.uuid == uuid) {
- some(idx) {
+ some(idx) => {
src.packages[idx] = newpkg;
log(debug, ~" updated package: " + src.name + ~"/" + name);
}
- none {
+ none => {
vec::grow(src.packages, 1u, newpkg);
}
}
@@ -554,17 +546,17 @@ fn load_source_info(c: cargo, src: source) {
if !os::path_exists(srcfile) { return; }
let srcstr = io::read_whole_file_str(srcfile);
alt json::from_str(result::get(srcstr)) {
- ok(json::dict(s)) {
+ ok(json::dict(s)) => {
let o = parse_source(src.name, json::dict(s));
src.key = o.key;
src.keyfp = o.keyfp;
}
- ok(_) {
+ ok(_) => {
warn(~"malformed source.json: " + src.name +
~"(source info is not a dict)");
}
- err(e) {
+ err(e) => {
warn(fmt!{"%s:%s", src.name, e.to_str()});
}
};
@@ -576,24 +568,24 @@ fn load_source_packages(c: cargo, src: source) {
if !os::path_exists(pkgfile) { return; }
let pkgstr = io::read_whole_file_str(pkgfile);
alt json::from_str(result::get(pkgstr)) {
- ok(json::list(js)) {
+ ok(json::list(js)) => {
for (*js).each |j| {
alt j {
- json::dict(p) {
+ json::dict(p) => {
load_one_source_package(src, p);
}
- _ {
+ _ => {
warn(~"malformed source json: " + src.name +
~" (non-dict pkg)");
}
}
}
}
- ok(_) {
+ ok(_) => {
warn(~"malformed packages.json: " + src.name +
~"(packages is not a list)");
}
- err(e) {
+ err(e) => {
warn(fmt!{"%s:%s", src.name, e.to_str()});
}
};
@@ -601,8 +593,8 @@ fn load_source_packages(c: cargo, src: source) {
fn build_cargo_options(argv: ~[~str]) -> options {
let matches = alt getopts::getopts(argv, opts()) {
- result::ok(m) { m }
- result::err(f) {
+ result::ok(m) => m,
+ result::err(f) => {
fail fmt!{"%s", getopts::fail_str(f)};
}
};
@@ -632,14 +624,14 @@ fn build_cargo_options(argv: ~[~str]) -> options {
fn configure(opts: options) -> cargo {
let home = alt get_cargo_root() {
- ok(home) { home }
- err(_err) { result::get(get_cargo_sysroot()) }
+ ok(home) => home,
+ err(_err) => result::get(get_cargo_sysroot())
};
let get_cargo_dir = alt opts.mode {
- system_mode { get_cargo_sysroot }
- user_mode { get_cargo_root }
- local_mode { get_cargo_root_nearest }
+ system_mode => get_cargo_sysroot,
+ user_mode => get_cargo_root,
+ local_mode => get_cargo_root_nearest
};
let p = result::get(get_cargo_dir());
@@ -726,8 +718,8 @@ fn run_in_buildpath(what: ~str, path: ~str, subdir: ~str, cf: ~str,
fn test_one_crate(_c: cargo, path: ~str, cf: ~str) {
let buildpath = alt run_in_buildpath(~"testing", path, ~"/test", cf,
~[ ~"--test"]) {
- none { return; }
- some(bp) { bp }
+ none => return,
+ some(bp) => bp
};
run_programs(buildpath);
}
@@ -735,8 +727,8 @@ fn test_one_crate(_c: cargo, path: ~str, cf: ~str) {
fn install_one_crate(c: cargo, path: ~str, cf: ~str) {
let buildpath = alt run_in_buildpath(~"installing", path,
~"/build", cf, ~[]) {
- none { return; }
- some(bp) { bp }
+ none => return,
+ some(bp) => bp
};
let newv = os::list_dir_path(buildpath);
let exec_suffix = os::exe_suffix();
@@ -761,13 +753,13 @@ fn install_one_crate(c: cargo, path: ~str, cf: ~str) {
fn rustc_sysroot() -> ~str {
alt os::self_exe_path() {
- some(path) {
+ some(path) => {
let path = ~[path, ~"..", ~"bin", ~"rustc"];
let rustc = path::normalize(path::connect_many(path));
debug!{" rustc: %s", rustc};
rustc
}
- none { ~"rustc" }
+ none => ~"rustc"
}
}
@@ -788,8 +780,8 @@ fn install_source(c: cargo, path: ~str) {
for cratefiles.each |cf| {
alt load_crate(cf) {
- none { again; }
- some(crate) {
+ none => again,
+ some(crate) => {
for crate.deps.each |query| {
// FIXME (#1356): handle cyclic dependencies
// (n.b. #1356 says "Cyclic dependency is an error
@@ -797,8 +789,8 @@ fn install_source(c: cargo, path: ~str) {
let wd_base = c.workdir + path::path_sep();
let wd = alt tempfile::mkdtemp(wd_base, ~"") {
- some(wd) { wd }
- none { fail fmt!{"needed temp dir: %s", wd_base}; }
+ some(wd) => wd,
+ none => fail fmt!{"needed temp dir: %s", wd_base}
};
install_query(c, wd, query);
@@ -847,18 +839,18 @@ fn install_file(c: cargo, wd: ~str, path: ~str) {
fn install_package(c: cargo, src: ~str, wd: ~str, pkg: package) {
let url = copy pkg.url;
let method = alt pkg.method {
- ~"git" { ~"git" }
- ~"file" { ~"file" }
- _ { ~"curl" }
+ ~"git" => ~"git",
+ ~"file" => ~"file",
+ _ => ~"curl"
};
info(fmt!{"installing %s/%s via %s...", src, pkg.name, method});
alt method {
- ~"git" { install_git(c, wd, url, copy pkg.reference); }
- ~"file" { install_file(c, wd, url); }
- ~"curl" { install_curl(c, wd, copy url); }
- _ {}
+ ~"git" => install_git(c, wd, url, copy pkg.reference),
+ ~"file" => install_file(c, wd, url),
+ ~"curl" => install_curl(c, wd, copy url),
+ _ => ()
}
}
@@ -922,7 +914,7 @@ fn install_named(c: cargo, wd: ~str, name: ~str) {
fn install_uuid_specific(c: cargo, wd: ~str, src: ~str, uuid: ~str) {
alt c.sources.find(src) {
- some(s) {
+ some(s) => {
let packages = copy s.packages;
if vec::any(packages, |p| {
if p.uuid == uuid {
@@ -931,14 +923,14 @@ fn install_uuid_specific(c: cargo, wd: ~str, src: ~str, uuid: ~str) {
} else { false }
}) { return; }
}
- _ { }
+ _ => ()
}
error(~"can't find package: " + src + ~"/" + uuid);
}
fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) {
alt c.sources.find(src) {
- some(s) {
+ some(s) => {
let packages = copy s.packages;
if vec::any(packages, |p| {
if p.name == name {
@@ -947,7 +939,7 @@ fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) {
} else { false }
}) { return; }
}
- _ { }
+ _ => ()
}
error(~"can't find package: " + src + ~"/" + name);
}
@@ -969,7 +961,7 @@ fn cmd_uninstall(c: cargo) {
if is_uuid(target) {
for os::list_dir(lib).each |file| {
alt str::find_str(file, ~"-" + target + ~"-") {
- some(idx) {
+ some(idx) => {
let full = path::normalize(path::connect(lib, file));
if os::remove_file(full) {
info(~"uninstalled: '" + full + ~"'");
@@ -978,7 +970,7 @@ fn cmd_uninstall(c: cargo) {
}
return;
}
- none { again; }
+ none => again
}
}
@@ -986,7 +978,7 @@ fn cmd_uninstall(c: cargo) {
} else {
for os::list_dir(lib).each |file| {
alt str::find_str(file, ~"lib" + target + ~"-") {
- some(idx) {
+ some(idx) => {
let full = path::normalize(path::connect(lib,
file));
if os::remove_file(full) {
@@ -996,12 +988,12 @@ fn cmd_uninstall(c: cargo) {
}
return;
}
- none { again; }
+ none => again
}
}
for os::list_dir(bin).each |file| {
alt str::find_str(file, target) {
- some(idx) {
+ some(idx) => {
let full = path::normalize(path::connect(bin, file));
if os::remove_file(full) {
info(~"uninstalled: '" + full + ~"'");
@@ -1010,7 +1002,7 @@ fn cmd_uninstall(c: cargo) {
}
return;
}
- none { again; }
+ none => again
}
}
@@ -1020,12 +1012,12 @@ fn cmd_uninstall(c: cargo) {
fn install_query(c: cargo, wd: ~str, target: ~str) {
alt c.dep_cache.find(target) {
- some(inst) {
+ some(inst) => {
if inst {
return;
}
}
- none {}
+ none => ()
}
c.dep_cache.insert(target, true);
@@ -1047,7 +1039,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) {
let mut ps = copy target;
alt str::find_char(ps, '/') {
- option::some(idx) {
+ option::some(idx) => {
let source = str::slice(ps, 0u, idx);
ps = str::slice(ps, idx + 1u, str::len(ps));
if is_uuid(ps) {
@@ -1056,7 +1048,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) {
install_named_specific(c, wd, source, ps);
}
}
- option::none {
+ option::none => {
if is_uuid(ps) {
install_uuid(c, wd, ps);
} else {
@@ -1081,8 +1073,8 @@ fn install_query(c: cargo, wd: ~str, target: ~str) {
fn cmd_install(c: cargo) unsafe {
let wd_base = c.workdir + path::path_sep();
let wd = alt tempfile::mkdtemp(wd_base, ~"") {
- some(wd) { wd }
- none { fail fmt!{"needed temp dir: %s", wd_base}; }
+ some(wd) => wd,
+ none => fail fmt!{"needed temp dir: %s", wd_base}
};
if vec::len(c.opts.free) == 2u {
@@ -1138,7 +1130,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
os::copy_file(path::connect(url, ~"packages.json.sig"), sigfile);
alt copy src.key {
- some(u) {
+ some(u) => {
let p = run::program_output(~"curl",
~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 {
@@ -1147,10 +1139,10 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
}
pgp::add(c.root, keyfile);
}
- _ { }
+ _ => ()
}
alt (src.key, src.keyfp) {
- (some(_), some(f)) {
+ (some(_), some(f)) => {
let r = pgp::verify(c.root, pkgfile, sigfile, f);
if !r {
@@ -1169,7 +1161,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool {
}
}
}
- _ {}
+ _ => ()
}
copy_warn(pkgfile, destpkgfile);
@@ -1247,7 +1239,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
let has_src_file = os::path_exists(srcfile);
alt copy src.key {
- some(u) {
+ some(u) => {
let p = run::program_output(~"curl",
~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 {
@@ -1257,10 +1249,10 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
}
pgp::add(c.root, keyfile);
}
- _ { }
+ _ => ()
}
alt (src.key, src.keyfp) {
- (some(_), some(f)) {
+ (some(_), some(f)) => {
let r = pgp::verify(c.root, pkgfile, sigfile, f);
if !r {
@@ -1281,7 +1273,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool {
}
}
}
- _ {}
+ _ => ()
}
os::remove_file(keyfile);
@@ -1327,7 +1319,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
}
alt copy src.key {
- some(u) {
+ some(u) => {
let p = run::program_output(~"curl",
~[~"-f", ~"-s", ~"-o", keyfile, u]);
if p.status != 0 {
@@ -1336,10 +1328,10 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
}
pgp::add(c.root, keyfile);
}
- _ { }
+ _ => ()
}
alt (src.key, src.keyfp) {
- (some(_), some(f)) {
+ (some(_), some(f)) => {
if smart {
url = src.url + ~"/packages.json.sig";
}
@@ -1383,7 +1375,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool {
}
}
}
- _ {}
+ _ => ()
}
copy_warn(pkgfile, destpkgfile);
@@ -1412,9 +1404,9 @@ fn sync_one(c: cargo, src: source) {
need_dir(dir);
let result = alt src.method {
- ~"git" { sync_one_git(c, dir, src) }
- ~"file" { sync_one_file(c, dir, src) }
- _ { sync_one_curl(c, dir, src) }
+ ~"git" => sync_one_git(c, dir, src),
+ ~"file" => sync_one_file(c, dir, src),
+ _ => sync_one_curl(c, dir, src)
};
if result {
@@ -1499,10 +1491,10 @@ fn cmd_list(c: cargo) {
error(fmt!{"'%s' is an invalid source name", name});
} else {
alt c.sources.find(name) {
- some(source) {
+ some(source) => {
print_source(source);
}
- none {
+ none => {
error(fmt!{"no such source: %s", name});
}
}
@@ -1571,7 +1563,7 @@ fn dump_sources(c: cargo) {
}
alt io::buffered_file_writer(out) {
- result::ok(writer) {
+ result::ok(writer) => {
let hash = map::str_hash();
let root = json::dict(hash);
@@ -1583,16 +1575,16 @@ fn dump_sources(c: cargo) {
chash.insert(~"method", json::string(@v.method));
alt copy v.key {
- some(key) {
+ some(key) => {
chash.insert(~"key", json::string(@key));
}
- _ {}
+ _ => ()
}
alt copy v.keyfp {
- some(keyfp) {
+ some(keyfp) => {
chash.insert(~"keyfp", json::string(@keyfp));
}
- _ {}
+ _ => ()
}
hash.insert(k, child);
@@ -1600,7 +1592,7 @@ fn dump_sources(c: cargo) {
writer.write_str(json::to_str(root));
}
- result::err(e) {
+ result::err(e) => {
error(fmt!{"could not dump sources: %s", e});
}
}
@@ -1624,14 +1616,14 @@ fn cmd_sources(c: cargo) {
let action = c.opts.free[2u];
alt action {
- ~"clear" {
+ ~"clear" => {
for c.sources.each_key |k| {
c.sources.remove(k);
}
info(~"cleared sources");
}
- ~"add" {
+ ~"add" => {
if vec::len(c.opts.free) < 5u {
cmd_usage();
return;
@@ -1646,10 +1638,10 @@ fn cmd_sources(c: cargo) {
}
alt c.sources.find(name) {
- some(source) {
+ some(source) => {
error(fmt!{"source already exists: %s", name});
}
- none {
+ none => {
c.sources.insert(name, @{
name: name,
mut url: url,
@@ -1662,7 +1654,7 @@ fn cmd_sources(c: cargo) {
}
}
}
- ~"remove" {
+ ~"remove" => {
if vec::len(c.opts.free) < 4u {
cmd_usage();
return;
@@ -1676,16 +1668,16 @@ fn cmd_sources(c: cargo) {
}
alt c.sources.find(name) {
- some(source) {
+ some(source) => {
c.sources.remove(name);
info(fmt!{"removed source: %s", name});
}
- none {
+ none => {
error(fmt!{"no such source: %s", name});
}
}
}
- ~"set-url" {
+ ~"set-url" => {
if vec::len(c.opts.free) < 5u {
cmd_usage();
return;
@@ -1700,7 +1692,7 @@ fn cmd_sources(c: cargo) {
}
alt c.sources.find(name) {
- some(source) {
+ some(source) => {
let old = copy source.url;
let method = assume_source_method(url);
@@ -1711,12 +1703,12 @@ fn cmd_sources(c: cargo) {
info(fmt!{"changed source url: '%s' to '%s'", old, url});
}
- none {
+ none => {
error(fmt!{"no such source: %s", name});
}
}
}
- ~"set-method" {
+ ~"set-method" => {
if vec::len(c.opts.free) < 5u {
cmd_usage();
return;
@@ -1731,13 +1723,13 @@ fn cmd_sources(c: cargo) {
}
alt c.sources.find(name) {
- some(source) {
+ some(source) => {
let old = copy source.method;
source.method = alt method {
- ~"git" { ~"git" }
- ~"file" { ~"file" }
- _ { ~"curl" }
+ ~"git" => ~"git",
+ ~"file" => ~"file",
+ _ => ~"curl"
};
c.sources.insert(name, source);
@@ -1745,12 +1737,12 @@ fn cmd_sources(c: cargo) {
info(fmt!{"changed source method: '%s' to '%s'", old,
method});
}
- none {
+ none => {
error(fmt!{"no such source: %s", name});
}
}
}
- ~"rename" {
+ ~"rename" => {
if vec::len(c.opts.free) < 5u {
cmd_usage();
return;
@@ -1769,17 +1761,17 @@ fn cmd_sources(c: cargo) {
}
alt c.sources.find(name) {
- some(source) {
+ some(source) => {
c.sources.remove(name);
c.sources.insert(newn, source);
info(fmt!{"renamed source: %s to %s", name, newn});
}
- none {
+ none => {
error(fmt!{"no such source: %s", name});
}
}
}
- _ { cmd_usage(); }
+ _ => cmd_usage()
}
}
@@ -1883,13 +1875,13 @@ fn main(argv: ~[~str]) {
}
if o.help {
alt o.free[1] {
- ~"init" { cmd_usage_init(); }
- ~"install" { cmd_usage_install(); }
- ~"uninstall" { cmd_usage_uninstall(); }
- ~"list" { cmd_usage_list(); }
- ~"search" { cmd_usage_search(); }
- ~"sources" { cmd_usage_sources(); }
- _ { cmd_usage(); }
+ ~"init" => cmd_usage_init(),
+ ~"install" => cmd_usage_install(),
+ ~"uninstall" => cmd_usage_uninstall(),
+ ~"list" => cmd_usage_list(),
+ ~"search" => cmd_usage_search(),
+ ~"sources" => cmd_usage_sources(),
+ _ => cmd_usage()
}
return;
}
@@ -1910,13 +1902,13 @@ fn main(argv: ~[~str]) {
}
alt o.free[1] {
- ~"init" { cmd_init(c); }
- ~"install" { cmd_install(c); }
- ~"uninstall" { cmd_uninstall(c); }
- ~"list" { cmd_list(c); }
- ~"search" { cmd_search(c); }
- ~"sources" { cmd_sources(c); }
- _ { cmd_usage(); }
+ ~"init" => cmd_init(c),
+ ~"install" => cmd_install(c),
+ ~"uninstall" => cmd_uninstall(c),
+ ~"list" => cmd_list(c),
+ ~"search" => cmd_search(c),
+ ~"sources" => cmd_sources(c),
+ _ => cmd_usage()
}
dump_cache(c);
View
37 src/compiletest/compiletest.rs
@@ -43,8 +43,8 @@ fn parse_config(args: ~[~str]) -> config {
let args_ = vec::tail(args);
let matches =
alt getopts::getopts(args_, opts) {
- ok(m) { m }
- err(f) { fail getopts::fail_str(f) }
+ ok(m) => m,
+ err(f) => fail getopts::fail_str(f)
};
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
@@ -85,7 +85,7 @@ fn log_config(config: config) {
}
fn opt_str(maybestr: option<~str>) -> ~str {
- alt maybestr { option::some(s) { s } option::none { ~"(none)" } }
+ alt maybestr { option::some(s) => s, option::none => ~"(none)" }
}
fn str_opt(maybestr: ~str) -> option<~str> {
@@ -94,20 +94,20 @@ fn str_opt(maybestr: ~str) -> option<~str> {
fn str_mode(s: ~str) -> mode {
alt s {
- ~"compile-fail" { mode_compile_fail }
- ~"run-fail" { mode_run_fail }
- ~"run-pass" { mode_run_pass }
- ~"pretty" { mode_pretty }
- _ { fail ~"invalid mode" }
+ ~"compile-fail" => mode_compile_fail,
+ ~"run-fail" => mode_run_fail,
+ ~"run-pass" => mode_run_pass,
+ ~"pretty" => mode_pretty,
+ _ => fail ~"invalid mode"
}
}
fn mode_str(mode: mode) -> ~str {
alt mode {
- mode_compile_fail { ~"compile-fail" }
- mode_run_fail { ~"run-fail" }
- mode_run_pass { ~"run-pass" }
- mode_pretty { ~"pretty" }
+ mode_compile_fail => ~"compile-fail",
+ mode_run_fail => ~"run-fail",
+ mode_run_pass => ~"run-pass",
+ mode_pretty => ~"pretty"
}
}
@@ -121,14 +121,14 @@ fn run_tests(config: config) {
fn test_opts(config: config) -> test::test_opts {
{filter:
alt config.filter {
- option::some(s) { option::some(s) }
- option::none { option::none }
+ option::some(s) => option::some(s),
+ option::none => option::none
},
run_ignored: config.run_ignored,
logfile:
alt config.logfile {
- option::some(s) { option::some(s) }
- option::none { option::none }
+ option::some(s) => option::some(s),
+ option::none => option::none
}
}
}
@@ -149,7 +149,10 @@ fn make_tests(config: config) -> ~[test::test_desc] {
fn is_test(config: config, testfile: ~str) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
- alt config.mode { mode_pretty { ~[~".rs"] } _ { ~[~".rc", ~".rs"] } };
+ alt config.mode {
+ mode_pretty => ~[~".rs"],
+ _ => ~[~".rc", ~".rs"]
+ };
let invalid_prefixes = ~[~".", ~"#", ~"~"];
let name = path::basename(testfile);
View
4 src/compiletest/errors.rs
@@ -24,8 +24,8 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
let error_tag = ~"//~";
let mut idx;
alt str::find_str(line, error_tag) {
- option::none { return ~[]; }
- option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
+ option::none => return ~[],
+ option::some(nn) => { idx = (nn as uint) + str::len(error_tag); }
}
// "//~^^^ kind msg" denotes a message expected
View
18 src/compiletest/header.rs
@@ -31,8 +31,8 @@ fn load_props(testfile: ~str) -> test_props {
let mut pp_exact = option::none;
for iter_header(testfile) |ln| {
alt parse_error_pattern(ln) {
- option::some(ep) { vec::push(error_patterns, ep) }
- option::none { }
+ option::some(ep) => vec::push(error_patterns, ep),
+ option::none => ()
};
if option::is_none(compile_flags) {
@@ -108,17 +108,17 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
// nv is either FOO or FOO=BAR
let strs = str::splitn_char(nv, '=', 1u);
alt strs.len() {
- 1u { (strs[0], ~"") }
- 2u { (strs[0], strs[1]) }
- n { fail fmt!{"Expected 1 or 2 strings, not %u", n}; }
+ 1u => (strs[0], ~""),
+ 2u => (strs[0], strs[1]),
+ n => fail fmt!{"Expected 1 or 2 strings, not %u", n}
}
}
}
fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> {
alt parse_name_value_directive(line, ~"pp-exact") {
- option::some(s) { option::some(s) }
- option::none {
+ option::some(s) => option::some(s),
+ option::none => {
if parse_name_directive(line, ~"pp-exact") {
option::some(path::basename(testfile))
} else {
@@ -136,12 +136,12 @@ fn parse_name_value_directive(line: ~str,
directive: ~str) -> option<~str> unsafe {
let keycolon = directive + ~":";
alt str::find_str(line, keycolon) {
- option::some(colon) {
+ option::some(colon) => {
let value = str::slice(line, colon + str::len(keycolon),
str::len(line));
debug!{"%s: %s", directive, value};
option::some(value)
}
- option::none { option::none }
+ option::none => option::none
}
}
View
4 src/compiletest/procsrv.rs
@@ -75,10 +75,10 @@ fn run(lib_path: ~str,
while count > 0 {
let stream = comm::recv(p);
alt check stream {
- (1, s) {
+ (1, s) => {
outs = s;
}
- (2, s) {
+ (2, s) => {
errs = s;
}
};
View
22 src/compiletest/runtest.rs
@@ -19,10 +19,10 @@ fn run(config: config, testfile: ~str) {
debug!{"running %s", testfile};
let props = load_props(testfile);
alt config.mode {
- mode_compile_fail { run_cfail_test(config, props, testfile); }
- mode_run_fail { run_rfail_test(config, props, testfile); }
- mode_run_pass { run_rpass_test(config, props, testfile); }
- mode_pretty { run_pretty_test(config, props, testfile); }
+ mode_compile_fail => run_cfail_test(config, props, testfile),
+ mode_run_fail => run_rfail_test(config, props, testfile),
+ mode_run_pass => run_rpass_test(config, props, testfile),
+ mode_pretty => run_pretty_test(config, props, testfile)
}
}
@@ -90,7 +90,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
} else { logv(config, ~"testing for converging pretty-printing"); }
let rounds =
- alt props.pp_exact { option::some(_) { 1 } option::none { 2 } };
+ alt props.pp_exact { option::some(_) => 1, option::none => 2 };
let mut srcs = ~[result::get(io::read_whole_file_str(testfile))];
@@ -110,11 +110,11 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) {
let mut expected =
alt props.pp_exact {
- option::some(file) {
+ option::some(file) => {
let filepath = path::connect(path::dirname(testfile), file);
result::get(io::read_whole_file_str(filepath))
}
- option::none { srcs[vec::len(srcs) - 2u] }
+ option::none => { srcs[vec::len(srcs) - 2u] }
};
let mut actual = srcs[vec::len(srcs) - 1u];
@@ -384,8 +384,8 @@ fn make_run_args(config: config, _props: test_props, testfile: ~str) ->
// then split apart its command
let runtool =
alt config.runtool {
- option::some(s) { option::some(s) }
- option::none { option::none }
+ option::some(s) => option::some(s),
+ option::none => option::none
};
split_maybe_args(runtool)
};
@@ -403,8 +403,8 @@ fn split_maybe_args(argstr: option<~str>) -> ~[~str] {
}
alt argstr {
- option::some(s) { rm_whitespace(str::split_char(s, ' ')) }
- option::none { ~[] }
+ option::some(s) => rm_whitespace(str::split_char(s, ' ')),
+ option::none => ~[]
}
}
View
4 src/compiletest/util.rs
@@ -8,10 +8,10 @@ fn make_new_path(path: ~str) -> ~str {
// Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own
alt getenv(lib_path_env_var()) {
- option::some(curr) {
+ option::some(curr) => {
fmt!{"%s%s%s", path, path_div(), curr}
}
- option::none { path }
+ option::none => path
}
}
View
76 src/fuzzer/fuzzer.rs
@@ -63,39 +63,39 @@ pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
alt tm {
- tm_converge {
+ tm_converge => {
alt e.node {
// If the fuzzer moves a block-ending-in-semicolon into callee
// position, the pretty-printer can't preserve this even by
// parenthesizing!! See email to marijn.
- ast::expr_if(_, _, _) { false }
- ast::expr_block(_) { false }
- ast::expr_alt(_, _, _) { false }
- ast::expr_while(_, _) { false }
+ ast::expr_if(_, _, _) => { false }
+ ast::expr_block(_) => { false }
+ ast::expr_alt(_, _, _) => { false }
+ ast::expr_while(_, _) => { false }
// https://github.com/mozilla/rust/issues/929
- ast::expr_cast(_, _) { false }
- ast::expr_assert(_) { false }
- ast::expr_binary(_, _, _) { false }
- ast::expr_assign(_, _) { false }
- ast::expr_assign_op(_, _, _) { false }
+ ast::expr_cast(_, _) => { false }
+ ast::expr_assert(_) => { false }
+ ast::expr_binary(_, _, _) => { false }
+ ast::expr_assign(_, _) => { false }
+ ast::expr_assign_op(_, _, _) => { false }
- ast::expr_fail(option::none) { false }
- ast::expr_ret(option::none) { false }
+ ast::expr_fail(option::none) => { false }
+ ast::expr_ret(option::none) => { false }
// https://github.com/mozilla/rust/issues/953
- ast::expr_fail(option::some(_)) { false }
+ ast::expr_fail(option::some(_)) => { false }
// https://github.com/mozilla/rust/issues/928
//ast::expr_cast(_, _) { false }
// https://github.com/mozilla/rust/issues/1458
- ast::expr_call(_, _, _) { false }
+ ast::expr_call(_, _, _) => { false }
- _ { true }
+ _ => { true }
}
}
- tm_run { true }
+ tm_run => { true }
}
}
@@ -141,23 +141,23 @@ fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff {
fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
alt e {
// https://github.com/mozilla/rust/issues/652
- ast::expr_if(*) { false }
- ast::expr_block(_) { false }
+ ast::expr_if(*) => { false }
+ ast::expr_block(_) => { false }
// expr_call is also missing a constraint
- ast::expr_fn_block(*) { false }
+ ast::expr_fn_block(*) => { false }
- _ { true }
+ _ => { true }
}
}
fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
alt t {
- ast::ty_infer { false } // always implicit, always top level
- ast::ty_bot { false } // in source, can only appear
+ ast::ty_infer => { false } // always implicit, always top level
+ ast::ty_bot => { false } // in source, can only appear
// as the out type of a function
- ast::ty_mac(_) { false }
- _ { true }
+ ast::ty_mac(_) => { false }
+ _ => { true }
}
}
@@ -273,10 +273,10 @@ fn check_variants_T<T: copy>(
pprust::no_ann(),
false));
alt cx.mode {
- tm_converge {
+ tm_converge => {
check_roundtrip_convergence(str3, 1u);
}
- tm_run {
+ tm_run => {
let file_label = fmt!{"rusttmp/%s_%s_%u_%u",
last_part(filename),
thing_label, i, j};
@@ -315,17 +315,17 @@ fn check_whole_compiler(code: ~str, suggested_filename_prefix: ~str,
let compile_result = check_compiling(filename);
let run_result = alt (compile_result, allow_running) {
- (passed, true) { check_running(suggested_filename_prefix) }
- (h, _) { h }
+ (passed, true) => { check_running(suggested_filename_prefix) }
+ (h, _) => { h }
};
alt run_result {
- passed | cleanly_rejected(_) | known_bug(_) {
+ passed | cleanly_rejected(_) | known_bug(_) => {
removeIfExists(suggested_filename_prefix);
removeIfExists(suggested_filename_prefix + ~".rs");
removeDirIfExists(suggested_filename_prefix + ~".dSYM");
}
- failed(s) {
+ failed(s) => {
log(error, ~"check_whole_compiler failure: " + s);
log(error, ~"Saved as: " + filename);
}
@@ -365,17 +365,17 @@ fn check_running(exe_filename: ~str) -> happiness {
failed(~"Mentioned malloc")
} else {
alt p.status {
- 0 { passed }
- 100 { cleanly_rejected(~"running: explicit fail") }
- 101 | 247 { cleanly_rejected(~"running: timed out") }
- 245 | 246 | 138 | 252 {
+ 0 => { passed }
+ 100 => { cleanly_rejected(~"running: explicit fail") }
+ 101 | 247 => { cleanly_rejected(~"running: timed out") }
+ 245 | 246 | 138 | 252 => {
known_bug(~"https://github.com/mozilla/rust/issues/1466")
}
- 136 | 248 {
+ 136 | 248 => {
known_bug(
~"SIGFPE - https://github.com/mozilla/rust/issues/944")
}
- rc {
+ rc => {
failed(~"Rust program ran but exited with status " +
int::str(rc))
}
@@ -442,8 +442,8 @@ fn has_raw_pointers(c: ast::crate) -> bool {
let has_rp = @mut false;
fn visit_ty(flag: @mut bool, t: @ast::ty) {
alt t.node {
- ast::ty_ptr(_) { *flag = true; }
- _ { }
+ ast::ty_ptr(_) => { *flag = true; }
+ _ => { }
}
}
let v =
View
6 src/libcore/bool.rs
@@ -40,9 +40,9 @@ pure fn is_false(v: bool) -> bool { !v }
/// Parse logic value from `s`
pure fn from_str(s: ~str) -> option<bool> {
alt check s {
- ~"true" { some(true) }
- ~"false" { some(false) }
- _ { none }
+ ~"true" => some(true),
+ ~"false" => some(false),
+ _ => none
}
}
View
24 src/libcore/char.rs
@@ -114,10 +114,10 @@ pure fn is_digit(c: char) -> bool {
*/
pure fn to_digit(c: char, radix: uint) -> option<uint> {
let val = alt c {
- '0' to '9' { c as uint - ('0' as uint) }
- 'a' to 'z' { c as uint + 10u - ('a' as uint) }
- 'A' to 'Z' { c as uint + 10u - ('A' as uint) }
- _ { return none; }
+ '0' to '9' => c as uint - ('0' as uint),
+ 'a' to 'z' => c as uint + 10u - ('a' as uint),
+ 'A' to 'Z' => c as uint + 10u - ('A' as uint),
+ _ => return none
};
if val < radix { some(val) }
else { none }
@@ -159,14 +159,14 @@ fn escape_unicode(c: char) -> ~str {
*/
fn escape_default(c: char) -> ~str {
alt c {
- '\t' { ~"\\t" }
- '\r' { ~"\\r" }
- '\n' { ~"\\n" }
- '\\' { ~"\\\\" }
- '\'' { ~"\\'" }
- '"' { ~"\\\"" }
- '\x20' to '\x7e' { str::from_char(c) }
- _ { escape_unicode(c) }
+ '\t' => ~"\\t",
+ '\r' => ~"\\r",
+ '\n' => ~"\\n",
+ '\\' => ~"\\\\",
+ '\'' => ~"\\'",
+ '"' => ~"\\\"",
+ '\x20' to '\x7e' => str::from_char(c),
+ _ => escape_unicode(c)
}
}
View
4 src/libcore/comm.rs
@@ -410,8 +410,8 @@ fn test_select2_stress() {
let mut bs = 0;
for iter::repeat(msgs * times * 2u) {
alt check select2(po_a, po_b) {
- either::left(~"a") { as += 1 }
- either::right(~"b") { bs += 1 }
+ either::left(~"a") => as += 1,
+ either::right(~"b") => bs += 1
}
}
View
60 src/libcore/dlist.rs
@@ -27,30 +27,22 @@ enum dlist<T> = @{
impl private_methods<T> for dlist_node<T> {
pure fn assert_links() {
alt self.next {
- some(neighbour) {
- alt neighbour.prev {
- some(me) {
- if !box::ptr_eq(*self, *me) {
- fail ~"Asymmetric next-link in dlist node."
- }
- }
- none { fail ~"One-way next-link in dlist node." }
- }
+ some(neighbour) => alt neighbour.prev {
+ some(me) => if !box::ptr_eq(*self, *me) {
+ fail ~"Asymmetric next-link in dlist node."
+ }
+ none => fail ~"One-way next-link in dlist node."
}
- none { }
+ none => ()
}
alt self.prev {
- some(neighbour) {
- alt neighbour.next {
- some(me) {
- if !box::ptr_eq(*me, *self) {
- fail ~"Asymmetric prev-link in dlist node."
- }
- }
- none { fail ~"One-way prev-link in dlist node." }
- }
+ some(neighbour) => alt neighbour.next {
+ some(me) => if !box::ptr_eq(*me, *self) {
+ fail ~"Asymmetric prev-link in dlist node."
+ }
+ none => fail ~"One-way prev-link in dlist node."
}
- none { }
+ none => ()
}
}
}
@@ -64,8 +56,8 @@ impl extensions<T> for dlist_node<T> {
/// Get the next node in the list, failing if there isn't one.
pure fn next_node() -> dlist_node<T> {
alt self.next_link() {
- some(nobe) { nobe }
- none { fail ~"This dlist node has no next neighbour." }
+ some(nobe) => nobe,
+ none => fail ~"This dlist node has no next neighbour."
}
}
/// Get the previous node in the list, if there is one.
@@ -76,8 +68,8 @@ impl extensions<T> for dlist_node<T> {
/// Get the previous node in the list, failing if there isn't one.
pure fn prev_node() -> dlist_node<T> {
alt self.prev_link() {
- some(nobe) { nobe }
- none { fail ~"This dlist node has no previous neighbour." }
+ some(nobe) => nobe,
+ none => fail ~"This dlist node has no previous neighbour."
}
}
}
@@ -147,12 +139,12 @@ impl private_methods<T> for dlist<T> {
#[inline(always)]
fn link(+before: dlist_link<T>, +after: dlist_link<T>) {
alt before {
- some(neighbour) { neighbour.next = after; }
- none { self.hd = after; }
+ some(neighbour) => neighbour.next = after,
+ none => self.hd = after
}
alt after {
- some(neighbour) { neighbour.prev = before; }
- none { self.tl = before; }
+ some(neighbour) => neighbour.prev = before,
+ none => self.tl = before
}
}
// Remove a node from the list.
@@ -295,19 +287,15 @@ impl extensions<T> for dlist<T> {
/// Get the node at the list's head, failing if empty. O(1).
pure fn head_n() -> dlist_node<T> {
alt self.hd {
- some(nobe) { nobe }
- none {
- fail ~"Attempted to get the head of an empty dlist."
- }
+ some(nobe) => nobe,
+ none => fail ~"Attempted to get the head of an empty dlist."
}
}
/// Get the node at the list's tail, failing if empty. O(1).
pure fn tail_n() -> dlist_node<T> {
alt self.tl {
- some(nobe) { nobe }
- none {
- fail ~"Attempted to get the tail of an empty dlist."
- }
+ some(nobe) => nobe,
+ none => fail ~"Attempted to get the tail of an empty dlist."
}
}
View
31 src/libcore/either.rs
@@ -18,7 +18,10 @@ fn either<T, U, V>(f_left: fn(T) -> V,
* result is returned.
*/
- alt value { left(l) { f_left(l) } right(r) { f_right(r) } }
+ alt value {
+ left(l) => f_left(l),
+ right(r) => f_right(r)
+ }
}
fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] {
@@ -26,7 +29,10 @@ fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] {
let mut result: ~[T] = ~[];
for vec::each(eithers) |elt| {
- alt elt { left(l) { vec::push(result, l); } _ {/* fallthrough */ } }
+ alt elt {
+ left(l) => vec::push(result, l),
+ _ => { /* fallthrough */ }
+ }
}
return result;
}
@@ -36,7 +42,10 @@ fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] {
let mut result: ~[U] = ~[];
for vec::each(eithers) |elt| {
- alt elt { right(r) { vec::push(result, r); } _ {/* fallthrough */ } }
+ alt elt {
+ right(r) => vec::push(result, r),
+ _ => { /* fallthrough */ }
+ }
}
return result;
}
@@ -54,8 +63,8 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>])
let mut rights: ~[U] = ~[];
for vec::each(eithers) |elt| {
alt elt {
- left(l) { vec::push(lefts, l); }
- right(r) { vec::push(rights, r); }
+ left(l) => vec::push(lefts, l),
+ right(r) => vec::push(rights, r)
}
}
return {lefts: lefts, rights: rights};
@@ -65,8 +74,8 @@ pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> {
//! Flips between left and right of a given either
alt eith {
- right(r) { left(r) }
- left(l) { right(l) }
+ right(r) => left(r),
+ left(l) => right(l)
}
}
@@ -80,21 +89,21 @@ pure fn to_result<T: copy, U: copy>(
*/
alt eith {
- right(r) { result::ok(r) }
- left(l) { result::err(l) }
+ right(r) => result::ok(r),
+ left(l) => result::err(l)
}
}
pure fn is_left<T, U>(eith: either<T, U>) -> bool {
//! Checks whether the given value is a left
- alt eith { left(_) { true } _ { false } }
+ alt eith { left(_) => true, _ => false }
}
pure fn is_right<T, U>(eith: either<T, U>) -> bool {
//! Checks whether the given value is a right
- alt eith { right(_) { true } _ { false } }
+ alt eith { right(_) => true, _ => false }
}
#[test]
View
65 src/libcore/extfmt.rs
@@ -123,8 +123,8 @@ mod ct {
if !('0' as u8 <= c && c <= '9' as u8) { return option::none; }
let n = (c - ('0' as u8)) as uint;
return alt peek_num(s, i + 1u, lim) {
- none { some({num: n, next: i + 1u}) }
- some(next) {
+ none => some({num: n, next: i + 1u}),
+ some(next) => {
let m = next.num;
let j = next.next;
some({num: n * 10u + m, next: j})
@@ -151,8 +151,8 @@ mod ct {
if i >= lim { return {param: none, next: i}; }
let num = peek_num(s, i, lim);
return alt num {
- none { {param: none, next: i} }
- some(t) {
+ none => {param: none, next: i},
+ some(t) => {
let n = t.num;
let j = t.next;
if j < lim && s[j] == '$' as u8 {
@@ -196,15 +196,16 @@ mod ct {
let param = parse_parameter(s, i + 1u, lim);
let j = param.next;
alt param.param {
- none { {count: count_is_next_param, next: j} }
- some(n) { {count: count_is_param(n), next: j} }
+ none => {count: count_is_next_param, next: j},
+ some(n) => {count: count_is_param(n), next: j}
}
} else {
let num = peek_num(s, i, lim);
alt num {
- none { {count: count_implied, next: i} }
- some(num) {
- {count: count_is(num.num as int), next: num.next}
+ none => {count: count_implied, next: i},
+ some(num) => {
+ count: count_is(num.num as int),
+ next: num.next
}
}
};
@@ -220,8 +221,8 @@ mod ct {
// If there were no digits specified, i.e. the precision
// was ".", then the precision is 0
alt count.count {
- count_implied { {count: count_is(0), next: count.next} }
- _ { count }
+ count_implied => {count: count_is(0), next: count.next},
+ _ => count
}
} else { {count: count_implied, next: i} };
}
@@ -294,11 +295,11 @@ mod rt {
let prec = get_int_precision(cv);
let mut rs =
alt cv.ty {
- ty_default { uint_to_str_prec(u, 10u, prec) }
- ty_hex_lower { uint_to_str_prec(u, 16u, prec) }
- ty_hex_upper { str::to_upper(uint_to_str_prec(u, 16u, prec)) }
- ty_bits { uint_to_str_prec(u, 2u, prec) }
- ty_octal { uint_to_str_prec(u, 8u, prec) }
+ ty_default => uint_to_str_prec(u, 10u, prec),
+ ty_hex_lower => uint_to_str_prec(u, 16u, prec),
+ ty_hex_upper => str::to_upper(uint_to_str_prec(u, 16u, prec)),
+ ty_bits => uint_to_str_prec(u, 2u, prec),
+ ty_octal => uint_to_str_prec(u, 8u, prec)
};
return unchecked { pad(cv, rs, pad_unsigned) };
}
@@ -316,19 +317,19 @@ mod rt {
// For strings, precision is the maximum characters
// displayed
let mut unpadded = alt cv.precision {
- count_implied { s.to_unique() }
- count_is(max) {
- if max as uint < str::char_len(s) {
- str::substr(s, 0u, max as uint)
- } else { s.to_unique() }
+ count_implied => s.to_unique(),
+ count_is(max) => if max as uint < str::char_len(s) {
+ str::substr(s, 0u, max as uint)
+ } else {
+ s.to_unique()
}
};
return unchecked { pad(cv, unpadded, pad_nozero) };
}
pure fn conv_float(cv: conv, f: float) -> ~str {
let (to_str, digits) = alt cv.precision {
- count_is(c) { (float::to_str_exact, c as uint) }
- count_implied { (float::to_str, 6u) }
+ count_is(c) => (float::to_str_exact, c as uint),
+ count_implied => (float::to_str, 6u)
};
let mut s = unchecked { to_str(f, digits) };
if 0.0 <= f {
@@ -371,15 +372,15 @@ mod rt {
}
pure fn get_int_precision(cv: conv) -> uint {
return alt cv.precision {
- count_is(c) { c as uint }
- count_implied { 1u }
+ count_is(c) => c as uint,
+ count_implied => 1u
};
}
enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float }
fn pad(cv: conv, &s: ~str, mode: pad_mode) -> ~str {
let uwidth : uint = alt cv.width {
- count_implied { return s; }
- count_is(width) {
+ count_implied => return s,
+ count_is(width) => {
// FIXME: width should probably be uint (see Issue #1996)
width as uint
}
@@ -393,13 +394,13 @@ mod rt {
return s + padstr;
}
let {might_zero_pad, signed} = alt mode {
- pad_nozero { {might_zero_pad:false, signed:false} }
- pad_signed { {might_zero_pad:true, signed:true } }
- pad_float { {might_zero_pad:true, signed:true } }
- pad_unsigned { {might_zero_pad:true, signed:false} }
+ pad_nozero => {might_zero_pad:false, signed:false},
+ pad_signed => {might_zero_pad:true, signed:true },
+ pad_float => {might_zero_pad:true, signed:true},
+ pad_unsigned => {might_zero_pad:true, signed:false}
};
pure fn have_precision(cv: conv) -> bool {
- return alt cv.precision { count_implied { false } _ { true } };
+ return alt cv.precision { count_implied => false, _ => true };
}
let zero_padding = {
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
View
46 src/libcore/float.rs
@@ -257,21 +257,21 @@ fn from_str(num: ~str) -> option<float> {
//The string must start with one of the following characters.
alt str::char_at(num, 0u) {
- '-' | '+' | '0' to '9' | '.' {}
- _ { return none; }
+ '-' | '+' | '0' to '9' | '.' => (),
+ _ => return none
}
//Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly.
let mut neg = false; //Sign of the result
alt str::char_at(num, 0u) {
- '-' {
+ '-' => {
neg = true;
pos = 1u;
}
- '+' {
+ '+' => {
pos = 1u;
}
- _ {}
+ _ => ()
}
//Examine the following chars until '.', 'e', 'E'
@@ -280,16 +280,12 @@ fn from_str(num: ~str) -> option<float> {
c = char_range.ch;
pos = char_range.next;
alt c {
- '0' to '9' {
+ '0' to '9' => {
total = total * 10f;
total += ((c as int) - ('0' as int)) as float;
}
- '.' | 'e' | 'E' {
- break;
- }
- _ {
- return none;
- }
+ '.' | 'e' | 'E' => break,
+ _ => return none
}
}
@@ -300,16 +296,12 @@ fn from_str(num: ~str) -> option<float> {
c = char_range.ch;
pos = char_range.next;
alt c {
- '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' {
+ '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => {
decimal /= 10f;
total += (((c as int) - ('0'