diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-06 12:34:08 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-06 15:36:30 -0700 |
| commit | ecaf9e39c9435fa2de4fe393c4b263be36eb2d99 (patch) | |
| tree | 775f69be65adff65551d96173dd797e32e2c3157 /src | |
| parent | d3a9bb1bd4a1d510bbaca2ab1121e4c85a239247 (diff) | |
| download | rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.tar.gz rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.zip | |
Convert alt to match. Stop parsing alt
Diffstat (limited to 'src')
357 files changed, 2901 insertions, 2878 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 33482679920..2f162db325c 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -128,7 +128,7 @@ fn is_uuid(id: ~str) -> bool { return false; } - alt i { + match i { 0u => { if str::len(part) == 8u { correct += 1u; @@ -192,7 +192,7 @@ fn is_archive_url(u: ~str) -> bool { // FIXME (#2661): this requires the protocol bit - if we had proper // url parsing, we wouldn't need it - alt str::find_str(u, ~"://") { + match str::find_str(u, ~"://") { option::some(i) => has_archive_extension(u), _ => false } @@ -223,9 +223,9 @@ fn load_link(mis: ~[@ast::meta_item]) -> (option<~str>, let mut vers = none; let mut uuid = none; for mis.each |a| { - alt a.node { + match a.node { ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) => { - alt *v { + match *v { ~"name" => name = some(*s), ~"vers" => vers = some(*s), ~"uuid" => uuid = some(*s), @@ -250,9 +250,9 @@ fn load_crate(filename: ~str) -> option<crate> { let mut crate_type = none; for c.node.attrs.each |a| { - alt a.node.value.node { + match a.node.value.node { ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) => { - alt *v { + match *v { ~"desc" => desc = some(*v), ~"sigs" => sigs = some(*v), ~"crate_type" => crate_type = some(*v), @@ -279,7 +279,7 @@ fn load_crate(filename: ~str) -> option<crate> { }; fn goto_view_item(e: env, i: @ast::view_item) { - alt i.node { + match i.node { ast::view_item_use(ident, metas, id) => { let name_items = attr::find_meta_items_by_name(metas, ~"name"); @@ -293,11 +293,11 @@ fn load_crate(filename: ~str) -> option<crate> { let mut attr_from = ~""; for m.each |item| { - alt attr::get_meta_item_value_str(item) { + match attr::get_meta_item_value_str(item) { some(value) => { let name = attr::get_meta_item_name(item); - alt *name { + match *name { ~"vers" => attr_vers = *value, ~"from" => attr_from = *value, _ => () @@ -315,7 +315,7 @@ fn load_crate(filename: ~str) -> option<crate> { } else { *attr_name } }; - alt *attr_name { + match *attr_name { ~"std" | ~"core" => (), _ => vec::push(e.deps, query) } @@ -339,7 +339,7 @@ fn load_crate(filename: ~str) -> option<crate> { let deps = copy e.deps; - alt (name, vers, uuid) { + match (name, vers, uuid) { (some(name0), some(vers0), some(uuid0)) => { some({ name: name0, @@ -390,21 +390,21 @@ fn parse_source(name: ~str, j: json::json) -> source { fail fmt!{"'%s' is an invalid source name", name}; } - alt j { + match j { json::dict(j) => { - let mut url = alt j.find(~"url") { + let mut url = match j.find(~"url") { some(json::string(u)) => *u, _ => fail ~"needed 'url' field in source" }; - let method = alt j.find(~"method") { + let method = match j.find(~"method") { some(json::string(u)) => *u, _ => assume_source_method(url) }; - let key = alt j.find(~"key") { + let key = match j.find(~"key") { some(json::string(u)) => some(*u), _ => none }; - let keyfp = alt j.find(~"keyfp") { + let keyfp = match j.find(~"keyfp") { some(json::string(u)) => some(*u), _ => none }; @@ -426,7 +426,7 @@ fn parse_source(name: ~str, j: json::json) -> source { 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)) { + match json::from_str(result::get(c)) { ok(json::dict(j)) => { for j.each |k, v| { sources.insert(k, parse_source(k, v)); @@ -439,7 +439,7 @@ fn try_parse_sources(filename: ~str, sources: map::hashmap<~str, source>) { } fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { - let name = alt p.find(~"name") { + let name = match p.find(~"name") { some(json::string(n)) => { if !valid_pkg_name(*n) { warn(~"malformed source json: " @@ -456,7 +456,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { } }; - let uuid = alt p.find(~"uuid") { + let uuid = match p.find(~"uuid") { some(json::string(n)) => { if !is_uuid(*n) { warn(~"malformed source json: " @@ -472,7 +472,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { } }; - let url = alt p.find(~"url") { + let url = match p.find(~"url") { some(json::string(n)) => *n, _ => { warn(~"malformed source json: " + src.name + ~" (missing url)"); @@ -480,7 +480,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { } }; - let method = alt p.find(~"method") { + let method = match p.find(~"method") { some(json::string(n)) => *n, _ => { warn(~"malformed source json: " @@ -489,16 +489,16 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { } }; - let reference = alt p.find(~"ref") { + let reference = match p.find(~"ref") { some(json::string(n)) => some(*n), _ => none }; let mut tags = ~[]; - alt p.find(~"tags") { + match p.find(~"tags") { some(json::list(js)) => { for (*js).each |j| { - alt j { + match j { json::string(j) => vec::grow(tags, 1u, *j), _ => () } @@ -507,7 +507,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { _ => () } - let description = alt p.find(~"description") { + let description = match p.find(~"description") { some(json::string(n)) => *n, _ => { warn(~"malformed source json: " + src.name @@ -527,7 +527,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { versions: ~[] }; - alt vec::position(src.packages, |pkg| pkg.uuid == uuid) { + match vec::position(src.packages, |pkg| pkg.uuid == uuid) { some(idx) => { src.packages[idx] = newpkg; log(debug, ~" updated package: " + src.name + ~"/" + name); @@ -545,7 +545,7 @@ fn load_source_info(c: cargo, src: source) { let srcfile = path::connect(dir, ~"source.json"); if !os::path_exists(srcfile) { return; } let srcstr = io::read_whole_file_str(srcfile); - alt json::from_str(result::get(srcstr)) { + match json::from_str(result::get(srcstr)) { ok(json::dict(s)) => { let o = parse_source(src.name, json::dict(s)); @@ -567,10 +567,10 @@ fn load_source_packages(c: cargo, src: source) { let pkgfile = path::connect(dir, ~"packages.json"); if !os::path_exists(pkgfile) { return; } let pkgstr = io::read_whole_file_str(pkgfile); - alt json::from_str(result::get(pkgstr)) { + match json::from_str(result::get(pkgstr)) { ok(json::list(js)) => { for (*js).each |j| { - alt j { + match j { json::dict(p) => { load_one_source_package(src, p); } @@ -592,7 +592,7 @@ fn load_source_packages(c: cargo, src: source) { } fn build_cargo_options(argv: ~[~str]) -> options { - let matches = alt getopts::getopts(argv, opts()) { + let matches = match getopts::getopts(argv, opts()) { result::ok(m) => m, result::err(f) => { fail fmt!{"%s", getopts::fail_str(f)}; @@ -623,12 +623,12 @@ fn build_cargo_options(argv: ~[~str]) -> options { } fn configure(opts: options) -> cargo { - let home = alt get_cargo_root() { + let home = match get_cargo_root() { ok(home) => home, err(_err) => result::get(get_cargo_sysroot()) }; - let get_cargo_dir = alt opts.mode { + let get_cargo_dir = match opts.mode { system_mode => get_cargo_sysroot, user_mode => get_cargo_root, local_mode => get_cargo_root_nearest @@ -716,7 +716,7 @@ 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, + let buildpath = match run_in_buildpath(~"testing", path, ~"/test", cf, ~[ ~"--test"]) { none => return, some(bp) => bp @@ -725,7 +725,7 @@ 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, + let buildpath = match run_in_buildpath(~"installing", path, ~"/build", cf, ~[]) { none => return, some(bp) => bp @@ -752,7 +752,7 @@ fn install_one_crate(c: cargo, path: ~str, cf: ~str) { fn rustc_sysroot() -> ~str { - alt os::self_exe_path() { + match os::self_exe_path() { some(path) => { let path = ~[path, ~"..", ~"bin", ~"rustc"]; let rustc = path::normalize(path::connect_many(path)); @@ -779,7 +779,7 @@ fn install_source(c: cargo, path: ~str) { } for cratefiles.each |cf| { - alt load_crate(cf) { + match load_crate(cf) { none => again, some(crate) => { for crate.deps.each |query| { @@ -788,7 +788,7 @@ fn install_source(c: cargo, path: ~str) { // condition") let wd_base = c.workdir + path::path_sep(); - let wd = alt tempfile::mkdtemp(wd_base, ~"") { + let wd = match tempfile::mkdtemp(wd_base, ~"") { some(wd) => wd, none => fail fmt!{"needed temp dir: %s", wd_base} }; @@ -838,7 +838,7 @@ 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 { + let method = match pkg.method { ~"git" => ~"git", ~"file" => ~"file", _ => ~"curl" @@ -846,7 +846,7 @@ fn install_package(c: cargo, src: ~str, wd: ~str, pkg: package) { info(fmt!{"installing %s/%s via %s...", src, pkg.name, method}); - alt method { + match method { ~"git" => install_git(c, wd, url, copy pkg.reference), ~"file" => install_file(c, wd, url), ~"curl" => install_curl(c, wd, copy url), @@ -913,7 +913,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) { + match c.sources.find(src) { some(s) => { let packages = copy s.packages; if vec::any(packages, |p| { @@ -929,7 +929,7 @@ fn install_uuid_specific(c: cargo, wd: ~str, src: ~str, uuid: ~str) { } fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) { - alt c.sources.find(src) { + match c.sources.find(src) { some(s) => { let packages = copy s.packages; if vec::any(packages, |p| { @@ -960,7 +960,7 @@ fn cmd_uninstall(c: cargo) { // name only) if is_uuid(target) { for os::list_dir(lib).each |file| { - alt str::find_str(file, ~"-" + target + ~"-") { + match str::find_str(file, ~"-" + target + ~"-") { some(idx) => { let full = path::normalize(path::connect(lib, file)); if os::remove_file(full) { @@ -977,7 +977,7 @@ fn cmd_uninstall(c: cargo) { error(~"can't find package with uuid: " + target); } else { for os::list_dir(lib).each |file| { - alt str::find_str(file, ~"lib" + target + ~"-") { + match str::find_str(file, ~"lib" + target + ~"-") { some(idx) => { let full = path::normalize(path::connect(lib, file)); @@ -992,7 +992,7 @@ fn cmd_uninstall(c: cargo) { } } for os::list_dir(bin).each |file| { - alt str::find_str(file, target) { + match str::find_str(file, target) { some(idx) => { let full = path::normalize(path::connect(bin, file)); if os::remove_file(full) { @@ -1011,7 +1011,7 @@ fn cmd_uninstall(c: cargo) { } fn install_query(c: cargo, wd: ~str, target: ~str) { - alt c.dep_cache.find(target) { + match c.dep_cache.find(target) { some(inst) => { if inst { return; @@ -1038,7 +1038,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) { } else { let mut ps = copy target; - alt str::find_char(ps, '/') { + match str::find_char(ps, '/') { option::some(idx) => { let source = str::slice(ps, 0u, idx); ps = str::slice(ps, idx + 1u, str::len(ps)); @@ -1072,7 +1072,7 @@ 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, ~"") { + let wd = match tempfile::mkdtemp(wd_base, ~"") { some(wd) => wd, none => fail fmt!{"needed temp dir: %s", wd_base} }; @@ -1129,7 +1129,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { os::copy_file(path::connect(url, ~"source.json.sig"), srcsigfile); os::copy_file(path::connect(url, ~"packages.json.sig"), sigfile); - alt copy src.key { + match copy src.key { some(u) => { let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", keyfile, u]); @@ -1141,7 +1141,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { } _ => () } - alt (src.key, src.keyfp) { + match (src.key, src.keyfp) { (some(_), some(f)) => { let r = pgp::verify(c.root, pkgfile, sigfile, f); @@ -1238,7 +1238,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { let has_src_file = os::path_exists(srcfile); - alt copy src.key { + match copy src.key { some(u) => { let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", keyfile, u]); @@ -1251,7 +1251,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { } _ => () } - alt (src.key, src.keyfp) { + match (src.key, src.keyfp) { (some(_), some(f)) => { let r = pgp::verify(c.root, pkgfile, sigfile, f); @@ -1318,7 +1318,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { } } - alt copy src.key { + match copy src.key { some(u) => { let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", keyfile, u]); @@ -1330,7 +1330,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { } _ => () } - alt (src.key, src.keyfp) { + match (src.key, src.keyfp) { (some(_), some(f)) => { if smart { url = src.url + ~"/packages.json.sig"; @@ -1403,7 +1403,7 @@ fn sync_one(c: cargo, src: source) { need_dir(dir); - let result = alt src.method { + let result = match src.method { ~"git" => sync_one_git(c, dir, src), ~"file" => sync_one_file(c, dir, src), _ => sync_one_curl(c, dir, src) @@ -1490,7 +1490,7 @@ fn cmd_list(c: cargo) { if !valid_pkg_name(name) { error(fmt!{"'%s' is an invalid source name", name}); } else { - alt c.sources.find(name) { + match c.sources.find(name) { some(source) => { print_source(source); } @@ -1562,7 +1562,7 @@ fn dump_sources(c: cargo) { copy_warn(out, path::connect(c.root, ~"sources.json.old")); } - alt io::buffered_file_writer(out) { + match io::buffered_file_writer(out) { result::ok(writer) => { let hash = map::str_hash(); let root = json::dict(hash); @@ -1574,13 +1574,13 @@ fn dump_sources(c: cargo) { chash.insert(~"url", json::string(@v.url)); chash.insert(~"method", json::string(@v.method)); - alt copy v.key { + match copy v.key { some(key) => { chash.insert(~"key", json::string(@key)); } _ => () } - alt copy v.keyfp { + match copy v.keyfp { some(keyfp) => { chash.insert(~"keyfp", json::string(@keyfp)); } @@ -1615,7 +1615,7 @@ fn cmd_sources(c: cargo) { let action = c.opts.free[2u]; - alt action { + match action { ~"clear" => { for c.sources.each_key |k| { c.sources.remove(k); @@ -1637,7 +1637,7 @@ fn cmd_sources(c: cargo) { return; } - alt c.sources.find(name) { + match c.sources.find(name) { some(source) => { error(fmt!{"source already exists: %s", name}); } @@ -1667,7 +1667,7 @@ fn cmd_sources(c: cargo) { return; } - alt c.sources.find(name) { + match c.sources.find(name) { some(source) => { c.sources.remove(name); info(fmt!{"removed source: %s", name}); @@ -1691,7 +1691,7 @@ fn cmd_sources(c: cargo) { return; } - alt c.sources.find(name) { + match c.sources.find(name) { some(source) => { let old = copy source.url; let method = assume_source_method(url); @@ -1722,11 +1722,11 @@ fn cmd_sources(c: cargo) { return; } - alt c.sources.find(name) { + match c.sources.find(name) { some(source) => { let old = copy source.method; - source.method = alt method { + source.method = match method { ~"git" => ~"git", ~"file" => ~"file", _ => ~"curl" @@ -1760,7 +1760,7 @@ fn cmd_sources(c: cargo) { return; } - alt c.sources.find(name) { + match c.sources.find(name) { some(source) => { c.sources.remove(name); c.sources.insert(newn, source); @@ -1874,7 +1874,7 @@ fn main(argv: ~[~str]) { return; } if o.help { - alt o.free[1] { + match o.free[1] { ~"init" => cmd_usage_init(), ~"install" => cmd_usage_install(), ~"uninstall" => cmd_usage_uninstall(), @@ -1901,7 +1901,7 @@ fn main(argv: ~[~str]) { c = configure(o); } - alt o.free[1] { + match o.free[1] { ~"init" => cmd_init(c), ~"install" => cmd_install(c), ~"uninstall" => cmd_uninstall(c), diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 33b9655aeb2..fd9a12aa1f7 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -37,7 +37,7 @@ fn parse_config(args: ~[~str]) -> config { assert (vec::is_not_empty(args)); let args_ = vec::tail(args); let matches = - alt getopts::getopts(args_, opts) { + match getopts::getopts(args_, opts) { ok(m) => m, err(f) => fail getopts::fail_str(f) }; @@ -80,7 +80,7 @@ fn log_config(config: config) { } fn opt_str(maybestr: option<~str>) -> ~str { - alt maybestr { option::some(s) => s, option::none => ~"(none)" } + match maybestr { option::some(s) => s, option::none => ~"(none)" } } fn str_opt(maybestr: ~str) -> option<~str> { @@ -88,7 +88,7 @@ fn str_opt(maybestr: ~str) -> option<~str> { } fn str_mode(s: ~str) -> mode { - alt s { + match s { ~"compile-fail" => mode_compile_fail, ~"run-fail" => mode_run_fail, ~"run-pass" => mode_run_pass, @@ -98,7 +98,7 @@ fn str_mode(s: ~str) -> mode { } fn mode_str(mode: mode) -> ~str { - alt mode { + match mode { mode_compile_fail => ~"compile-fail", mode_run_fail => ~"run-fail", mode_run_pass => ~"run-pass", @@ -115,13 +115,13 @@ fn run_tests(config: config) { fn test_opts(config: config) -> test::test_opts { {filter: - alt config.filter { + match config.filter { option::some(s) => option::some(s), option::none => option::none }, run_ignored: config.run_ignored, logfile: - alt config.logfile { + match config.logfile { option::some(s) => option::some(s), option::none => option::none } @@ -144,7 +144,7 @@ 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 { + match config.mode { mode_pretty => ~[~".rs"], _ => ~[~".rc", ~".rs"] }; diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index 8a550e94c78..53599a9ad0e 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -23,7 +23,7 @@ fn load_errors(testfile: ~str) -> ~[expected_error] { fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe { let error_tag = ~"//~"; let mut idx; - alt str::find_str(line, error_tag) { + match str::find_str(line, error_tag) { option::none => return ~[], option::some(nn) => { idx = (nn as uint) + str::len(error_tag); } } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 731e874ddcc..bf58e809692 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -30,7 +30,7 @@ fn load_props(testfile: ~str) -> test_props { let mut compile_flags = option::none; let mut pp_exact = option::none; for iter_header(testfile) |ln| { - alt parse_error_pattern(ln) { + match parse_error_pattern(ln) { option::some(ep) => vec::push(error_patterns, ep), option::none => () }; @@ -107,7 +107,7 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> { do parse_name_value_directive(line, ~"exec-env").map |nv| { // nv is either FOO or FOO=BAR let strs = str::splitn_char(nv, '=', 1u); - alt strs.len() { + match strs.len() { 1u => (strs[0], ~""), 2u => (strs[0], strs[1]), n => fail fmt!{"Expected 1 or 2 strings, not %u", n} @@ -116,7 +116,7 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> { } fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> { - alt parse_name_value_directive(line, ~"pp-exact") { + match parse_name_value_directive(line, ~"pp-exact") { option::some(s) => option::some(s), option::none => { if parse_name_directive(line, ~"pp-exact") { @@ -135,7 +135,7 @@ fn parse_name_directive(line: ~str, directive: ~str) -> bool { fn parse_name_value_directive(line: ~str, directive: ~str) -> option<~str> unsafe { let keycolon = directive + ~":"; - alt str::find_str(line, keycolon) { + match str::find_str(line, keycolon) { option::some(colon) => { let value = str::slice(line, colon + str::len(keycolon), str::len(line)); diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index a8418a545a2..ba4249999a4 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -76,7 +76,7 @@ fn run(lib_path: ~str, let mut outs = ~""; let mut count = 2; while count > 0 { - alt p.recv() { + match p.recv() { (1, s) => { outs = s; } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 79b7e6f08d4..7a2d3456ed6 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -18,7 +18,7 @@ fn run(config: config, testfile: ~str) { } debug!{"running %s", testfile}; let props = load_props(testfile); - alt config.mode { + match 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), @@ -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 }; + match props.pp_exact { option::some(_) => 1, option::none => 2 }; let mut srcs = ~[result::get(io::read_whole_file_str(testfile))]; @@ -109,7 +109,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) { } let mut expected = - alt props.pp_exact { + match props.pp_exact { option::some(file) => { let filepath = path::connect(path::dirname(testfile), file); result::get(io::read_whole_file_str(filepath)) @@ -383,7 +383,7 @@ fn make_run_args(config: config, _props: test_props, testfile: ~str) -> // If we've got another tool to run under (valgrind), // then split apart its command let runtool = - alt config.runtool { + match config.runtool { option::some(s) => option::some(s), option::none => option::none }; @@ -402,7 +402,7 @@ fn split_maybe_args(argstr: option<~str>) -> ~[~str] { vec::filter_map(v, flt) } - alt argstr { + match argstr { option::some(s) => rm_whitespace(str::split_char(s, ' ')), option::none => ~[] } diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 027d247ebb8..0c7a0235bee 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -7,7 +7,7 @@ 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()) { + match getenv(lib_path_env_var()) { option::some(curr) => { fmt!{"%s%s%s", path, path_div(), curr} } diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index 1cc0c08eb5c..230ef3d981f 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -62,9 +62,9 @@ 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 { + match tm { tm_converge => { - alt e.node { + match 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. @@ -139,7 +139,7 @@ fn steal(crate: ast::crate, tm: test_mode) -> stolen_stuff { fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool { - alt e { + match e { // https://github.com/mozilla/rust/issues/652 ast::expr_if(*) => { false } ast::expr_block(_) => { false } @@ -152,7 +152,7 @@ fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool { } fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool { - alt t { + match t { 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 @@ -272,7 +272,7 @@ fn check_variants_T<T: copy>( io::str_reader(~""), a, pprust::no_ann(), false)); - alt cx.mode { + match cx.mode { tm_converge => { check_roundtrip_convergence(str3, 1u); } @@ -314,12 +314,12 @@ fn check_whole_compiler(code: ~str, suggested_filename_prefix: ~str, let compile_result = check_compiling(filename); - let run_result = alt (compile_result, allow_running) { + let run_result = match (compile_result, allow_running) { (passed, true) => { check_running(suggested_filename_prefix) } (h, _) => { h } }; - alt run_result { + match run_result { passed | cleanly_rejected(_) | known_bug(_) => { removeIfExists(suggested_filename_prefix); removeIfExists(suggested_filename_prefix + ~".rs"); @@ -364,7 +364,7 @@ fn check_running(exe_filename: ~str) -> happiness { } else if contains(comb, ~"malloc") { failed(~"Mentioned malloc") } else { - alt p.status { + match p.status { 0 => { passed } 100 => { cleanly_rejected(~"running: explicit fail") } 101 | 247 => { cleanly_rejected(~"running: timed out") } @@ -441,7 +441,7 @@ fn parse_and_print(code: @~str) -> ~str { 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 { + match t.node { ast::ty_ptr(_) => { *flag = true; } _ => { } } diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 91b268bc703..f8eb96996d0 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -39,7 +39,7 @@ pure fn is_false(v: bool) -> bool { !v } /// Parse logic value from `s` pure fn from_str(s: ~str) -> option<bool> { - alt check s { + match check s { ~"true" => some(true), ~"false" => some(false), _ => none diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 97a484b491f..98aeddcf273 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -113,7 +113,7 @@ pure fn is_digit(c: char) -> bool { * refer to a digit in the given radix. */ pure fn to_digit(c: char, radix: uint) -> option<uint> { - let val = alt c { + let val = match 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), @@ -158,7 +158,7 @@ fn escape_unicode(c: char) -> ~str { * - Any other chars are given hex unicode escapes; see `escape_unicode`. */ fn escape_default(c: char) -> ~str { - alt c { + match c { '\t' => ~"\\t", '\r' => ~"\\r", '\n' => ~"\\n", diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 86bcfad89dd..794bdc90885 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -409,7 +409,7 @@ fn test_select2_stress() { let mut as = 0; let mut bs = 0; for iter::repeat(msgs * times * 2u) { - alt check select2(po_a, po_b) { + match check select2(po_a, po_b) { either::left(~"a") => as += 1, either::right(~"b") => bs += 1 } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 7b9d4432e54..9d410c03d6a 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -26,8 +26,8 @@ enum dlist<T> = @{ impl private_methods<T> for dlist_node<T> { pure fn assert_links() { - alt self.next { - some(neighbour) => alt neighbour.prev { + match self.next { + some(neighbour) => match neighbour.prev { some(me) => if !box::ptr_eq(*self, *me) { fail ~"Asymmetric next-link in dlist node." } @@ -35,8 +35,8 @@ impl private_methods<T> for dlist_node<T> { } none => () } - alt self.prev { - some(neighbour) => alt neighbour.next { + match self.prev { + some(neighbour) => match neighbour.next { some(me) => if !box::ptr_eq(*me, *self) { fail ~"Asymmetric prev-link in dlist node." } @@ -55,7 +55,7 @@ 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() { + match self.next_link() { some(nobe) => nobe, none => fail ~"This dlist node has no next neighbour." } @@ -67,7 +67,7 @@ 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() { + match self.prev_link() { some(nobe) => nobe, none => fail ~"This dlist node has no previous neighbour." } @@ -138,11 +138,11 @@ impl private_methods<T> for dlist<T> { // the head and/or tail pointers appropriately. #[inline(always)] fn link(+before: dlist_link<T>, +after: dlist_link<T>) { - alt before { + match before { some(neighbour) => neighbour.next = after, none => self.hd = after } - alt after { + match after { some(neighbour) => neighbour.prev = before, none => self.tl = before } @@ -286,14 +286,14 @@ 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 { + match self.hd { 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 { + match self.tl { some(nobe) => nobe, none => fail ~"Attempted to get the tail of an empty dlist." } diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 4f1e02d674d..a05df4e608a 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -222,7 +222,7 @@ impl extensions<A:copy> for dvec<A> { */ fn append_iter<A, I:iter::base_iter<A>>(ts: I) { do self.swap |v| { - let mut v = alt ts.size_hint() { + let mut v = match ts.size_hint() { none { v } some(h) { let len = v.len() + h; diff --git a/src/libcore/either.rs b/src/libcore/either.rs index d07b126bb5d..06999513889 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -18,7 +18,7 @@ fn either<T, U, V>(f_left: fn(T) -> V, * result is returned. */ - alt value { + match value { left(l) => f_left(l), right(r) => f_right(r) } @@ -29,7 +29,7 @@ fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] { let mut result: ~[T] = ~[]; for vec::each(eithers) |elt| { - alt elt { + match elt { left(l) => vec::push(result, l), _ => { /* fallthrough */ } } @@ -42,7 +42,7 @@ fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] { let mut result: ~[U] = ~[]; for vec::each(eithers) |elt| { - alt elt { + match elt { right(r) => vec::push(result, r), _ => { /* fallthrough */ } } @@ -62,7 +62,7 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) let mut lefts: ~[T] = ~[]; let mut rights: ~[U] = ~[]; for vec::each(eithers) |elt| { - alt elt { + match elt { left(l) => vec::push(lefts, l), right(r) => vec::push(rights, r) } @@ -73,7 +73,7 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) 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 { + match eith { right(r) => left(r), left(l) => right(l) } @@ -88,7 +88,7 @@ pure fn to_result<T: copy, U: copy>( * an ok result, and the "left" choice a fail */ - alt eith { + match eith { right(r) => result::ok(r), left(l) => result::err(l) } @@ -97,13 +97,13 @@ pure fn to_result<T: copy, U: copy>( pure fn is_left<T, U>(eith: either<T, U>) -> bool { //! Checks whether the given value is a left - alt eith { left(_) => true, _ => false } + match 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 } + match eith { right(_) => true, _ => false } } #[test] diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 251bc2d18e1..fba8968103c 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -122,7 +122,7 @@ mod ct { let c = s[i]; 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) { + return match peek_num(s, i + 1u, lim) { none => some({num: n, next: i + 1u}), some(next) => { let m = next.num; @@ -150,7 +150,7 @@ mod ct { {param: option<int>, next: uint} { if i >= lim { return {param: none, next: i}; } let num = peek_num(s, i, lim); - return alt num { + return match num { none => {param: none, next: i}, some(t) => { let n = t.num; @@ -195,13 +195,13 @@ mod ct { } else if s[i] == '*' as u8 { let param = parse_parameter(s, i + 1u, lim); let j = param.next; - alt param.param { + match param.param { 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 { + match num { none => {count: count_implied, next: i}, some(num) => { count: count_is(num.num as int), @@ -220,7 +220,7 @@ mod ct { // If there were no digits specified, i.e. the precision // was ".", then the precision is 0 - alt count.count { + match count.count { count_implied => {count: count_is(0), next: count.next}, _ => count } @@ -294,7 +294,7 @@ mod rt { pure fn conv_uint(cv: conv, u: uint) -> ~str { let prec = get_int_precision(cv); let mut rs = - alt cv.ty { + match 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)), @@ -316,7 +316,7 @@ mod rt { pure fn conv_str(cv: conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed - let mut unpadded = alt cv.precision { + let mut unpadded = match 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) @@ -327,7 +327,7 @@ mod rt { return unchecked { pad(cv, unpadded, pad_nozero) }; } pure fn conv_float(cv: conv, f: float) -> ~str { - let (to_str, digits) = alt cv.precision { + let (to_str, digits) = match cv.precision { count_is(c) => (float::to_str_exact, c as uint), count_implied => (float::to_str, 6u) }; @@ -371,14 +371,14 @@ mod rt { }; } pure fn get_int_precision(cv: conv) -> uint { - return alt cv.precision { + return match cv.precision { 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 { + let uwidth : uint = match cv.width { count_implied => return s, count_is(width) => { // FIXME: width should probably be uint (see Issue #1996) @@ -393,14 +393,14 @@ mod rt { let padstr = str::from_chars(vec::from_elem(diff, padchar)); return s + padstr; } - let {might_zero_pad, signed} = alt mode { + let {might_zero_pad, signed} = match 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} }; pure fn have_precision(cv: conv) -> bool { - return alt cv.precision { count_implied => false, _ => true }; + return match cv.precision { count_implied => false, _ => true }; } let zero_padding = { if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) && diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 02133205be9..4269ef41f4d 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -256,14 +256,14 @@ fn from_str(num: ~str) -> option<float> { let mut c = 'z'; //Latest char. //The string must start with one of the following characters. - alt str::char_at(num, 0u) { + match str::char_at(num, 0u) { '-' | '+' | '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) { + match str::char_at(num, 0u) { '-' => { neg = true; pos = 1u; @@ -279,7 +279,7 @@ fn from_str(num: ~str) -> option<float> { let char_range = str::char_range_at(num, pos); c = char_range.ch; pos = char_range.next; - alt c { + match c { '0' to '9' => { total = total * 10f; total += ((c as int) - ('0' as int)) as float; @@ -295,7 +295,7 @@ fn from_str(num: ~str) -> option<float> { let char_range = str::char_range_at(num, pos); c = char_range.ch; pos = char_range.next; - alt c { + match c { '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => { decimal /= 10f; total += (((c as int) - ('0' as int)) as float)*decimal; @@ -312,7 +312,7 @@ fn from_str(num: ~str) -> option<float> { if(pos < len) { let char_range = str::char_range_at(num, pos); c = char_range.ch; - alt c { + match c { '+' => { pos = char_range.next; } @@ -325,7 +325,7 @@ fn from_str(num: ~str) -> option<float> { while(pos < len) { let char_range = str::char_range_at(num, pos); c = char_range.ch; - alt c { + match c { '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => { exponent *= 10u; exponent += ((c as uint) - ('0' as uint)); @@ -447,7 +447,7 @@ fn test_from_str() { assert from_str(~"inf") == some(infinity); assert from_str(~"-inf") == some(neg_infinity); // note: NaN != NaN, hence this slightly complex test - alt from_str(~"NaN") { + match from_str(~"NaN") { some(f) => assert is_NaN(f), none => fail } diff --git a/src/libcore/future.rs b/src/libcore/future.rs index 1f6b259c467..8b7b51eef58 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -77,7 +77,7 @@ fn from_port<A:send>(-port: future_pipe::client::waiting<A>) -> future<A> { let mut port_ = none; port_ <-> *port; let port = option::unwrap(port_); - alt recv(port) { + match recv(port) { future_pipe::completed(data) => move_it!{data} } } @@ -119,7 +119,7 @@ fn get<A:copy>(future: future<A>) -> A { fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B { //! Work with the value without copying it - let v = alt copy future.v { + let v = match copy future.v { either::left(v) => v, either::right(f) => { let v = @f(); diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 02ef14c5366..897f4030a47 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -144,7 +144,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { } let mut n = 0 as T; loop { - alt char::to_digit(buf[i] as char, radix) { + match char::to_digit(buf[i] as char, radix) { some(d) => n += (d as T) * power, none => return none } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index cf2c51625d8..2946700f832 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -196,7 +196,7 @@ impl reader_util for reader { // Reader implementations fn convert_whence(whence: seek_style) -> i32 { - return alt whence { + return match whence { seek_set => 0i32, seek_cur => 1i32, seek_end => 2i32 @@ -440,7 +440,7 @@ fn mk_file_writer(path: ~str, flags: ~[fileflag]) let mut fflags: c_int = wb(); for vec::each(flags) |f| { - alt f { + match f { append => fflags |= O_APPEND as c_int, create => fflags |= O_CREAT as c_int, truncate => fflags |= O_TRUNC as c_int, @@ -460,7 +460,7 @@ fn mk_file_writer(path: ~str, flags: ~[fileflag]) fn u64_to_le_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { assert size <= 8u; - alt size { + match size { 1u => f(&[n as u8]), 2u => f(&[n as u8, (n >> 8) as u8]), @@ -491,7 +491,7 @@ fn u64_to_le_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { fn u64_to_be_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { assert size <= 8u; - alt size { + match size { 1u => f(&[n as u8]), 2u => f(&[(n >> 8) as u8, n as u8]), @@ -717,7 +717,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> uint { let mut bpos = pos as int; let blen = len as int; - alt whence { + match whence { seek_set => bpos = offset, seek_cur => bpos += offset, seek_end => bpos = blen + offset @@ -767,7 +767,7 @@ mod fsync { let arg: arg<t>; new(-arg: arg<t>) { self.arg <- arg; } drop { - alt self.arg.opt_level { + match self.arg.opt_level { option::none => (), option::some(level) => { // fail hard if not succesful @@ -891,7 +891,7 @@ mod tests { #[test] fn file_reader_not_exist() { - alt io::file_reader(~"not a file") { + match io::file_reader(~"not a file") { result::err(e) => { assert e == ~"error opening not a file"; } @@ -901,7 +901,7 @@ mod tests { #[test] fn file_writer_bad_name() { - alt io::file_writer(~"?/?", ~[]) { + match io::file_writer(~"?/?", ~[]) { result::err(e) => { assert str::starts_with(e, ~"error opening ?/?"); } @@ -911,7 +911,7 @@ mod tests { #[test] fn buffered_file_writer_bad_name() { - alt io::buffered_file_writer(~"?/?") { + match io::buffered_file_writer(~"?/?") { result::err(e) => { assert e == ~"error opening ?/?"; } diff --git a/src/libcore/iter-trait/option.rs b/src/libcore/iter-trait/option.rs index a150afa36e1..2bcb7bba56e 100644 --- a/src/libcore/iter-trait/option.rs +++ b/src/libcore/iter-trait/option.rs @@ -1,14 +1,14 @@ type IMPL_T<A> = option<A>; pure fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) { - alt self { + match self { none => (), some(a) => { f(a); } } } fn SIZE_HINT<A>(self: IMPL_T<A>) -> option<uint> { - alt self { + match self { none => some(0u), some(_) => some(1u) } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 541c19aa3a5..2cb3369dbc7 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -134,8 +134,8 @@ fn repeat(times: uint, blk: fn() -> bool) { } fn min<A:copy,IA:base_iter<A>>(self: IA) -> A { - alt do foldl::<A,option<A>,IA>(self, none) |a, b| { - alt a { + match do foldl::<A,option<A>,IA>(self, none) |a, b| { + match a { some(a_) if a_ < b => { // FIXME (#2005): Not sure if this is successfully optimized to // a move @@ -150,8 +150,8 @@ fn min<A:copy,IA:base_iter<A>>(self: IA) -> A { } fn max<A:copy,IA:base_iter<A>>(self: IA) -> A { - alt do foldl::<A,option<A>,IA>(self, none) |a, b| { - alt a { + match do foldl::<A,option<A>,IA>(self, none) |a, b| { + match a { some(a_) if a_ > b => { // FIXME (#2005): Not sure if this is successfully optimized to // a move. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b2ae670ec05..d64b89c2f04 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -23,7 +23,7 @@ pure fn get<T: copy>(opt: option<T>) -> T { * Fails if the value equals `none` */ - alt opt { + match opt { some(x) => return x, none => fail ~"option::get none" } @@ -37,13 +37,13 @@ pure fn expect<T: copy>(opt: option<T>, reason: ~str) -> T { Fails if the value equals `none` "]; - alt opt { some(x) => x, none => fail reason } + match opt { some(x) => x, none => fail reason } } pure fn map<T, U>(opt: option<T>, f: fn(T) -> U) -> option<U> { //! Maps a `some` value from one type to another - alt opt { some(x) => some(f(x)), none => none } + match opt { some(x) => some(f(x)), none => none } } pure fn map_consume<T, U>(-opt: option<T>, f: fn(-T) -> U) -> option<U> { @@ -60,7 +60,7 @@ pure fn chain<T, U>(opt: option<T>, f: fn(T) -> option<U>) -> option<U> { * function that returns an option. */ - alt opt { some(x) => f(x), none => none } + match opt { some(x) => f(x), none => none } } #[inline(always)] @@ -76,7 +76,7 @@ pure fn while_some<T>(+x: option<T>, blk: fn(+T) -> option<T>) { pure fn is_none<T>(opt: option<T>) -> bool { //! Returns true if the option equals `none` - alt opt { none => true, some(_) => false } + match opt { none => true, some(_) => false } } pure fn is_some<T>(opt: option<T>) -> bool { @@ -88,19 +88,19 @@ pure fn is_some<T>(opt: option<T>) -> bool { pure fn get_default<T: copy>(opt: option<T>, def: T) -> T { //! Returns the contained value or a default - alt opt { some(x) => x, none => def } + match opt { some(x) => x, none => def } } pure fn map_default<T, U>(opt: option<T>, +def: U, f: fn(T) -> U) -> U { //! Applies a function to the contained value or returns a default - alt opt { none => def, some(t) => f(t) } + match opt { none => def, some(t) => f(t) } } pure fn iter<T>(opt: option<T>, f: fn(T)) { //! Performs an operation on the contained value or does nothing - alt opt { none => (), some(t) => f(t) } + match opt { none => (), some(t) => f(t) } } #[inline(always)] @@ -113,7 +113,7 @@ pure fn unwrap<T>(-opt: option<T>) -> T { */ unsafe { - let addr = alt opt { + let addr = match opt { some(x) => ptr::addr_of(x), none => fail ~"option::unwrap none" }; diff --git a/src/libcore/os.rs b/src/libcore/os.rs index fba4e7acac5..07bbff42b94 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -178,7 +178,7 @@ mod global_env { unsafe { do priv::weaken_task |weak_po| { loop { - alt comm::select2(msg_po, weak_po) { + match comm::select2(msg_po, weak_po) { either::left(msg_getenv(n, resp_ch)) => { comm::send(resp_ch, impl::getenv(n)) } @@ -282,7 +282,7 @@ fn fsync_fd(fd: c_int, _level: io::fsync::level) -> c_int { #[cfg(target_os = "linux")] fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::funcs::posix01::unistd::*; - alt level { + match level { io::fsync::fsync | io::fsync::fullfsync => return fsync(fd), io::fsync::fdatasync => return fdatasync(fd) @@ -294,7 +294,7 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::consts::os::extra::*; import libc::funcs::posix88::fcntl::*; import libc::funcs::posix01::unistd::*; - alt level { + match level { io::fsync::fsync => return fsync(fd), _ => { // According to man fnctl, the ok retval is only specified to be !=-1 @@ -440,7 +440,7 @@ fn self_exe_path() -> option<path> { * Otherwise, homedir returns option::none. */ fn homedir() -> option<path> { - return alt getenv(~"HOME") { + return match getenv(~"HOME") { some(p) => if !str::is_empty(p) { some(p) } else { diff --git a/src/libcore/path.rs b/src/libcore/path.rs index dc541b14a4b..1f239605131 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -61,7 +61,7 @@ fn path_is_absolute(p: ~str) -> bool { fn path_sep() -> ~str { return str::from_char(consts::path_sep); } fn split_dirname_basename (pp: path) -> {dirname: ~str, basename: ~str} { - alt str::rfind(pp, |ch| + match str::rfind(pp, |ch| ch == consts::path_sep || ch == consts::alt_path_sep ) { some(i) => { diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index ce72a6edca9..33ee3cc52fb 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -136,7 +136,7 @@ struct packet_header { unsafe fn unblock() { let old_task = swap_task(self.blocked_task, ptr::null()); if !old_task.is_null() { rustrt::rust_task_deref(old_task) } - alt swap_state_acq(self.state, empty) { + match swap_state_acq(self.state, empty) { empty | blocked => (), terminated => self.state = terminated, full => self.state = full @@ -345,7 +345,7 @@ fn send<T: send, Tbuffer: send>(-p: send_packet_buffered<T, Tbuffer>, assert p.payload == none; p.payload <- some(payload); let old_state = swap_state_rel(p.header.state, full); - alt old_state { + match old_state { empty => { // Yay, fastpath. @@ -403,7 +403,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) rustrt::task_clear_event_reject(this); let old_state = swap_state_acq(p.header.state, blocked); - alt old_state { + match old_state { empty => { debug!{"no data available on %?, going to sleep.", p_}; if count == 0 { @@ -451,7 +451,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) /// Returns true if messages are available. pure fn peek<T: send, Tb: send>(p: recv_packet_buffered<T, Tb>) -> bool { - alt unsafe {(*p.header()).state} { + match unsafe {(*p.header()).state} { empty => false, blocked => fail ~"peeking on blocked packet", full | terminated => true @@ -467,7 +467,7 @@ impl peek<T: send, Tb: send> for recv_packet_buffered<T, Tb> { #[doc(hidden)] fn sender_terminate<T: send>(p: *packet<T>) { let p = unsafe { &*p }; - alt swap_state_rel(p.header.state, terminated) { + match swap_state_rel(p.header.state, terminated) { empty => { assert p.header.blocked_task.is_null(); // The receiver will eventually clean up. @@ -500,7 +500,7 @@ fn sender_terminate<T: send>(p: *packet<T>) { fn receiver_terminate<T: send>(p: *packet<T>) { let p = unsafe { &*p }; assert p.header.blocked_task.is_null(); - alt swap_state_rel(p.header.state, terminated) { + match swap_state_rel(p.header.state, terminated) { empty => { // the sender will clean up //unsafe { forget(p) } @@ -534,7 +534,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint { for pkts.eachi |i, p| unsafe { let p = unsafe { &*p }; let old = p.mark_blocked(this); - alt old { + match old { full | terminated => { data_avail = true; ready_packet = i; @@ -551,7 +551,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint { let event = wait_event(this) as *packet_header; let pos = vec::position(pkts, |p| p == event); - alt pos { + match pos { some(i) => { ready_packet = i; data_avail = true; @@ -611,7 +611,7 @@ fn select2<A: send, Ab: send, B: send, Bb: send>( let i = wait_many([a.header(), b.header()]/_); unsafe { - alt i { + match i { 0 => left((try_recv(a), b)), 1 => right((a, try_recv(b))), _ => fail ~"select2 return an invalid packet" @@ -631,7 +631,7 @@ fn selecti<T: selectable>(endpoints: &[T]) -> uint { /// Returns 0 or 1 depending on which endpoint is ready to receive fn select2i<A: selectable, B: selectable>(a: A, b: B) -> either<(), ()> { - alt wait_many([a.header(), b.header()]/_) { + match wait_many([a.header(), b.header()]/_) { 0 => left(()), 1 => right(()), _ => fail ~"wait returned unexpected index" @@ -704,7 +704,7 @@ struct send_packet_buffered<T: send, Tbuffer: send> { } pure fn header() -> *packet_header { - alt self.p { + match self.p { some(packet) => unsafe { let packet = &*packet; let header = ptr::addr_of(packet.header); @@ -765,7 +765,7 @@ struct recv_packet_buffered<T: send, Tbuffer: send> : selectable { } pure fn header() -> *packet_header { - alt self.p { + match self.p { some(packet) => unsafe { let packet = &*packet; let header = ptr::addr_of(packet.header); @@ -924,7 +924,7 @@ impl port<T: send> of recv<T> for port<T> { fn try_recv() -> option<T> { let mut endp = none; endp <-> self.endp; - alt move pipes::try_recv(unwrap(endp)) { + match move pipes::try_recv(unwrap(endp)) { some(streamp::data(x, endp)) => { self.endp = some(move_it!{endp}); some(move_it!{x}) @@ -936,7 +936,7 @@ impl port<T: send> of recv<T> for port<T> { pure fn peek() -> bool unchecked { let mut endp = none; endp <-> self.endp; - let peek = alt endp { + let peek = match endp { some(endp) => pipes::peek(endp), none => fail ~"peeking empty stream" }; @@ -969,7 +969,7 @@ struct port_set<T: send> : recv<T> { ports <-> self.ports; while result == none && ports.len() > 0 { let i = wait_many(ports.map(|p| p.header())); - alt move ports[i].try_recv() { + match move ports[i].try_recv() { some(copy m) => { result = some(move m); } @@ -1007,7 +1007,7 @@ struct port_set<T: send> : recv<T> { impl<T: send> of selectable for port<T> { pure fn header() -> *packet_header unchecked { - alt self.endp { + match self.endp { some(endp) => endp.header(), none => fail ~"peeking empty stream" } @@ -1045,8 +1045,8 @@ impl<T: send, U: send, Left: selectable recv<T>, Right: selectable recv<U>> of select2<T, U> for (Left, Right) { fn select() -> either<T, U> { - alt self { - (lp, rp) => alt select2i(lp, rp) { + match self { + (lp, rp) => match select2i(lp, rp) { left(()) => left (lp.recv()), right(()) => right(rp.recv()) } @@ -1054,8 +1054,8 @@ impl<T: send, U: send, Left: selectable recv<T>, Right: selectable recv<U>> } fn try_select() -> either<option<T>, option<U>> { - alt self { - (lp, rp) => alt select2i(lp, rp) { + match self { + (lp, rp) => match select2i(lp, rp) { left(()) => left (lp.try_recv()), right(()) => right(rp.try_recv()) } @@ -1072,7 +1072,7 @@ mod test { c1.send(~"abc"); - alt (p1, p2).select() { + match (p1, p2).select() { right(_) => fail, _ => () } diff --git a/src/libcore/priv.rs b/src/libcore/priv.rs index 5d7123f1bba..ac286da79f6 100644 --- a/src/libcore/priv.rs +++ b/src/libcore/priv.rs @@ -49,7 +49,7 @@ unsafe fn chan_from_global_ptr<T: send>( // Wait to hear if we are the official instance of // this global task - alt comm::recv::<msg>(setup_po) { + match comm::recv::<msg>(setup_po) { proceed => f(po), abort => () } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index a74ac589b93..417841f3323 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -18,7 +18,7 @@ enum result<T, U> { * If the result is an error */ pure fn get<T: copy, U>(res: result<T, U>) -> T { - alt res { + match res { ok(t) => t, err(the_err) => unchecked { fail fmt!{"get called on error result: %?", the_err} @@ -34,7 +34,7 @@ pure fn get<T: copy, U>(res: result<T, U>) -> T { * If the result is not an error */ pure fn get_err<T, U: copy>(res: result<T, U>) -> U { - alt res { + match res { err(u) => u, ok(_) => fail ~"get_error called on ok result" } @@ -42,7 +42,7 @@ pure fn get_err<T, U: copy>(res: result<T, U>) -> U { /// Returns true if the result is `ok` pure fn is_ok<T, U>(res: result<T, U>) -> bool { - alt res { + match res { ok(_) => true, err(_) => false } @@ -60,7 +60,7 @@ pure fn is_err<T, U>(res: result<T, U>) -> bool { * result variants are converted to `either::left`. */ pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> either<T, U> { - alt res { + match res { ok(res) => either::right(res), err(fail_) => either::left(fail_) } @@ -82,7 +82,7 @@ pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> either<T, U> { */ fn chain<T, U: copy, V: copy>(res: result<T, V>, op: fn(T) -> result<U, V>) -> result<U, V> { - alt res { + match res { ok(t) => op(t), err(e) => err(e) } @@ -100,7 +100,7 @@ fn chain_err<T: copy, U: copy, V: copy>( res: result<T, V>, op: fn(V) -> result<T, U>) -> result<T, U> { - alt res { + match res { ok(t) => ok(t), err(v) => op(v) } @@ -121,7 +121,7 @@ fn chain_err<T: copy, U: copy, V: copy>( * } */ fn iter<T, E>(res: result<T, E>, f: fn(T)) { - alt res { + match res { ok(t) => f(t), err(_) => () } @@ -136,7 +136,7 @@ fn iter<T, E>(res: result<T, E>, f: fn(T)) { * handling an error. */ fn iter_err<T, E>(res: result<T, E>, f: fn(E)) { - alt res { + match res { ok(_) => (), err(e) => f(e) } @@ -158,7 +158,7 @@ fn iter_err<T, E>(res: result<T, E>, f: fn(E)) { */ fn map<T, E: copy, U: copy>(res: result<T, E>, op: fn(T) -> U) -> result<U, E> { - alt res { + match res { ok(t) => ok(op(t)), err(e) => err(e) } @@ -174,7 +174,7 @@ fn map<T, E: copy, U: copy>(res: result<T, E>, op: fn(T) -> U) */ fn map_err<T: copy, E, F: copy>(res: result<T, E>, op: fn(E) -> F) -> result<T, F> { - alt res { + match res { ok(t) => ok(t), err(e) => err(op(e)) } @@ -186,14 +186,14 @@ impl extensions<T, E> for result<T, E> { fn is_err() -> bool { is_err(self) } fn iter(f: fn(T)) { - alt self { + match self { ok(t) => f(t), err(_) => () } } fn iter_err(f: fn(E)) { - alt self { + match self { ok(_) => (), err(e) => f(e) } @@ -204,7 +204,7 @@ impl extensions<T:copy, E> for result<T, E> { fn get() -> T { get(self) } fn map_err<F:copy>(op: fn(E) -> F) -> result<T,F> { - alt self { + match self { ok(t) => ok(t), err(e) => err(op(e)) } @@ -215,7 +215,7 @@ impl extensions<T, E:copy> for result<T, E> { fn get_err() -> E { get_err(self) } fn map<U:copy>(op: fn(T) -> U) -> result<U,E> { - alt self { + match self { ok(t) => ok(op(t)), err(e) => err(e) } @@ -255,7 +255,7 @@ fn map_vec<T,U:copy,V:copy>( let mut vs: ~[V] = ~[]; vec::reserve(vs, vec::len(ts)); for vec::each(ts) |t| { - alt op(t) { + match op(t) { ok(v) => vec::push(vs, v), err(u) => return err(u) } @@ -266,9 +266,9 @@ fn map_vec<T,U:copy,V:copy>( fn map_opt<T,U:copy,V:copy>( o_t: option<T>, op: fn(T) -> result<V,U>) -> result<option<V>,U> { - alt o_t { + match o_t { none => ok(none), - some(t) => alt op(t) { + some(t) => match op(t) { ok(v) => ok(some(v)), err(e) => err(e) } @@ -293,7 +293,7 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T], vec::reserve(vs, n); let mut i = 0u; while i < n { - alt op(ss[i],ts[i]) { + match op(ss[i],ts[i]) { ok(v) => vec::push(vs, v), err(u) => return err(u) } @@ -314,7 +314,7 @@ fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T], let n = vec::len(ts); let mut i = 0u; while i < n { - alt op(ss[i],ts[i]) { + match op(ss[i],ts[i]) { ok(()) => (), err(u) => return err(u) } @@ -326,7 +326,7 @@ fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T], /// Unwraps a result, assuming it is an `ok(T)` fn unwrap<T, U>(-res: result<T, U>) -> T { unsafe { - let addr = alt res { + let addr = match res { ok(x) => ptr::addr_of(x), err(_) => fail ~"error result" }; diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 60527e786bd..92e89d8a7c8 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -96,7 +96,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>, cb: fn(*c_void) -> T) -> T { // On posixy systems we can pass a char** for envp, which is // a null-terminated array of "k=v\n" strings. - alt env { + match env { some(es) if !vec::is_empty(es) => { let mut tmps = ~[]; let mut ptrs = ~[]; @@ -123,7 +123,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>, // rather a concatenation of null-terminated k=v\0 sequences, with a final // \0 to terminate. unsafe { - alt env { + match env { some(es) if !vec::is_empty(es) => { let mut blk : ~[u8] = ~[]; for vec::each(es) |e| { @@ -143,7 +143,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>, fn with_dirp<T>(d: option<~str>, cb: fn(*libc::c_char) -> T) -> T { - alt d { + match d { some(dir) => str::as_c_str(dir, cb), none => cb(ptr::null()) } @@ -309,7 +309,7 @@ fn program_output(prog: ~str, args: ~[~str]) -> let mut count = 2; while count > 0 { let stream = comm::recv(p); - alt check stream { + match check stream { (1, s) => { outs = s; } diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index a242587a21c..04dc25a2c11 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -115,7 +115,7 @@ mod linear { k: &K) -> search_result { let _ = for self.bucket_sequence(hash) |i| { - alt buckets[i] { + match buckets[i] { some(bkt) => if bkt.hash == hash && self.eqfn(k, &bkt.key) { return found_entry(i); } @@ -155,7 +155,7 @@ mod linear { /// Assumes that there will be a bucket. /// True if there was no previous entry with that key fn insert_internal(hash: uint, +k: K, +v: V) -> bool { - alt self.bucket_for_key_with_hash(self.buckets, hash, + match self.bucket_for_key_with_hash(self.buckets, hash, unsafe{borrow(k)}) { table_full => {fail ~"Internal logic error";} found_hole(idx) => { @@ -207,7 +207,7 @@ mod linear { // I found this explanation elucidating: // http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf - let mut idx = alt self.bucket_for_key(self.buckets, k) { + let mut idx = match self.bucket_for_key(self.buckets, k) { table_full | found_hole(_) => { return false; } @@ -246,7 +246,7 @@ mod linear { } fn contains_key(k: &K) -> bool { - alt self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(self.buckets, k) { found_entry(_) => {true} table_full | found_hole(_) => {false} } @@ -255,9 +255,9 @@ mod linear { impl public_methods<K,V: copy> for &const linear_map<K,V> { fn find(k: &K) -> option<V> { - alt self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(self.buckets, k) { found_entry(idx) => { - alt check self.buckets[idx] { + match check self.buckets[idx] { some(bkt) => {some(copy bkt.value)} } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index cec8ec52ee4..4a13c1d9354 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -341,7 +341,7 @@ fn unshift_char(&s: ~str, ch: char) { s = from_char(ch) + s; } /// Returns a string with leading whitespace removed pure fn trim_left(s: &str) -> ~str { - alt find(s, |c| !char::is_whitespace(c)) { + match find(s, |c| !char::is_whitespace(c)) { none => ~"", some(first) => unsafe { unsafe::slice_bytes(s, first, len(s)) } } @@ -349,7 +349,7 @@ pure fn trim_left(s: &str) -> ~str { /// Returns a string with trailing whitespace removed pure fn trim_right(s: &str) -> ~str { - alt rfind(s, |c| !char::is_whitespace(c)) { + match rfind(s, |c| !char::is_whitespace(c)) { none => ~"", some(last) => { let {next, _} = char_range_at(s, last); @@ -2776,7 +2776,7 @@ mod tests { fn test_chars_iter() { let mut i = 0; do chars_iter(~"x\u03c0y") |ch| { - alt check i { + match check i { 0 => assert ch == 'x', 1 => assert ch == '\u03c0', 2 => assert ch == 'y' @@ -2792,7 +2792,7 @@ mod tests { let mut i = 0; do bytes_iter(~"xyz") |bb| { - alt check i { + match check i { 0 => assert bb == 'x' as u8, 1 => assert bb == 'y' as u8, 2 => assert bb == 'z' as u8 @@ -2810,7 +2810,7 @@ mod tests { let mut ii = 0; do split_char_iter(data, ' ') |xx| { - alt ii { + match ii { 0 => assert ~"\nMary" == xx, 1 => assert ~"had" == xx, 2 => assert ~"a" == xx, @@ -2828,7 +2828,7 @@ mod tests { let mut ii = 0; do splitn_char_iter(data, ' ', 2u) |xx| { - alt ii { + match ii { 0 => assert ~"\nMary" == xx, 1 => assert ~"had" == xx, 2 => assert ~"a little lamb\nLittle lamb\n" == xx, @@ -2845,7 +2845,7 @@ mod tests { let mut ii = 0; do words_iter(data) |ww| { - alt ii { + match ii { 0 => assert ~"Mary" == ww, 1 => assert ~"had" == ww, 2 => assert ~"a" == ww, @@ -2865,7 +2865,7 @@ mod tests { let mut ii = 0; do lines_iter(lf) |x| { - alt ii { + match ii { 0 => assert ~"" == x, 1 => assert ~"Mary had a little lamb" == x, 2 => assert ~"Little lamb" == x, diff --git a/src/libcore/task.rs b/src/libcore/task.rs index cf354f0f809..422d62862ea 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -279,7 +279,7 @@ impl task_builder for task_builder { let ch = comm::chan(po); blk(do future::from_fn { - alt comm::recv(po) { + match comm::recv(po) { exit(_, result) => result } }); @@ -502,7 +502,7 @@ fn try<T:send>(+f: fn~() -> T) -> result<T,()> { do task().unlinked().future_result(|-r| { result = some(r); }).spawn { comm::send(ch, f()); } - alt future::get(option::unwrap(result)) { + match future::get(option::unwrap(result)) { success => result::ok(comm::recv(po)), failure => result::err(()) } @@ -991,7 +991,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) /*######################################################################* * Step 1. Get spawner's taskgroup info. *######################################################################*/ - let spawner_group = alt unsafe { local_get(spawner, taskgroup_key()) } { + let spawner_group = match unsafe { local_get(spawner, taskgroup_key()) } { none => { // Main task, doing first spawn ever. Lazily initialise here. let mut members = new_taskset(); @@ -1028,7 +1028,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) // assertion, but initialising it requires locking a mutex. Hence // it should be enabled only in debug builds. let new_generation = - alt *old_ancestors { + match *old_ancestors { some(arc) => access_ancestors(arc, |a| a.generation+1), none => 0 // the actual value doesn't really matter. }; @@ -1047,7 +1047,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) fn share_ancestors(ancestors: &mut ancestor_list) -> ancestor_list { // Appease the borrow-checker. Really this wants to be written as: - // alt ancestors + // match ancestors // some(ancestor_arc) { ancestor_list(some(ancestor_arc.clone())) } // none { ancestor_list(none) } let tmp = util::replace(&mut **ancestors, none); @@ -1073,7 +1073,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) { // Agh. Get move-mode items into the closure. FIXME (#2829) let (child_tg, ancestors, f) = option::swap_unwrap(child_data); // Create child task. - let new_task = alt opts.sched { + let new_task = match opts.sched { none => rustrt::new_task(), some(sched_opts) => new_task_in_new_sched(sched_opts) }; @@ -1162,7 +1162,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) { fail ~"foreign_stack_size scheduler option unimplemented"; } - let num_threads = alt opts.mode { + let num_threads = match opts.mode { single_threaded => 1u, thread_per_core => { fail ~"thread_per_core scheduling mode unimplemented" @@ -1273,7 +1273,7 @@ unsafe fn local_data_lookup<T: owned>( let key_value = key_to_key_value(key); let map_pos = (*map).position(|entry| - alt entry { + match entry { some((k,_,_)) => k == key_value, none => false } @@ -1336,7 +1336,7 @@ unsafe fn local_set<T: owned>( // Construct new entry to store in the map. let new_entry = some((keyval, data_ptr, data_box)); // Find a place to put it. - alt local_data_lookup(map, key) { + match local_data_lookup(map, key) { some((index, _old_data_ptr)) => { // Key already had a value set, _old_data_ptr, whose reference // will get dropped when the local_data box is overwritten. @@ -1344,7 +1344,7 @@ unsafe fn local_set<T: owned>( } none => { // Find an empty slot. If not, grow the vector. - alt (*map).position(|x| x == none) { + match (*map).position(|x| x == none) { some(empty_index) => (*map).set_elt(empty_index, new_entry), none => (*map).push(new_entry) } @@ -1694,7 +1694,7 @@ fn test_spawn_listiner_bidi() { #[test] fn test_try_success() { - alt do try { + match do try { ~"Success!" } { result::ok(~"Success!") => (), @@ -1705,7 +1705,7 @@ fn test_try_success() { #[test] #[ignore(cfg(windows))] fn test_try_fail() { - alt do try { + match do try { fail } { result::err(()) => (), @@ -2052,13 +2052,13 @@ fn test_tls_pop() unsafe { fn test_tls_modify() unsafe { fn my_key(+_x: @~str) { } local_data_modify(my_key, |data| { - alt data { + match data { some(@val) => fail ~"unwelcome value: " + val, none => some(@~"first data") } }); local_data_modify(my_key, |data| { - alt data { + match data { some(@~"first data") => some(@~"next data"), some(@val) => fail ~"wrong value: " + val, none => fail ~"missing value" diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index d3b0e8cea24..a0feaf3ed9d 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -127,7 +127,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { let mut power = 1u as T; let mut n = 0u as T; loop { - alt char::to_digit(buf[i] as char, radix) { + match char::to_digit(buf[i] as char, radix) { some(d) => n += d as T * power, none => return none } @@ -146,7 +146,7 @@ fn from_str_radix(buf: ~str, radix: u64) -> option<u64> { let mut i = str::len(buf) - 1u; let mut power = 1u64, n = 0u64; loop { - alt char::to_digit(buf[i] as char, radix as uint) { + match char::to_digit(buf[i] as char, radix as uint) { some(d) => n += d as u64 * power, none => return none } diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 343bf7954e6..c7f0c9bfa17 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -1,6 +1,6 @@ mod general_category { pure fn Cc(c: char) -> bool { - return alt c { + return match c { '\x00' to '\x1f' | '\x7f' to '\x9f' => true, _ => false @@ -8,7 +8,7 @@ mod general_category { } pure fn Cf(c: char) -> bool { - return alt c { + return match c { '\xad' | '\u0600' to '\u0603' | '\u06dd' @@ -27,21 +27,21 @@ mod general_category { } pure fn Co(c: char) -> bool { - return alt c { + return match c { '\ue000' to '\uf8ff' => true, _ => false }; } pure fn Cs(c: char) -> bool { - return alt c { + return match c { '\ud800' to '\udfff' => true, _ => false }; } pure fn Ll(c: char) -> bool { - return alt c { + return match c { '\x61' to '\x7a' | '\xaa' | '\xb5' @@ -646,7 +646,7 @@ mod general_category { } pure fn Lm(c: char) -> bool { - return alt c { + return match c { '\u02b0' to '\u02c1' | '\u02c6' to '\u02d1' | '\u02e0' to '\u02e4' @@ -702,7 +702,7 @@ mod general_category { } pure fn Lo(c: char) -> bool { - return alt c { + return match c { '\u01bb' | '\u01c0' to '\u01c3' | '\u0294' @@ -888,7 +888,7 @@ mod general_category { } pure fn Lt(c: char) -> bool { - return alt c { + return match c { '\u01c5' | '\u01c8' | '\u01cb' @@ -905,7 +905,7 @@ mod general_category { } pure fn Lu(c: char) -> bool { - return alt c { + return match c { '\x41' to '\x5a' | '\xc0' to '\xd6' | '\xd8' to '\xde' @@ -1497,7 +1497,7 @@ mod general_category { } pure fn Mc(c: char) -> bool { - return alt c { + return match c { '\u0903' | '\u093b' | '\u093e' to '\u0940' @@ -1608,7 +1608,7 @@ mod general_category { } pure fn Me(c: char) -> bool { - return alt c { + return match c { '\u0488' to '\u0489' | '\u20dd' to '\u20e0' | '\u20e2' to '\u20e4' @@ -1619,7 +1619,7 @@ mod general_category { } pure fn Mn(c: char) -> bool { - return alt c { + return match c { '\u0300' to '\u036f' | '\u0483' to '\u0487' | '\u0591' to '\u05bd' @@ -1812,7 +1812,7 @@ mod general_category { } pure fn Nd(c: char) -> bool { - return alt c { + return match c { '\x30' to '\x39' | '\u0660' to '\u0669' | '\u06f0' to '\u06f9' @@ -1856,7 +1856,7 @@ mod general_category { } pure fn Nl(c: char) -> bool { - return alt c { + return match c { '\u16ee' to '\u16f0' | '\u2160' to '\u2182' | '\u2185' to '\u2188' @@ -1875,7 +1875,7 @@ mod general_category { } pure fn No(c: char) -> bool { - return alt c { + return match c { '\xb2' to '\xb3' | '\xb9' | '\xbc' to '\xbe' @@ -1923,7 +1923,7 @@ mod general_category { } pure fn Pc(c: char) -> bool { - return alt c { + return match c { '\x5f' | '\u203f' to '\u2040' | '\u2054' @@ -1936,7 +1936,7 @@ mod general_category { } pure fn Pd(c: char) -> bool { - return alt c { + return match c { '\x2d' | '\u058a' | '\u05be' @@ -1958,7 +1958,7 @@ mod general_category { } pure fn Pe(c: char) -> bool { - return alt c { + return match c { '\x29' | '\x5d' | '\x7d' @@ -2035,7 +2035,7 @@ mod general_category { } pure fn Pf(c: char) -> bool { - return alt c { + return match c { '\xbb' | '\u2019' | '\u201d' @@ -2052,7 +2052,7 @@ mod general_category { } pure fn Pi(c: char) -> bool { - return alt c { + return match c { '\xab' | '\u2018' | '\u201b' to '\u201c' @@ -2070,7 +2070,7 @@ mod general_category { } pure fn Po(c: char) -> bool { - return alt c { + return match c { '\x21' to '\x23' | '\x25' to '\x27' | '\x2a' @@ -2203,7 +2203,7 @@ mod general_category { } pure fn Ps(c: char) -> bool { - return alt c { + return match c { '\x28' | '\x5b' | '\x7b' @@ -2282,7 +2282,7 @@ mod general_category { } pure fn Sc(c: char) -> bool { - return alt c { + return match c { '\x24' | '\xa2' to '\xa5' | '\u060b' @@ -2305,7 +2305,7 @@ mod general_category { } pure fn Sk(c: char) -> bool { - return alt c { + return match c { '\x5e' | '\x60' | '\xa8' @@ -2339,7 +2339,7 @@ mod general_category { } pure fn Sm(c: char) -> bool { - return alt c { + return match c { '\x2b' | '\x3c' to '\x3e' | '\x7c' @@ -2410,7 +2410,7 @@ mod general_category { } pure fn So(c: char) -> bool { - return alt c { + return match c { '\xa6' to '\xa7' | '\xa9' | '\xae' @@ -2529,21 +2529,21 @@ mod general_category { } pure fn Zl(c: char) -> bool { - return alt c { + return match c { '\u2028' => true, _ => false }; } pure fn Zp(c: char) -> bool { - return alt c { + return match c { '\u2029' => true, _ => false }; } pure fn Zs(c: char) -> bool { - return alt c { + return match c { '\x20' | '\xa0' | '\u1680' @@ -2561,7 +2561,7 @@ mod general_category { mod derived_property { /// Check if a character has the alphabetic unicode property pure fn Alphabetic(c: char) -> bool { - return alt c { + return match c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' @@ -3299,7 +3299,7 @@ mod derived_property { } pure fn XID_Continue(c: char) -> bool { - return alt c { + return match c { '\x30' to '\x39' | '\x41' to '\x5a' | '\x5f' @@ -4170,7 +4170,7 @@ mod derived_property { } pure fn XID_Start(c: char) -> bool { - return alt c { + return match c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 93bdd53d90d..fcfbb3ea135 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -356,7 +356,7 @@ fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let mut start = 0u; let mut result = ~[]; while start < ln { - alt position_between(v, start, ln, f) { + match position_between(v, start, ln, f) { none => break, some(i) => { push(result, slice(v, start, i)); @@ -380,7 +380,7 @@ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let mut count = n; let mut result = ~[]; while start < ln && count > 0u { - alt position_between(v, start, ln, f) { + match position_between(v, start, ln, f) { none => break, some(i) => { push(result, slice(v, start, i)); @@ -405,7 +405,7 @@ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let mut end = ln; let mut result = ~[]; while end > 0u { - alt rposition_between(v, 0u, end, f) { + match rposition_between(v, 0u, end, f) { none => break, some(i) => { push(result, slice(v, i + 1u, end)); @@ -429,7 +429,7 @@ fn rsplitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let mut count = n; let mut result = ~[]; while end > 0u && count > 0u { - alt rposition_between(v, 0u, end, f) { + match rposition_between(v, 0u, end, f) { none => break, some(i) => { push(result, slice(v, i + 1u, end)); @@ -713,7 +713,7 @@ pure fn filter_map<T, U: copy>(v: &[T], f: fn(T) -> option<U>) -> ~[U] { let mut result = ~[]; for each(v) |elem| { - alt f(elem) { + match f(elem) { none => {/* no-op */ } some(result_elem) => unsafe { push(result, result_elem); } } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index e76d3093c17..a51ac7658a6 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -30,7 +30,7 @@ impl of to_base64 for ~[u8] { i += 3u; } - alt check len % 3u { + match check len % 3u { 0u => (), 1u => { let n = (self[i] as uint) << 16u; @@ -96,7 +96,7 @@ impl of from_base64 for ~[u8] { } else if ch == '/' { n |= 0x3Fu; } else if ch == '=' { - alt len - i { + match len - i { 1u => { vec::push(r, ((n >> 16u) & 0xFFu) as u8); vec::push(r, ((n >> 8u ) & 0xFFu) as u8); diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index de51e2b7f51..4b1fa4bfac9 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -179,9 +179,9 @@ class bitv { if self.nbits != other.nbits { self.die(); } - alt self.rep { - small(s) => alt other.rep { - small(s1) => alt op { + match self.rep { + small(s) => match other.rep { + small(s1) => match op { union => s.union(s1), intersect => s.intersect(s1), assign => s.become(s1), @@ -189,9 +189,9 @@ class bitv { } big(s1) => self.die() } - big(s) => alt other.rep { + big(s) => match other.rep { small(_) => self.die(), - big(s1) => alt op { + big(s1) => match op { union => s.union(s1), intersect => s.intersect(s1), assign => s.become(s1), @@ -232,7 +232,7 @@ class bitv { /// Makes a copy of a bitvector #[inline(always)] fn clone() -> ~bitv { - ~alt self.rep { + ~match self.rep { small(b) => { bitv{nbits: self.nbits, rep: small(~small_bitv{bits: b.bits})} } @@ -249,7 +249,7 @@ class bitv { #[inline(always)] pure fn get(i: uint) -> bool { assert (i < self.nbits); - alt self.rep { + match self.rep { big(b) => b.get(i), small(s) => s.get(i) } @@ -263,7 +263,7 @@ class bitv { #[inline(always)] fn set(i: uint, x: bool) { assert (i < self.nbits); - alt self.rep { + match self.rep { big(b) => b.set(i, x), small(s) => s.set(i, x) } @@ -278,12 +278,12 @@ class bitv { #[inline(always)] fn equal(v1: bitv) -> bool { if self.nbits != v1.nbits { return false; } - alt self.rep { - small(b) => alt v1.rep { + match self.rep { + small(b) => match v1.rep { small(b1) => b.equals(b1), _ => false } - big(s) => alt v1.rep { + big(s) => match v1.rep { big(s1) => s.equals(s1), small(_) => return false } @@ -293,7 +293,7 @@ class bitv { /// Set all bits to 0 #[inline(always)] fn clear() { - alt self.rep { + match self.rep { small(b) => b.clear(), big(s) => for s.each_storage() |w| { w = 0u } } @@ -302,7 +302,7 @@ class bitv { /// Set all bits to 1 #[inline(always)] fn set_all() { - alt self.rep { + match self.rep { small(b) => b.set_all(), big(s) => for s.each_storage() |w| { w = !0u } } } @@ -310,7 +310,7 @@ class bitv { /// Invert all bits #[inline(always)] fn invert() { - alt self.rep { + match self.rep { small(b) => b.invert(), big(s) => for s.each_storage() |w| { w = !w } } } @@ -329,7 +329,7 @@ class bitv { /// Returns true if all bits are 1 #[inline(always)] fn is_true() -> bool { - alt self.rep { + match self.rep { small(b) => b.is_true(), _ => { for self.each() |i| { if !i { return false; } } @@ -350,7 +350,7 @@ class bitv { /// Returns true if all bits are 0 fn is_false() -> bool { - alt self.rep { + match self.rep { small(b) => b.is_false(), big(_) => { for self.each() |i| { if i { return false; } } diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index e00ee13949b..8b5a5e55113 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -46,7 +46,7 @@ class dtor_res { let dtor: option<fn@()>; new(dtor: option<fn@()>) { self.dtor = dtor; } drop { - alt self.dtor { + match self.dtor { option::none => (), option::some(f) => f() } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 5e98f3c7054..8293e4f215c 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -41,7 +41,7 @@ fn create<T: copy>() -> t<T> { return rv; } fn get<T: copy>(elts: dvec<cell<T>>, i: uint) -> T { - alt elts.get_elt(i) { some(t) => t, _ => fail } + match elts.get_elt(i) { some(t) => t, _ => fail } } type repr<T> = {mut nelts: uint, @@ -238,32 +238,32 @@ mod tests { fn inteq(&&a: int, &&b: int) -> bool { return a == b; } fn intboxeq(&&a: @int, &&b: @int) -> bool { return a == b; } fn taggyeq(a: taggy, b: taggy) -> bool { - alt a { - one(a1) => alt b { + match a { + one(a1) => match b { one(b1) => return a1 == b1, _ => return false } - two(a1, a2) => alt b { + two(a1, a2) => match b { two(b1, b2) => return a1 == b1 && a2 == b2, _ => return false } - three(a1, a2, a3) => alt b { + three(a1, a2, a3) => match b { three(b1, b2, b3) => return a1 == b1 && a2 == b2 && a3 == b3, _ => return false } } } fn taggypareq<T>(a: taggypar<T>, b: taggypar<T>) -> bool { - alt a { - onepar::<T>(a1) => alt b { + match a { + onepar::<T>(a1) => match b { onepar::<T>(b1) => return a1 == b1, _ => return false } - twopar::<T>(a1, a2) => alt b { + twopar::<T>(a1, a2) => match b { twopar::<T>(b1, b2) => return a1 == b1 && a2 == b2, _ => return false } - threepar::<T>(a1, a2, a3) => alt b { + threepar::<T>(a1, a2, a3) => match b { threepar::<T>(b1, b2, b3) => { return a1 == b1 && a2 == b2 && a3 == b3 } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 78ec45659cc..f5396395b93 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -113,7 +113,7 @@ fn maybe_get_doc(d: doc, tg: uint) -> option<doc> { } fn get_doc(d: doc, tg: uint) -> doc { - alt maybe_get_doc(d, tg) { + match maybe_get_doc(d, tg) { some(d) => return d, none => { error!{"failed to find block with tag %u", tg}; @@ -189,7 +189,7 @@ enum writer { } fn write_sized_vuint(w: io::writer, n: uint, size: uint) { - alt size { + match size { 1u => w.write(&[0x80u8 | (n as u8)]), 2u => w.write(&[0x40u8 | ((n >> 8_u) as u8), n as u8]), 3u => w.write(&[0x20u8 | ((n >> 16_u) as u8), (n >> 8_u) as u8, @@ -593,7 +593,7 @@ fn test_option_int() { fn serialize_0<S: serialization::serializer>(s: S, v: option<int>) { do s.emit_enum(~"core::option::t") { - alt v { + match v { none => s.emit_enum_variant( ~"core::option::none", 0u, 0u, || { } ), some(v0) => { @@ -612,7 +612,7 @@ fn test_option_int() { fn deserialize_0<S: serialization::deserializer>(s: S) -> option<int> { do s.read_enum(~"core::option::t") { do s.read_enum_variant |i| { - alt check i { + match check i { 0u => none, 1u => { let v0 = do s.read_enum_variant_arg(0u) { diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index e849d77ded6..786af20940e 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -30,7 +30,7 @@ fn init<K, V>() -> treemap<K, V> { @empty } /// Insert a value into the map fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) -> treemap<K, V> { - @alt m { + @match m { @empty => node(@k, @v, @empty, @empty), @node(@kk, vv, left, right) => { if k < kk { @@ -44,7 +44,7 @@ fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) -> treemap<K, V> { /// Find a value based on the key fn find<K, V: copy>(m: treemap<K, V>, k: K) -> option<V> { - alt *m { + match *m { empty => none, node(@kk, @v, left, right) => { if k == kk { @@ -56,7 +56,7 @@ fn find<K, V: copy>(m: treemap<K, V>, k: K) -> option<V> { /// Visit all pairs in the map in order. fn traverse<K, V: copy>(m: treemap<K, V>, f: fn(K, V)) { - alt *m { + match *m { empty => (), /* Previously, this had what looked like redundant diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index c05c685daa8..04a04691077 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -43,7 +43,7 @@ * optflag("h"), * optflag("help") * ]; - * let matches = alt getopts(vec::tail(args), opts) { + * let matches = match getopts(vec::tail(args), opts) { * result::ok(m) { m } * result::err(f) { fail fail_str(f) } * }; @@ -140,7 +140,7 @@ fn is_arg(arg: ~str) -> bool { } fn name_str(nm: name) -> ~str { - return alt nm { + return match nm { short(ch) => str::from_char(ch), long(s) => s }; @@ -164,7 +164,7 @@ enum fail_ { /// Convert a `fail_` enum into an error string fn fail_str(f: fail_) -> ~str { - return alt f { + return match f { argument_missing(nm) => ~"Argument to option '" + nm + ~"' missing.", unrecognized_option(nm) => ~"Unrecognized option: '" + nm + ~"'.", option_missing(nm) => ~"Required option '" + nm + ~"' missing.", @@ -233,12 +233,14 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { correctly */ - alt find_opt(opts, opt) { + match find_opt(opts, opt) { some(id) => last_valid_opt_id = option::some(id), none => { let arg_follows = option::is_some(last_valid_opt_id) && - alt opts[option::get(last_valid_opt_id)].hasarg { + match opts[option::get(last_valid_opt_id)] + .hasarg { + yes | maybe => true, no => false }; @@ -257,11 +259,11 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { let mut name_pos = 0u; for vec::each(names) |nm| { name_pos += 1u; - let optid = alt find_opt(opts, nm) { + let optid = match find_opt(opts, nm) { some(id) => id, none => return err(unrecognized_option(name_str(nm))) }; - alt opts[optid].hasarg { + match opts[optid].hasarg { no => { if !option::is_none::<~str>(i_arg) { return err(unexpected_argument(name_str(nm))); @@ -309,7 +311,7 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { } fn opt_vals(m: matches, nm: ~str) -> ~[optval] { - return alt find_opt(m.opts, mkname(nm)) { + return match find_opt(m.opts, mkname(nm)) { some(id) => m.vals[id], none => { error!{"No option '%s' defined", nm}; @@ -328,7 +330,7 @@ fn opt_present(m: matches, nm: ~str) -> bool { /// Returns true if any of several options were matched fn opts_present(m: matches, names: ~[~str]) -> bool { for vec::each(names) |nm| { - alt find_opt(m.opts, mkname(nm)) { + match find_opt(m.opts, mkname(nm)) { some(_) => return true, _ => () } @@ -344,7 +346,7 @@ fn opts_present(m: matches, names: ~[~str]) -> bool { * argument */ fn opt_str(m: matches, nm: ~str) -> ~str { - return alt opt_val(m, nm) { val(s) => s, _ => fail }; + return match opt_val(m, nm) { val(s) => s, _ => fail }; } /** @@ -355,7 +357,7 @@ fn opt_str(m: matches, nm: ~str) -> ~str { */ fn opts_str(m: matches, names: ~[~str]) -> ~str { for vec::each(names) |nm| { - alt opt_val(m, nm) { + match opt_val(m, nm) { val(s) => return s, _ => () } @@ -373,7 +375,7 @@ fn opts_str(m: matches, names: ~[~str]) -> ~str { fn opt_strs(m: matches, nm: ~str) -> ~[~str] { let mut acc: ~[~str] = ~[]; for vec::each(opt_vals(m, nm)) |v| { - alt v { val(s) => vec::push(acc, s), _ => () } + match v { val(s) => vec::push(acc, s), _ => () } } return acc; } @@ -382,7 +384,7 @@ fn opt_strs(m: matches, nm: ~str) -> ~[~str] { fn opt_maybe_str(m: matches, nm: ~str) -> option<~str> { let vals = opt_vals(m, nm); if vec::len::<optval>(vals) == 0u { return none::<~str>; } - return alt vals[0] { val(s) => some::<~str>(s), _ => none::<~str> }; + return match vals[0] { val(s) => some::<~str>(s), _ => none::<~str> }; } @@ -396,7 +398,7 @@ fn opt_maybe_str(m: matches, nm: ~str) -> option<~str> { fn opt_default(m: matches, nm: ~str, def: ~str) -> option<~str> { let vals = opt_vals(m, nm); if vec::len::<optval>(vals) == 0u { return none::<~str>; } - return alt vals[0] { val(s) => some::<~str>(s), _ => some::<~str>(def) } + return match vals[0] { val(s) => some::<~str>(s), _ => some::<~str>(def) } } #[cfg(test)] @@ -413,7 +415,7 @@ mod tests { } fn check_fail_type(f: fail_, ft: fail_type) { - alt f { + match f { argument_missing(_) => assert ft == argument_missing_, unrecognized_option(_) => assert ft == unrecognized_option_, option_missing(_) => assert ft == option_missing_, @@ -429,7 +431,7 @@ mod tests { let args = ~[~"--test=20"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); - alt check rs { + match check rs { ok(m) => { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); @@ -442,7 +444,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_missing_), _ => fail } @@ -453,7 +455,7 @@ mod tests { let args = ~[~"--test"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, argument_missing_), _ => fail } @@ -464,7 +466,7 @@ mod tests { let args = ~[~"--test=20", ~"--test=30"]; let opts = ~[reqopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_duplicated_), _ => fail } @@ -475,7 +477,7 @@ mod tests { let args = ~[~"-t", ~"20"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); @@ -489,7 +491,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_missing_), _ => fail } @@ -500,7 +502,7 @@ mod tests { let args = ~[~"-t"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, argument_missing_), _ => fail } @@ -511,7 +513,7 @@ mod tests { let args = ~[~"-t", ~"20", ~"-t", ~"30"]; let opts = ~[reqopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_duplicated_), _ => fail } @@ -524,7 +526,7 @@ mod tests { let args = ~[~"--test=20"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); @@ -538,7 +540,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (!opt_present(m, ~"test")), _ => fail } @@ -549,7 +551,7 @@ mod tests { let args = ~[~"--test"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, argument_missing_), _ => fail } @@ -560,7 +562,7 @@ mod tests { let args = ~[~"--test=20", ~"--test=30"]; let opts = ~[optopt(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_duplicated_), _ => fail } @@ -571,7 +573,7 @@ mod tests { let args = ~[~"-t", ~"20"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); @@ -585,7 +587,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (!opt_present(m, ~"t")), _ => fail } @@ -596,7 +598,7 @@ mod tests { let args = ~[~"-t"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, argument_missing_), _ => fail } @@ -607,7 +609,7 @@ mod tests { let args = ~[~"-t", ~"20", ~"-t", ~"30"]; let opts = ~[optopt(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_duplicated_), _ => fail } @@ -620,7 +622,7 @@ mod tests { let args = ~[~"--test"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (opt_present(m, ~"test")), _ => fail } @@ -631,7 +633,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (!opt_present(m, ~"test")), _ => fail } @@ -642,7 +644,7 @@ mod tests { let args = ~[~"--test=20"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => { log(error, fail_str(f)); check_fail_type(f, unexpected_argument_); @@ -656,7 +658,7 @@ mod tests { let args = ~[~"--test", ~"--test"]; let opts = ~[optflag(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_duplicated_), _ => fail } @@ -667,7 +669,7 @@ mod tests { let args = ~[~"-t"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (opt_present(m, ~"t")), _ => fail } @@ -678,7 +680,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (!opt_present(m, ~"t")), _ => fail } @@ -689,7 +691,7 @@ mod tests { let args = ~[~"-t", ~"20"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { // The next variable after the flag is just a free argument @@ -704,7 +706,7 @@ mod tests { let args = ~[~"-t", ~"-t"]; let opts = ~[optflag(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, option_duplicated_), _ => fail } @@ -717,7 +719,7 @@ mod tests { let args = ~[~"--test=20"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); @@ -731,7 +733,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (!opt_present(m, ~"test")), _ => fail } @@ -742,7 +744,7 @@ mod tests { let args = ~[~"--test"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, argument_missing_), _ => fail } @@ -753,7 +755,7 @@ mod tests { let args = ~[~"--test=20", ~"--test=30"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); @@ -769,7 +771,7 @@ mod tests { let args = ~[~"-t", ~"20"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); @@ -783,7 +785,7 @@ mod tests { let args = ~[~"blah"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => assert (!opt_present(m, ~"t")), _ => fail } @@ -794,7 +796,7 @@ mod tests { let args = ~[~"-t"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, argument_missing_), _ => fail } @@ -805,7 +807,7 @@ mod tests { let args = ~[~"-t", ~"20", ~"-t", ~"30"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); @@ -821,7 +823,7 @@ mod tests { let args = ~[~"--untest"]; let opts = ~[optmulti(~"t")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, unrecognized_option_), _ => fail } @@ -832,7 +834,7 @@ mod tests { let args = ~[~"-t"]; let opts = ~[optmulti(~"test")]; let rs = getopts(args, opts); - alt rs { + match rs { err(f) => check_fail_type(f, unrecognized_option_), _ => fail } @@ -849,7 +851,7 @@ mod tests { optflag(~"f"), optmulti(~"m"), optmulti(~"n"), optopt(~"notpresent")]; let rs = getopts(args, opts); - alt rs { + match rs { ok(m) => { assert (m.free[0] == ~"prog"); assert (m.free[1] == ~"free1"); @@ -872,7 +874,7 @@ mod tests { fn test_multi() { let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"]; let opts = ~[optopt(~"e"), optopt(~"encrypt")]; - let matches = alt getopts(args, opts) { + let matches = match getopts(args, opts) { result::ok(m) => m, result::err(f) => fail }; @@ -893,7 +895,7 @@ mod tests { fn test_nospace() { let args = ~[~"-Lfoo"]; let opts = ~[optmulti(~"L")]; - let matches = alt getopts(args, opts) { + let matches = match getopts(args, opts) { result::ok(m) => m, result::err(f) => fail }; diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 82a0f7d8084..f3ca79be02b 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -45,7 +45,7 @@ type error = { /// Serializes a json value into a io::writer fn to_writer(wr: io::writer, j: json) { - alt j { + match j { num(n) => wr.write_str(float::to_str(n, 6u)), string(s) => wr.write_str(escape_str(*s)), boolean(b) => wr.write_str(if b { ~"true" } else { ~"false" }), @@ -87,7 +87,7 @@ fn to_writer(wr: io::writer, j: json) { fn escape_str(s: ~str) -> ~str { let mut escaped = ~"\""; do str::chars_iter(s) |c| { - alt c { + match c { '"' => escaped += ~"\\\"", '\\' => escaped += ~"\\\\", '\x08' => escaped += ~"\\b", @@ -144,7 +144,7 @@ impl parser for parser { } fn parse() -> result<json, error> { - alt self.parse_value() { + match self.parse_value() { ok(value) => { // Skip trailing whitespaces. self.parse_whitespace(); @@ -164,12 +164,12 @@ impl parser for parser { if self.eof() { return self.error(~"EOF while parsing value"); } - alt self.ch { + match self.ch { 'n' => self.parse_ident(~"ull", null), 't' => self.parse_ident(~"rue", boolean(true)), 'f' => self.parse_ident(~"alse", boolean(false)), '0' to '9' | '-' => self.parse_number(), - '"' => alt self.parse_str() { + '"' => match self.parse_str() { ok(s) => ok(string(s)), err(e) => err(e) } @@ -200,20 +200,20 @@ impl parser for parser { neg = -1f; } - let mut res = alt self.parse_integer() { + let mut res = match self.parse_integer() { ok(res) => res, err(e) => return err(e) }; if self.ch == '.' { - alt self.parse_decimal(res) { + match self.parse_decimal(res) { ok(r) => res = r, err(e) => return err(e) } } if self.ch == 'e' || self.ch == 'E' { - alt self.parse_exponent(res) { + match self.parse_exponent(res) { ok(r) => res = r, err(e) => return err(e) } @@ -225,19 +225,19 @@ impl parser for parser { fn parse_integer() -> result<float, error> { let mut res = 0f; - alt self.ch { + match self.ch { '0' => { self.bump(); // There can be only one leading '0'. - alt self.ch { + match self.ch { '0' to '9' => return self.error(~"invalid number"), _ => () } } '1' to '9' => { while !self.eof() { - alt self.ch { + match self.ch { '0' to '9' => { res *= 10f; res += ((self.ch as int) - ('0' as int)) as float; @@ -258,7 +258,7 @@ impl parser for parser { self.bump(); // Make sure a digit follows the decimal place. - alt self.ch { + match self.ch { '0' to '9' => (), _ => return self.error(~"invalid number") } @@ -266,7 +266,7 @@ impl parser for parser { let mut res = res; let mut dec = 1f; while !self.eof() { - alt self.ch { + match self.ch { '0' to '9' => { dec /= 10f; res += (((self.ch as int) - ('0' as int)) as float) * dec; @@ -287,20 +287,20 @@ impl parser for parser { let mut exp = 0u; let mut neg_exp = false; - alt self.ch { + match self.ch { '+' => self.bump(), '-' => { self.bump(); neg_exp = true; } _ => () } // Make sure a digit follows the exponent place. - alt self.ch { + match self.ch { '0' to '9' => (), _ => return self.error(~"invalid number") } while !self.eof() { - alt self.ch { + match self.ch { '0' to '9' => { exp *= 10u; exp += (self.ch as uint) - ('0' as uint); @@ -329,7 +329,7 @@ impl parser for parser { self.bump(); if (escape) { - alt self.ch { + match self.ch { '"' => str::push_char(res, '"'), '\\' => str::push_char(res, '\\'), '/' => str::push_char(res, '/'), @@ -343,7 +343,7 @@ impl parser for parser { let mut i = 0u; let mut n = 0u; while i < 4u { - alt self.next_char() { + match self.next_char() { '0' to '9' => { n = n * 10u + (self.ch as uint) - ('0' as uint); @@ -389,7 +389,7 @@ impl parser for parser { } loop { - alt self.parse_value() { + match self.parse_value() { ok(v) => vec::push(values, v), e => return e } @@ -399,7 +399,7 @@ impl parser for parser { return self.error(~"EOF while parsing list"); } - alt self.ch { + match self.ch { ',' => self.bump(), ']' => { self.bump(); return ok(list(@values)); } _ => return self.error(~"expected `,` or `]`") @@ -425,7 +425,7 @@ impl parser for parser { return self.error(~"key must be a string"); } - let key = alt self.parse_str() { + let key = match self.parse_str() { ok(key) => key, err(e) => return err(e) }; @@ -438,13 +438,13 @@ impl parser for parser { } self.bump(); - alt self.parse_value() { + match self.parse_value() { ok(value) => { values.insert(copy *key, value); } e => return e } self.parse_whitespace(); - alt self.ch { + match self.ch { ',' => self.bump(), '}' => { self.bump(); return ok(dict(values)); } _ => { @@ -477,7 +477,7 @@ fn from_str(s: ~str) -> result<json, error> { /// Test if two json values are equal fn eq(value0: json, value1: json) -> bool { - alt (value0, value1) { + match (value0, value1) { (num(f0), num(f1)) => f0 == f1, (string(s0), string(s1)) => s0 == s1, (boolean(b0), boolean(b1)) => b0 == b1, @@ -486,7 +486,7 @@ fn eq(value0: json, value1: json) -> bool { if d0.size() == d1.size() { let mut equal = true; for d0.each |k, v0| { - alt d1.find(k) { + match d1.find(k) { some(v1) => if !eq(v0, v1) { equal = false }, none => equal = false } @@ -581,7 +581,7 @@ impl of to_json for @~str { impl <A: to_json, B: to_json> of to_json for (A, B) { fn to_json() -> json { - alt self { + match self { (a, b) => { list(@~[a.to_json(), b.to_json()]) } @@ -592,7 +592,7 @@ impl <A: to_json, B: to_json> of to_json for (A, B) { impl <A: to_json, B: to_json, C: to_json> of to_json for (A, B, C) { fn to_json() -> json { - alt self { + match self { (a, b, c) => { list(@~[a.to_json(), b.to_json(), c.to_json()]) } @@ -616,7 +616,7 @@ impl <A: to_json copy> of to_json for hashmap<~str, A> { impl <A: to_json> of to_json for option<A> { fn to_json() -> json { - alt self { + match self { none => null, some(value) => value.to_json() } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 3538929e728..4b8b75d3d66 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -43,7 +43,7 @@ fn foldl<T: copy, U>(z: T, ls: @list<U>, f: fn(T, U) -> T) -> T { fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> option<T> { let mut ls = ls; loop { - ls = alt *ls { + ls = match *ls { cons(hd, tl) => { if f(hd) { return some(hd); } tl @@ -63,7 +63,7 @@ fn has<T: copy>(ls: @list<T>, elt: T) -> bool { /// Returns true if the list is empty pure fn is_empty<T: copy>(ls: @list<T>) -> bool { - alt *ls { + match *ls { nil => true, _ => false } @@ -83,7 +83,7 @@ fn len<T>(ls: @list<T>) -> uint { /// Returns all but the first element of a list pure fn tail<T: copy>(ls: @list<T>) -> @list<T> { - alt *ls { + match *ls { cons(_, tl) => return tl, nil => fail ~"list empty" } @@ -91,12 +91,12 @@ pure fn tail<T: copy>(ls: @list<T>) -> @list<T> { /// Returns the first element of a list pure fn head<T: copy>(ls: @list<T>) -> T { - alt check *ls { cons(hd, _) => hd } + match check *ls { cons(hd, _) => hd } } /// Appends one list to another pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T> { - alt *l { + match *l { nil => return m, cons(x, xs) => { let rest = append(xs, m); @@ -114,7 +114,7 @@ fn push<T: copy>(&l: list<T>, v: T) { fn iter<T>(l: @list<T>, f: fn(T)) { let mut cur = l; loop { - cur = alt *cur { + cur = match *cur { cons(hd, tl) => { f(hd); tl @@ -128,7 +128,7 @@ fn iter<T>(l: @list<T>, f: fn(T)) { fn each<T>(l: @list<T>, f: fn(T) -> bool) { let mut cur = l; loop { - cur = alt *cur { + cur = match *cur { cons(hd, tl) => { if !f(hd) { return; } tl diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 2b99c4cb8aa..695f40fc387 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -133,7 +133,7 @@ mod chained { let mut e0 = e_root; let mut comp = 1u; // for logging loop { - alt copy e0.next { + match copy e0.next { none => { debug!{"search_tbl: absent, comp %u, hash %u, idx %u", comp, h, idx}; @@ -156,7 +156,7 @@ mod chained { fn search_tbl(k: &K, h: uint) -> search_result<K,V> { let idx = h % vec::len(self.chains); - alt copy self.chains[idx] { + match copy self.chains[idx] { none => { debug!{"search_tbl: none, comp %u, hash %u, idx %u", 0u, h, idx}; @@ -193,7 +193,7 @@ mod chained { while i < n { let mut chain = self.chains[i]; loop { - chain = alt chain { + chain = match chain { none => break, some(entry) => { let next = entry.next; @@ -216,7 +216,7 @@ mod chained { fn contains_key_ref(k: &K) -> bool { let hash = self.hasher(k); - alt self.search_tbl(k, hash) { + match self.search_tbl(k, hash) { not_found => false, found_first(*) | found_after(*) => true } @@ -224,7 +224,7 @@ mod chained { fn insert(+k: K, +v: V) -> bool { let hash = self.hasher(&k); - alt self.search_tbl(&k, hash) { + match self.search_tbl(&k, hash) { not_found => { self.count += 1u; let idx = hash % vec::len(self.chains); @@ -265,7 +265,7 @@ mod chained { } fn find(+k: K) -> option<V> { - alt self.search_tbl(&k, self.hasher(&k)) { + match self.search_tbl(&k, self.hasher(&k)) { not_found => none, found_first(_, entry) => some(entry.value), found_after(_, entry) => some(entry.value) @@ -281,7 +281,7 @@ mod chained { } fn remove(+k: K) -> option<V> { - alt self.search_tbl(&k, self.hasher(&k)) { + match self.search_tbl(&k, self.hasher(&k)) { not_found => none, found_first(idx, entry) => { self.count -= 1u; @@ -638,7 +638,7 @@ mod tests { i = 0u; while i < num_to_insert { let v = hm.remove(i); - alt v { + match v { option::some(u) => assert (u == i * i), option::none => fail } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 1cc8dd3bed9..d0b08212952 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -47,7 +47,7 @@ type parse_addr_err = { * * ip - a `std::net::ip::ip_addr` */ fn format_addr(ip: ip_addr) -> ~str { - alt ip { + match ip { ipv4(addr) => unsafe { let result = uv_ip4_name(&addr); if result == ~"" { @@ -103,7 +103,7 @@ fn get_addr(++node: ~str, iotask: iotask) node_ptr, ptr::null(), ptr::null()); - alt result { + match result { 0i32 => { set_data_for_req(handle_ptr, handle_data_ptr); } @@ -134,7 +134,7 @@ mod v4 { * * an `ip_addr` of the `ipv4` variant */ fn parse_addr(ip: ~str) -> ip_addr { - alt try_parse_addr(ip) { + match try_parse_addr(ip) { result::ok(addr) => copy(addr), result::err(err_data) => fail err_data.err_msg } @@ -155,7 +155,7 @@ mod v4 { } fn parse_to_ipv4_rep(ip: ~str) -> result::result<ipv4_rep, ~str> { let parts = vec::map(str::split_char(ip, '.'), |s| { - alt uint::from_str(s) { + match uint::from_str(s) { some(n) if n <= 255u => n, _ => 256u } @@ -220,7 +220,7 @@ mod v6 { * * an `ip_addr` of the `ipv6` variant */ fn parse_addr(ip: ~str) -> ip_addr { - alt try_parse_addr(ip) { + match try_parse_addr(ip) { result::ok(addr) => copy(addr), result::err(err_data) => fail err_data.err_msg } @@ -326,7 +326,7 @@ mod test { } #[test] fn test_ip_ipv4_bad_parse() { - alt v4::try_parse_addr(~"b4df00d") { + match v4::try_parse_addr(~"b4df00d") { result::err(err_info) => { log(debug, fmt!{"got error as expected %?", err_info}); assert true; @@ -339,7 +339,7 @@ mod test { #[test] #[ignore(target_os="win32")] fn test_ip_ipv6_bad_parse() { - alt v6::try_parse_addr(~"::,~2234k;") { + match v6::try_parse_addr(~"::,~2234k;") { result::err(err_info) => { log(debug, fmt!{"got error as expected %?", err_info}); assert true; @@ -364,7 +364,7 @@ mod test { log(debug, fmt!{"test_get_addr: Number of results for %s: %?", localhost_name, vec::len(results)}); for vec::each(results) |r| { - let ipv_prefix = alt r { + let ipv_prefix = match r { ipv4(_) => ~"IPv4", ipv6(_) => ~"IPv6" }; diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 2ce47a641c1..4e25a42985a 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -151,16 +151,16 @@ fn connect(-input_ip: ip::ip_addr, port: uint, log(debug, ~"in interact cb for tcp client connect.."); log(debug, fmt!{"stream_handle_ptr in interact %?", stream_handle_ptr}); - alt uv::ll::tcp_init( loop_ptr, stream_handle_ptr) { + match uv::ll::tcp_init( loop_ptr, stream_handle_ptr) { 0i32 => { log(debug, ~"tcp_init successful"); - alt input_ip { + match input_ip { ipv4 => { log(debug, ~"dealing w/ ipv4 connection.."); let connect_req_ptr = ptr::addr_of((*socket_data_ptr).connect_req); let addr_str = ip::format_addr(input_ip); - let connect_result = alt input_ip { + let connect_result = match input_ip { ip::ipv4(addr) => { // have to "recreate" the sockaddr_in/6 // since the ip_addr discards the port @@ -185,7 +185,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint, tcp_connect_on_connect_cb) } }; - alt connect_result { + match connect_result { 0i32 => { log(debug, ~"tcp_connect successful"); // reusable data that we'll have for the @@ -223,7 +223,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint, } } }; - alt comm::recv(result_po) { + match comm::recv(result_po) { conn_success => { log(debug, ~"tcp::connect - received success on result_po"); result::ok(tcp_socket(socket_data)) @@ -234,7 +234,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint, // still have to free the malloc'd stream handle.. rustrt::rust_uv_current_kernel_free(stream_handle_ptr as *libc::c_void); - let tcp_conn_err = alt err_data.err_name { + let tcp_conn_err = match err_data.err_name { ~"ECONNREFUSED" => connection_refused, _ => generic_connect_err(err_data.err_name, err_data.err_msg) }; @@ -445,7 +445,7 @@ fn read_future(sock: tcp_socket, timeout_msecs: uint) * // do work here * } * }; - * alt comm::recv(cont_po) { + * match comm::recv(cont_po) { * // shut down listen() * some(err_data) { comm::send(kill_chan, some(err_data)) } * // wait for next connection @@ -469,7 +469,7 @@ fn read_future(sock: tcp_socket, timeout_msecs: uint) fn accept(new_conn: tcp_new_connection) -> result::result<tcp_socket, tcp_err_data> unsafe { - alt new_conn{ + match new_conn{ new_tcp_conn(server_handle_ptr) => { let server_data_ptr = uv::ll::get_data_for_uv_handle( server_handle_ptr) as *tcp_listen_fc_data; @@ -501,10 +501,10 @@ fn accept(new_conn: tcp_new_connection) log(debug, ~"in interact cb for tcp::accept"); let loop_ptr = uv::ll::get_loop_for_uv_handle( server_handle_ptr); - alt uv::ll::tcp_init(loop_ptr, client_stream_handle_ptr) { + match uv::ll::tcp_init(loop_ptr, client_stream_handle_ptr) { 0i32 => { log(debug, ~"uv_tcp_init successful for client stream"); - alt uv::ll::accept( + match uv::ll::accept( server_handle_ptr as *libc::c_void, client_stream_handle_ptr as *libc::c_void) { 0i32 => { @@ -528,7 +528,7 @@ fn accept(new_conn: tcp_new_connection) } } // UNSAFE LIBUV INTERACTION END - alt comm::recv(result_po) { + match comm::recv(result_po) { some(err_data) => result::err(err_data), none => result::ok(tcp_socket(client_socket_data)) } @@ -610,13 +610,13 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, // nested within a comm::listen block) let loc_ip = copy(host_ip); do iotask::interact(iotask) |loop_ptr| { - alt uv::ll::tcp_init(loop_ptr, server_stream_ptr) { + match uv::ll::tcp_init(loop_ptr, server_stream_ptr) { 0i32 => { uv::ll::set_data_for_uv_handle( server_stream_ptr, server_data_ptr); let addr_str = ip::format_addr(loc_ip); - let bind_result = alt loc_ip { + let bind_result = match loc_ip { ip::ipv4(addr) => { log(debug, fmt!{"addr: %?", addr}); let in_addr = uv::ll::ip4_addr(addr_str, port as int); @@ -630,9 +630,9 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, ptr::addr_of(in_addr)) } }; - alt bind_result { + match bind_result { 0i32 => { - alt uv::ll::listen(server_stream_ptr, + match uv::ll::listen(server_stream_ptr, backlog as libc::c_int, tcp_lfc_on_connection_cb) { 0i32 => comm::send(setup_ch, none), @@ -659,7 +659,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, }; setup_ch.recv() }; - alt setup_result { + match setup_result { some(err_data) => { do iotask::interact(iotask) |loop_ptr| { log(debug, fmt!{"tcp::listen post-kill recv hl interact %?", @@ -668,7 +668,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, uv::ll::close(server_stream_ptr, tcp_lfc_close_cb); }; stream_closed_po.recv(); - alt err_data.err_name { + match err_data.err_name { ~"EACCES" => { log(debug, ~"Got EACCES error"); result::err(access_denied) @@ -695,7 +695,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint, uv::ll::close(server_stream_ptr, tcp_lfc_close_cb); }; stream_closed_po.recv(); - alt kill_result { + match kill_result { // some failure post bind/listen some(err_data) => result::err(generic_listen_err(err_data.err_name, err_data.err_msg)), @@ -878,7 +878,7 @@ fn read_common_impl(socket_data: *tcp_socket_data, timeout_msecs: uint) some(comm::recv(result::get(rs_result))) }; log(debug, ~"tcp::read after recv_timeout"); - alt read_result { + match read_result { none => { log(debug, ~"tcp::read: timed out.."); let err_data = { @@ -905,7 +905,7 @@ fn read_stop_common_impl(socket_data: *tcp_socket_data) -> let stop_ch = comm::chan(stop_po); do iotask::interact((*socket_data).iotask) |loop_ptr| { log(debug, ~"in interact cb for tcp::read_stop"); - alt uv::ll::read_stop(stream_handle_ptr as *uv::ll::uv_stream_t) { + match uv::ll::read_stop(stream_handle_ptr as *uv::ll::uv_stream_t) { 0i32 => { log(debug, ~"successfully called uv_read_stop"); comm::send(stop_ch, none); @@ -917,7 +917,7 @@ fn read_stop_common_impl(socket_data: *tcp_socket_data) -> } } }; - alt comm::recv(stop_po) { + match comm::recv(stop_po) { some(err_data) => result::err(err_data.to_tcp_err()), none => result::ok(()) } @@ -933,7 +933,7 @@ fn read_start_common_impl(socket_data: *tcp_socket_data) log(debug, ~"in tcp::read_start before interact loop"); do iotask::interact((*socket_data).iotask) |loop_ptr| { log(debug, fmt!{"in tcp::read_start interact cb %?", loop_ptr}); - alt uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t, + match uv::ll::read_start(stream_handle_ptr as *uv::ll::uv_stream_t, on_alloc_cb, on_tcp_read_cb) { 0i32 => { @@ -947,7 +947,7 @@ fn read_start_common_impl(socket_data: *tcp_socket_data) } } }; - alt comm::recv(start_po) { + match comm::recv(start_po) { some(err_data) => result::err(err_data.to_tcp_err()), none => result::ok((*socket_data).reader_po) } @@ -973,7 +973,7 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data, let write_data_ptr = ptr::addr_of(write_data); do iotask::interact((*socket_data_ptr).iotask) |loop_ptr| { log(debug, fmt!{"in interact cb for tcp::write %?", loop_ptr}); - alt uv::ll::write(write_req_ptr, + match uv::ll::write(write_req_ptr, stream_handle_ptr, write_buf_vec_ptr, tcp_write_complete_cb) { @@ -993,7 +993,7 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data, // and waiting here for the write to complete, we should transfer // ownership of everything to the I/O task and let it deal with the // aftermath, so we don't have to sit here blocking. - alt comm::recv(result_po) { + match comm::recv(result_po) { tcp_write_success => result::ok(()), tcp_write_error(err_data) => result::err(err_data.to_tcp_err()) } @@ -1024,7 +1024,7 @@ extern fn tcp_lfc_on_connection_cb(handle: *uv::ll::uv_tcp_t, as *tcp_listen_fc_data; let kill_ch = (*server_data_ptr).kill_ch; if (*server_data_ptr).active { - alt status { + match status { 0i32 => (*server_data_ptr).on_connect_cb(handle), _ => { let loop_ptr = uv::ll::get_loop_for_uv_handle(handle); @@ -1081,7 +1081,7 @@ extern fn on_tcp_read_cb(stream: *uv::ll::uv_stream_t, let loop_ptr = uv::ll::get_loop_for_uv_handle(stream); let socket_data_ptr = uv::ll::get_data_for_uv_handle(stream) as *tcp_socket_data; - alt nread as int { + match nread as int { // incoming err.. probably eof -1 => { let err_data = uv::ll::get_last_err_data(loop_ptr).to_tcp_err(); @@ -1175,7 +1175,7 @@ extern fn tcp_connect_on_connect_cb(connect_req_ptr: *uv::ll::uv_connect_t, log(debug, fmt!{"tcp_connect result_ch %?", result_ch}); let tcp_stream_ptr = uv::ll::get_stream_handle_from_connect_req(connect_req_ptr); - alt status { + match status { 0i32 => { log(debug, ~"successful tcp connection!"); comm::send(result_ch, conn_success); @@ -1336,7 +1336,7 @@ mod test { client_ch, hl_loop) }; - alt actual_resp_result.get_err() { + match actual_resp_result.get_err() { connection_refused => (), _ => fail ~"unknown error.. expected connection_refused" } @@ -1382,7 +1382,7 @@ mod test { client_ch, hl_loop) }; - alt listen_err { + match listen_err { address_in_use => { assert true; } @@ -1401,7 +1401,7 @@ mod test { server_ip, server_port, hl_loop); - alt listen_err { + match listen_err { access_denied => { assert true; } @@ -1515,7 +1515,7 @@ mod test { log(debug, ~"SERVER: successfully accepted"+ ~"connection!"); let received_req_bytes = read(sock, 0u); - alt received_req_bytes { + match received_req_bytes { result::ok(data) => { log(debug, ~"SERVER: got REQ str::from_bytes.."); log(debug, fmt!{"SERVER: REQ data len: %?", @@ -1544,7 +1544,7 @@ mod test { }); // err check on listen_result if result::is_err(listen_result) { - alt result::get_err(listen_result) { + match result::get_err(listen_result) { generic_listen_err(name, msg) => { fail fmt!{"SERVER: exited abnormally name %s msg %s", name, msg}; diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index 5c779e37507..215d5b4f5e1 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -133,10 +133,10 @@ fn prepend_str(rope: rope, str: @~str) -> rope { /// Concatenate two ropes fn append_rope(left: rope, right: rope) -> rope { - alt(left) { + match (left) { node::empty => return right, node::content(left_content) => { - alt(right) { + match (right) { node::empty => return left, node::content(right_content) => { return node::content(node::concat2(left_content, right_content)); @@ -197,9 +197,9 @@ Section: Keeping ropes healthy * to rebalance your rope at some point, before using it for other purposes. */ fn bal(rope:rope) -> rope { - alt(rope) { + match (rope) { node::empty => return rope, - node::content(x) => alt(node::bal(x)) { + node::content(x) => match (node::bal(x)) { option::none => rope, option::some(y) => node::content(y) } @@ -226,7 +226,7 @@ Section: Transforming ropes */ fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope { if char_len == 0u { return node::empty; } - alt(rope) { + match (rope) { node::empty => fail, node::content(node) => if char_len > node::char_len(node) { fail @@ -251,7 +251,7 @@ fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope { */ fn sub_bytes(rope: rope, byte_offset: uint, byte_len: uint) -> rope { if byte_len == 0u { return node::empty; } - alt(rope) { + match (rope) { node::empty => fail, node::content(node) =>if byte_len > node::byte_len(node) { fail @@ -276,7 +276,7 @@ Section: Comparing ropes * value if `left > right` */ fn cmp(left: rope, right: rope) -> int { - alt((left, right)) { + match ((left, right)) { (node::empty, node::empty) => return 0, (node::empty, _) => return -1, (_, node::empty) => return 1, @@ -379,7 +379,7 @@ Section: Iterating * that is if `it` returned `false` at any point. */ fn loop_chars(rope: rope, it: fn(char) -> bool) -> bool { - alt(rope) { + match (rope) { node::empty => return true, node::content(x) => return node::loop_chars(x, it) } @@ -422,7 +422,7 @@ fn iter_chars(rope: rope, it: fn(char)) { * that is if `it` returned `false` at any point. */ fn loop_leaves(rope: rope, it: fn(node::leaf) -> bool) -> bool{ - alt(rope) { + match (rope) { node::empty => return true, node::content(x) => return node::loop_leaves(x, it) } @@ -431,7 +431,7 @@ fn loop_leaves(rope: rope, it: fn(node::leaf) -> bool) -> bool{ mod iterator { mod leaf { fn start(rope: rope) -> node::leaf_iterator::t { - alt(rope) { + match (rope) { node::empty => return node::leaf_iterator::empty(), node::content(x) => return node::leaf_iterator::start(x) } @@ -442,7 +442,7 @@ mod iterator { } mod char { fn start(rope: rope) -> node::char_iterator::t { - alt(rope) { + match (rope) { node::empty => return node::char_iterator::empty(), node::content(x) => return node::char_iterator::start(x) } @@ -469,7 +469,7 @@ mod iterator { * Constant time. */ fn height(rope: rope) -> uint { - alt(rope) { + match (rope) { node::empty => return 0u, node::content(x) => return node::height(x) } @@ -485,7 +485,7 @@ fn height(rope: rope) -> uint { * Constant time. */ pure fn char_len(rope: rope) -> uint { - alt(rope) { + match (rope) { node::empty => return 0u, node::content(x) => return node::char_len(x) } @@ -499,7 +499,7 @@ pure fn char_len(rope: rope) -> uint { * Constant time. */ pure fn byte_len(rope: rope) -> uint { - alt(rope) { + match (rope) { node::empty => return 0u, node::content(x) => return node::byte_len(x) } @@ -522,7 +522,7 @@ pure fn byte_len(rope: rope) -> uint { * rope + the (bounded) length of the largest leaf. */ fn char_at(rope: rope, pos: uint) -> char { - alt(rope) { + match (rope) { node::empty => fail, node::content(x) => return node::char_at(x, pos) } @@ -730,14 +730,14 @@ mod node { pure fn byte_len(node: @node) -> uint { //FIXME (#2744): Could we do this without the pattern-matching? - alt(*node) { + match (*node) { leaf(y) => return y.byte_len, concat(y) => return y.byte_len } } pure fn char_len(node: @node) -> uint { - alt(*node) { + match (*node) { leaf(y) => return y.char_len, concat(y) => return y.char_len } @@ -800,7 +800,7 @@ mod node { let mut offset = 0u;//Current position in the buffer let it = leaf_iterator::start(node); loop { - alt(leaf_iterator::next(it)) { + match (leaf_iterator::next(it)) { option::none => break, option::some(x) => { //FIXME (#2744): Replace with memcpy or something similar @@ -827,7 +827,7 @@ mod node { * This function executes in linear time. */ fn flatten(node: @node) -> @node unsafe { - alt(*node) { + match (*node) { leaf(_) => return node, concat(x) => { return @leaf({ @@ -861,7 +861,7 @@ mod node { let mut forest = ~[mut]; let it = leaf_iterator::start(node); loop { - alt (leaf_iterator::next(it)) { + match (leaf_iterator::next(it)) { option::none => break, option::some(x) => vec::push(forest, @leaf(x)) } @@ -898,7 +898,7 @@ mod node { if byte_offset == 0u && byte_len == node::byte_len(node) { return node; } - alt(*node) { + match (*node) { node::leaf(x) => { let char_len = str::count_chars(*x.content, byte_offset, byte_len); @@ -956,7 +956,7 @@ mod node { let mut node = node; let mut char_offset = char_offset; loop { - alt(*node) { + match (*node) { node::leaf(x) => { if char_offset == 0u && char_len == x.char_len { return node; @@ -1007,7 +1007,7 @@ mod node { } fn height(node: @node) -> uint { - alt(*node) { + match (*node) { leaf(_) => return 0u, concat(x) => return x.height } @@ -1018,7 +1018,7 @@ mod node { let itb = char_iterator::start(b); let mut result = 0; while result == 0 { - alt((char_iterator::next(ita), char_iterator::next(itb))) { + match ((char_iterator::next(ita), char_iterator::next(itb))) { (option::none, option::none) => break, (option::some(chara), option::some(charb)) => { result = char::cmp(chara, charb); @@ -1059,7 +1059,7 @@ mod node { fn loop_leaves(node: @node, it: fn(leaf) -> bool) -> bool{ let mut current = node; loop { - alt(*current) { + match (*current) { leaf(x) => return it(x), concat(x) => if loop_leaves(x.left, it) { //non tail call current = x.right; //tail call @@ -1091,7 +1091,7 @@ mod node { let mut node = node; let mut pos = pos; loop { - alt *node { + match *node { leaf(x) => return str::char_at(*x.content, pos), concat({left, right, _}) => { let left_len = char_len(left); @@ -1126,7 +1126,7 @@ mod node { loop { let current = it.stack[it.stackpos]; it.stackpos -= 1; - alt(*current) { + match (*current) { concat(x) => { it.stackpos += 1; it.stack[it.stackpos] = x.right; @@ -1164,11 +1164,11 @@ mod node { fn next(it: t) -> option<char> { loop { - alt(get_current_or_next_leaf(it)) { + match (get_current_or_next_leaf(it)) { option::none => return option::none, option::some(_) => { let next_char = get_next_char_in_leaf(it); - alt(next_char) { + match (next_char) { option::none => again, option::some(_) => return next_char } @@ -1178,11 +1178,11 @@ mod node { } fn get_current_or_next_leaf(it: t) -> option<leaf> { - alt(it.leaf) { + match (it.leaf) { option::some(_) => return it.leaf, option::none => { let next = leaf_iterator::next(it.leaf_iterator); - alt(next) { + match (next) { option::none => return option::none, option::some(_) => { it.leaf = next; @@ -1195,7 +1195,7 @@ mod node { } fn get_next_char_in_leaf(it: t) -> option<char> { - alt copy it.leaf { + match copy it.leaf { option::none => return option::none, option::some(aleaf) => { if it.leaf_byte_pos >= aleaf.byte_len { @@ -1220,12 +1220,12 @@ mod tests { //Utility function, used for sanity check fn rope_to_string(r: rope) -> ~str { - alt(r) { + match (r) { node::empty => return ~"", node::content(x) => { let str = @mut ~""; fn aux(str: @mut ~str, node: @node::node) unsafe { - alt(*node) { + match (*node) { node::leaf(x) => { *str += str::slice( *x.content, x.byte_offset, @@ -1274,7 +1274,7 @@ mod tests { let rope_iter = iterator::char::start(r); let mut equal = true; while equal { - alt(node::char_iterator::next(rope_iter)) { + match (node::char_iterator::next(rope_iter)) { option::none => { if string_iter < string_len { equal = false; @@ -1301,7 +1301,7 @@ mod tests { let mut len = 0u; let it = iterator::char::start(r); loop { - alt(node::char_iterator::next(it)) { + match (node::char_iterator::next(it)) { option::none => break, option::some(_) => len += 1u } diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index 622d31c00b9..86421ea3e74 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -243,7 +243,7 @@ fn deserialize_bool<D: deserializer>(d: D) -> bool { fn serialize_option<S: serializer,T>(s: S, v: option<T>, st: fn(T)) { do s.emit_enum(~"option") { - alt v { + match v { none => do s.emit_enum_variant(~"none", 0u, 0u) { } @@ -260,7 +260,7 @@ fn deserialize_option<D: deserializer,T: copy>(d: D, st: fn() -> T) -> option<T> { do d.read_enum(~"option") { do d.read_enum_variant |i| { - alt check i { + match check i { 0u => none, 1u => some(d.read_enum_variant_arg(0u, || st() )) } diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 2fe09f75d56..6ed2a397b3f 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -48,7 +48,7 @@ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> { * If the key does not exist in the map */ pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T { - alt find(self, key) { + match find(self, key) { none => { error!{"smallintmap::get(): key not present"}; fail; @@ -67,7 +67,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn size() -> uint { let mut sz = 0u; for self.v.each |item| { - alt item { + match item { some(_) => sz += 1u, _ => () } @@ -103,7 +103,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn each(it: fn(+key: uint, +value: V) -> bool) { let mut idx = 0u, l = self.v.len(); while idx < l { - alt self.v.get_elt(idx) { + match self.v.get_elt(idx) { some(elt) => if !it(idx, elt) { break } none => () } @@ -119,7 +119,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn each_ref(it: fn(key: &uint, value: &V) -> bool) { let mut idx = 0u, l = self.v.len(); while idx < l { - alt self.v.get_elt(idx) { + match self.v.get_elt(idx) { some(elt) => if !it(&idx, &elt) { break } none => () } diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index a67164ee107..1ebfe695519 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -21,7 +21,7 @@ fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> { #[test] fn test_mkdtemp() { let r = mkdtemp(~"./", ~"foobar"); - alt r { + match r { some(p) => { os::remove_dir(p); assert(str::ends_with(p, ~"foobar")); diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 1d2ae7bca5d..0d311223847 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -35,7 +35,7 @@ fn reset(writer: io::writer) { fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; - return alt os::getenv(~"TERM") { + return match os::getenv(~"TERM") { option::some(env) => { for vec::each(supported_terms) |term| { if term == env { return true; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 890bddb3519..a4b52c51685 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -52,7 +52,7 @@ type test_desc = { // arguments and a vector of test_descs (generated at compile time). fn test_main(args: ~[~str], tests: ~[test_desc]) { let opts = - alt parse_opts(args) { + match parse_opts(args) { either::left(o) => o, either::right(m) => fail m }; @@ -69,7 +69,7 @@ fn parse_opts(args: ~[~str]) -> opt_res { let args_ = vec::tail(args); let opts = ~[getopts::optflag(~"ignored"), getopts::optopt(~"logfile")]; let matches = - alt getopts::getopts(args_, opts) { + match getopts::getopts(args_, opts) { ok(m) => m, err(f) => return either::right(getopts::fail_str(f)) }; @@ -105,7 +105,7 @@ fn run_tests_console(opts: test_opts, tests: ~[test_desc]) -> bool { fn callback(event: testevent, st: console_test_state) { - alt event { + match event { te_filtered(filtered_tests) => { st.total = vec::len(filtered_tests); let noun = if st.total != 1u { ~"tests" } else { ~"test" }; @@ -113,11 +113,11 @@ fn run_tests_console(opts: test_opts, } te_wait(test) => st.out.write_str(fmt!{"test %s ... ", test.name}), te_result(test, result) => { - alt st.log_out { + match st.log_out { some(f) => write_log(f, result, test), none => () } - alt result { + match result { tr_ok => { st.passed += 1u; write_ok(st.out, st.use_color); @@ -139,8 +139,9 @@ fn run_tests_console(opts: test_opts, } } - let log_out = alt opts.logfile { - some(path) => alt io::file_writer(path, ~[io::create, io::truncate]) { + let log_out = match opts.logfile { + some(path) => match io::file_writer(path, + ~[io::create, io::truncate]) { result::ok(w) => some(w), result::err(s) => { fail(fmt!{"can't open output file: %s", s}) @@ -180,7 +181,7 @@ fn run_tests_console(opts: test_opts, fn write_log(out: io::writer, result: test_result, test: test_desc) { out.write_line(fmt!{"%s %s", - alt result { + match result { tr_ok => ~"ok", tr_failed => ~"failed", tr_ignored => ~"ignored" @@ -334,7 +335,7 @@ fn filter_tests(opts: test_opts, filtered } else { let filter_str = - alt opts.filter { + match opts.filter { option::some(f) => f, option::none => ~"" }; @@ -479,7 +480,7 @@ mod tests { #[test] fn first_free_arg_should_be_a_filter() { let args = ~[~"progname", ~"filter"]; - let opts = alt parse_opts(args) { + let opts = match parse_opts(args) { either::left(o) => o, _ => fail ~"Malformed arg in first_free_arg_should_be_a_filter" }; @@ -489,7 +490,7 @@ mod tests { #[test] fn parse_ignored_flag() { let args = ~[~"progname", ~"filter", ~"--ignored"]; - let opts = alt parse_opts(args) { + let opts = match parse_opts(args) { either::left(o) => o, _ => fail ~"Malformed arg in parse_ignored_flag" }; diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 23b6bf22276..3a4b5f3ccd9 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -181,7 +181,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { let {ch, next} = str::char_range_at(s, pos); pos = next; - alt ch { + match ch { '0' to '9' => { value = value * 10_i32 + (ch as i32 - '0' as i32); } @@ -208,8 +208,8 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { fn parse_type(s: ~str, pos: uint, ch: char, tm: tm_mut) -> result<uint, ~str> { - alt ch { - 'A' => alt match_strs(s, pos, ~[ + match ch { + 'A' => match match_strs(s, pos, ~[ (~"Sunday", 0_i32), (~"Monday", 1_i32), (~"Tuesday", 2_i32), @@ -221,7 +221,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { some(item) => { let (v, pos) = item; tm.tm_wday = v; ok(pos) } none => err(~"Invalid day") } - 'a' => alt match_strs(s, pos, ~[ + 'a' => match match_strs(s, pos, ~[ (~"Sun", 0_i32), (~"Mon", 1_i32), (~"Tue", 2_i32), @@ -233,7 +233,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { some(item) => { let (v, pos) = item; tm.tm_wday = v; ok(pos) } none => err(~"Invalid day") } - 'B' => alt match_strs(s, pos, ~[ + 'B' => match match_strs(s, pos, ~[ (~"January", 0_i32), (~"February", 1_i32), (~"March", 2_i32), @@ -250,7 +250,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { some(item) => { let (v, pos) = item; tm.tm_mon = v; ok(pos) } none => err(~"Invalid month") } - 'b' | 'h' => alt match_strs(s, pos, ~[ + 'b' | 'h' => match match_strs(s, pos, ~[ (~"Jan", 0_i32), (~"Feb", 1_i32), (~"Mar", 2_i32), @@ -267,7 +267,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { some(item) => { let (v, pos) = item; tm.tm_mon = v; ok(pos) } none => err(~"Invalid month") } - 'C' => alt match_digits(s, pos, 2u, false) { + 'C' => match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_year += (v * 100_i32) - 1900_i32; @@ -293,11 +293,11 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { .chain(|pos| parse_char(s, pos, '/')) .chain(|pos| parse_type(s, pos, 'y', tm)) } - 'd' => alt match_digits(s, pos, 2u, false) { + 'd' => match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_mday = v; ok(pos) } none => err(~"Invalid day of the month") } - 'e' => alt match_digits(s, pos, 2u, true) { + 'e' => match match_digits(s, pos, 2u, true) { some(item) => { let (v, pos) = item; tm.tm_mday = v; ok(pos) } none => err(~"Invalid day of the month") } @@ -310,14 +310,14 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } 'H' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, false) { + match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_hour = v; ok(pos) } none => err(~"Invalid hour") } } 'I' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, false) { + match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_hour = if v == 12_i32 { 0_i32 } else { v }; @@ -328,7 +328,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } 'j' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 3u, false) { + match match_digits(s, pos, 3u, false) { some(item) => { let (v, pos) = item; tm.tm_yday = v - 1_i32; @@ -339,14 +339,14 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } 'k' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, true) { + match match_digits(s, pos, 2u, true) { some(item) => { let (v, pos) = item; tm.tm_hour = v; ok(pos) } none => err(~"Invalid hour") } } 'l' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, true) { + match match_digits(s, pos, 2u, true) { some(item) => { let (v, pos) = item; tm.tm_hour = if v == 12_i32 { 0_i32 } else { v }; @@ -357,14 +357,14 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } 'M' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, false) { + match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_min = v; ok(pos) } none => err(~"Invalid minute") } } 'm' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, false) { + match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_mon = v - 1_i32; @@ -374,11 +374,15 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } } 'n' => parse_char(s, pos, '\n'), - 'P' => alt match_strs(s, pos, ~[(~"am", 0_i32), (~"pm", 12_i32)]) { + 'P' => match match_strs(s, pos, + ~[(~"am", 0_i32), (~"pm", 12_i32)]) { + some(item) => { let (v, pos) = item; tm.tm_hour += v; ok(pos) } none => err(~"Invalid hour") } - 'p' => alt match_strs(s, pos, ~[(~"AM", 0_i32), (~"PM", 12_i32)]) { + 'p' => match match_strs(s, pos, + ~[(~"AM", 0_i32), (~"PM", 12_i32)]) { + some(item) => { let (v, pos) = item; tm.tm_hour += v; ok(pos) } none => err(~"Invalid hour") } @@ -398,7 +402,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } 'S' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, false) { + match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_sec = v; @@ -418,7 +422,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { 't' => parse_char(s, pos, '\t'), 'u' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 1u, false) { + match match_digits(s, pos, 1u, false) { some(item) => { let (v, pos) = item; tm.tm_wday = v; @@ -437,7 +441,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { //'W' {} 'w' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 1u, false) { + match match_digits(s, pos, 1u, false) { some(item) => { let (v, pos) = item; tm.tm_wday = v; ok(pos) } none => err(~"Invalid weekday") } @@ -446,7 +450,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { //'x' {} 'Y' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 4u, false) { + match match_digits(s, pos, 4u, false) { some(item) => { let (v, pos) = item; tm.tm_year = v - 1900_i32; @@ -457,7 +461,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { } 'y' => { // FIXME (#2350): range check. - alt match_digits(s, pos, 2u, false) { + match match_digits(s, pos, 2u, false) { some(item) => { let (v, pos) = item; tm.tm_year = v - 1900_i32; @@ -489,7 +493,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { let {ch, next} = str::char_range_at(s, pos); if ch == '+' || ch == '-' { - alt match_digits(s, next, 4u, false) { + match match_digits(s, next, 4u, false) { some(item) => { let (v, pos) = item; if v == 0_i32 { @@ -534,8 +538,8 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { while !rdr.eof() && pos < len { let {ch, next} = str::char_range_at(s, pos); - alt rdr.read_char() { - '%' => alt parse_type(s, pos, rdr.read_char(), tm) { + match rdr.read_char() { + '%' => match parse_type(s, pos, rdr.read_char(), tm) { ok(next) => pos = next, err(e) => { result = err(e); break; } } @@ -568,8 +572,8 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { fn strftime(format: ~str, tm: tm) -> ~str { fn parse_type(ch: char, tm: tm) -> ~str { //FIXME (#2350): Implement missing types. - alt check ch { - 'A' => alt check tm.tm_wday as int { + match check ch { + 'A' => match check tm.tm_wday as int { 0 => ~"Sunday", 1 => ~"Monday", 2 => ~"Tuesday", @@ -578,7 +582,7 @@ fn strftime(format: ~str, tm: tm) -> ~str { 5 => ~"Friday", 6 => ~"Saturday" } - 'a' => alt check tm.tm_wday as int { + 'a' => match check tm.tm_wday as int { 0 => ~"Sun", 1 => ~"Mon", 2 => ~"Tue", @@ -587,7 +591,7 @@ fn strftime(format: ~str, tm: tm) -> ~str { 5 => ~"Fri", 6 => ~"Sat" } - 'B' => alt check tm.tm_mon as int { + 'B' => match check tm.tm_mon as int { 0 => ~"January", 1 => ~"February", 2 => ~"March", @@ -601,7 +605,7 @@ fn strftime(format: ~str, tm: tm) -> ~str { 10 => ~"November", 11 => ~"December" } - 'b' | 'h' => alt check tm.tm_mon as int { + 'b' | 'h' => match check tm.tm_mon as int { 0 => ~"Jan", 1 => ~"Feb", 2 => ~"Mar", @@ -716,7 +720,7 @@ fn strftime(format: ~str, tm: tm) -> ~str { do io::with_str_reader(format) |rdr| { while !rdr.eof() { - alt rdr.read_char() { + match rdr.read_char() { '%' => buf += parse_type(rdr.read_char(), tm), ch => str::push_char(buf, ch) } @@ -932,7 +936,7 @@ mod tests { os::setenv(~"TZ", ~"America/Los_Angeles"); tzset(); - alt strptime(~"", ~"") { + match strptime(~"", ~"") { ok(tm) => { assert tm.tm_sec == 0_i32; assert tm.tm_min == 0_i32; @@ -954,7 +958,7 @@ mod tests { assert strptime(~"Fri Feb 13 15:31:30", format) == err(~"Invalid time"); - alt strptime(~"Fri Feb 13 15:31:30 2009", format) { + match strptime(~"Fri Feb 13 15:31:30 2009", format) { err(e) => fail e, ok(tm) => { assert tm.tm_sec == 30_i32; @@ -973,7 +977,7 @@ mod tests { } fn test(s: ~str, format: ~str) -> bool { - alt strptime(s, format) { + match strptime(s, format) { ok(tm) => tm.strftime(format) == s, err(e) => fail e } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index de629d98d63..d19d7a1adcc 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -215,7 +215,7 @@ mod test { delayed_send(hl_loop, 1u, test_ch, expected); }; - alt recv_timeout(hl_loop, 10u, test_po) { + match recv_timeout(hl_loop, 10u, test_po) { some(val) => { assert val == expected; successes += 1; @@ -243,7 +243,7 @@ mod test { delayed_send(hl_loop, 1000u, test_ch, expected); }; - alt recv_timeout(hl_loop, 1u, test_po) { + match recv_timeout(hl_loop, 1u, test_po) { none => successes += 1, _ => failures += 1 }; diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index ab7330fb1ee..65dbadb4a53 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -30,7 +30,7 @@ fn treemap<K, V>() -> treemap<K, V> { @mut none } /// Insert a value into the map fn insert<K: copy, V: copy>(m: &mut tree_edge<K, V>, k: K, v: V) { - alt copy *m { + match copy *m { none => { *m = some(@tree_node({key: k, mut value: v, @@ -52,7 +52,7 @@ fn insert<K: copy, V: copy>(m: &mut tree_edge<K, V>, k: K, v: V) { /// Find a value based on the key fn find<K: copy, V: copy>(m: &const tree_edge<K, V>, k: K) -> option<V> { - alt copy *m { + match copy *m { none => none, // FIXME (#2808): was that an optimization? @@ -70,7 +70,7 @@ fn find<K: copy, V: copy>(m: &const tree_edge<K, V>, k: K) -> option<V> { /// Visit all pairs in the map in order. fn traverse<K, V: copy>(m: &const tree_edge<K, V>, f: fn(K, V)) { - alt copy *m { + match copy *m { none => (), some(node) => { traverse(&const node.left, f); diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 52e4879c0b2..b2ae1de6e4a 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -56,7 +56,7 @@ fn get_monitor_task_gl() -> iotask unsafe { let hl_loop = spawn_loop(); loop { debug!{"in outer_loop..."}; - alt select2(weak_exit_po, msg_po) { + match select2(weak_exit_po, msg_po) { left(weak_exit) => { // all normal tasks have ended, tell the // libuv loop to tear_down, then exit diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 5b9d3b1f2f2..80d1053570e 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -144,7 +144,7 @@ extern fn wake_up_cb(async_handle: *ll::uv_async_t, let msg_po = (*data).msg_po; while msg_po.peek() { - alt msg_po.recv() { + match msg_po.recv() { interaction(cb) => cb(loop_ptr), teardown_loop => begin_teardown(data) } diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 9d120cce742..26b95a9a37b 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -848,7 +848,7 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { src_unsafe_ptr, src}); let result = rustrt::rust_uv_ip6_name(src_unsafe_ptr, dst_buf, size as libc::size_t); - alt result { + match result { 0i32 => str::unsafe::from_buf(dst_buf), _ => ~"" } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index daf3e20f469..f10ec142328 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -193,7 +193,7 @@ enum vstore { } pure fn is_blockish(p: ast::proto) -> bool { - alt p { + match p { proto_block => true, proto_bare | proto_uniq | proto_box => false } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index f23385f2e17..2c774abff57 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -12,7 +12,7 @@ type path = ~[path_elt]; /* FIXMEs that say "bad" are as per #2543 */ fn path_to_str_with_sep(p: path, sep: ~str) -> ~str { let strs = do vec::map(p) |e| { - alt e { + match e { path_mod(s) => /* FIXME (#2543) */ copy *s, path_name(s) => /* FIXME (#2543) */ copy *s } @@ -104,7 +104,7 @@ fn map_decoded_item(diag: span_handler, // methods get added to the AST map when their impl is visited. Since we // don't decode and instantiate the impl, but just the method, we have to // add it to the table now: - alt ii { + match ii { ii_item(*) | ii_ctor(*) | ii_dtor(*) => { /* fallthrough */ } ii_foreign(i) => { cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic, @@ -127,7 +127,7 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, copy a, cx.local_id)); cx.local_id += 1u; } - alt fk { + match fk { visit::fk_ctor(nm, attrs, tps, self_id, parent_id) => { let ct = @{node: {id: id, attrs: attrs, @@ -159,7 +159,7 @@ fn map_block(b: blk, cx: ctx, v: vt) { fn number_pat(cx: ctx, pat: @pat) { do ast_util::walk_pat(pat) |p| { - alt p.node { + match p.node { pat_ident(*) => { cx.map.insert(p.id, node_local(cx.local_id)); cx.local_id += 1u; @@ -189,7 +189,7 @@ fn map_method(impl_did: def_id, impl_path: @path, fn map_item(i: @item, cx: ctx, v: vt) { let item_path = @/* FIXME (#2543) */ copy cx.path; cx.map.insert(i.id, node_item(i, item_path)); - alt i.node { + match i.node { item_impl(_, opt_ir, _, ms) => { let impl_did = ast_util::local_def(i.id); for ms.each |m| { @@ -205,7 +205,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { } } item_foreign_mod(nm) => { - let abi = alt attr::foreign_abi(i.attrs) { + let abi = match attr::foreign_abi(i.attrs) { either::left(msg) => cx.diag.span_fatal(i.span, msg), either::right(abi) => abi }; @@ -248,7 +248,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { } _ => () } - alt i.node { + match i.node { item_mod(_) | item_foreign_mod(_) => { vec::push(cx.path, path_mod(i.ident)); } @@ -259,9 +259,9 @@ fn map_item(i: @item, cx: ctx, v: vt) { } fn map_view_item(vi: @view_item, cx: ctx, _v: vt) { - alt vi.node { + match vi.node { view_item_export(vps) => for vps.each |vp| { - let (id, name) = alt vp.node { + let (id, name) = match vp.node { view_path_simple(nm, _, id) => { (id, /* FIXME (#2543) */ copy nm) } @@ -281,7 +281,7 @@ fn map_expr(ex: @expr, cx: ctx, v: vt) { } fn node_id_to_str(map: map, id: node_id) -> ~str { - alt map.find(id) { + match map.find(id) { none => { fmt!{"unknown node (id=%d)", id} } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index cf5168fc6da..4f261afa3de 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -35,7 +35,7 @@ pure fn local_def(id: node_id) -> def_id { {crate: local_crate, node: id} } pure fn is_local(did: ast::def_id) -> bool { did.crate == local_crate } pure fn stmt_id(s: stmt) -> node_id { - alt s.node { + match s.node { stmt_decl(_, id) => id, stmt_expr(_, id) => id, stmt_semi(_, id) => id @@ -43,7 +43,7 @@ pure fn stmt_id(s: stmt) -> node_id { } fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { - alt d { + match d { def_variant(enum_id, var_id) => { return {enm: enum_id, var: var_id} } @@ -52,7 +52,7 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { } pure fn def_id_of_def(d: def) -> def_id { - alt d { + match d { def_fn(id, _) | def_mod(id) | def_foreign_mod(id) | def_const(id) | def_variant(_, id) | def_ty(id) | def_ty_param(id, _) | @@ -70,7 +70,7 @@ pure fn def_id_of_def(d: def) -> def_id { } pure fn binop_to_str(op: binop) -> ~str { - alt op { + match op { add => return ~"+", subtract => return ~"-", mul => return ~"*", @@ -93,7 +93,7 @@ pure fn binop_to_str(op: binop) -> ~str { } pure fn binop_to_method_name(op: binop) -> option<~str> { - alt op { + match op { add => return some(~"add"), subtract => return some(~"sub"), mul => return some(~"mul"), @@ -109,7 +109,7 @@ pure fn binop_to_method_name(op: binop) -> option<~str> { } pure fn lazy_binop(b: binop) -> bool { - alt b { + match b { and => true, or => true, _ => false @@ -117,7 +117,7 @@ pure fn lazy_binop(b: binop) -> bool { } pure fn is_shift_binop(b: binop) -> bool { - alt b { + match b { shl => true, shr => true, _ => false @@ -125,7 +125,7 @@ pure fn is_shift_binop(b: binop) -> bool { } pure fn unop_to_str(op: unop) -> ~str { - alt op { + match op { box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" }, uniq(mt) => if mt == m_mutbl { ~"~mut " } else { ~"~" }, deref => ~"*", @@ -135,11 +135,11 @@ pure fn unop_to_str(op: unop) -> ~str { } pure fn is_path(e: @expr) -> bool { - return alt e.node { expr_path(_) => true, _ => false }; + return match e.node { expr_path(_) => true, _ => false }; } pure fn int_ty_to_str(t: int_ty) -> ~str { - alt t { + match t { ty_char => ~"u8", // ??? ty_i => ~"", ty_i8 => ~"i8", @@ -150,7 +150,7 @@ pure fn int_ty_to_str(t: int_ty) -> ~str { } pure fn int_ty_max(t: int_ty) -> u64 { - alt t { + match t { ty_i8 => 0x80u64, ty_i16 => 0x8000u64, ty_i | ty_char | ty_i32 => 0x80000000u64, // actually ni about ty_i @@ -159,7 +159,7 @@ pure fn int_ty_max(t: int_ty) -> u64 { } pure fn uint_ty_to_str(t: uint_ty) -> ~str { - alt t { + match t { ty_u => ~"u", ty_u8 => ~"u8", ty_u16 => ~"u16", @@ -169,7 +169,7 @@ pure fn uint_ty_to_str(t: uint_ty) -> ~str { } pure fn uint_ty_max(t: uint_ty) -> u64 { - alt t { + match t { ty_u8 => 0xffu64, ty_u16 => 0xffffu64, ty_u | ty_u32 => 0xffffffffu64, // actually ni about ty_u @@ -178,7 +178,7 @@ pure fn uint_ty_max(t: uint_ty) -> u64 { } pure fn float_ty_to_str(t: float_ty) -> ~str { - alt t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" } + match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" } } fn is_exported(i: ident, m: _mod) -> bool { @@ -186,7 +186,7 @@ fn is_exported(i: ident, m: _mod) -> bool { let mut parent_enum : option<ident> = none; for m.items.each |it| { if it.ident == i { local = true; } - alt it.node { + match it.node { item_enum(variants, _) => for variants.each |v| { if v.node.name == i { local = true; @@ -199,14 +199,14 @@ fn is_exported(i: ident, m: _mod) -> bool { } let mut has_explicit_exports = false; for m.view_items.each |vi| { - alt vi.node { + match vi.node { view_item_export(vps) => { has_explicit_exports = true; for vps.each |vp| { - alt vp.node { + match vp.node { ast::view_path_simple(id, _, _) => { if id == i { return true; } - alt parent_enum { + match parent_enum { some(parent_enum_id) => { if id == parent_enum_id { return true; } } @@ -240,7 +240,7 @@ fn is_exported(i: ident, m: _mod) -> bool { } pure fn is_call_expr(e: @expr) -> bool { - alt e.node { expr_call(_, _, _) => true, _ => false } + match e.node { expr_call(_, _, _) => true, _ => false } } pure fn eq_ty(a: &@ty, b: &@ty) -> bool { box::ptr_eq(*a, *b) } @@ -284,7 +284,7 @@ fn ident_to_path(s: span, +i: ident) -> @path { } pure fn is_unguarded(&&a: arm) -> bool { - alt a.guard { + match a.guard { none => true, _ => false } @@ -295,7 +295,7 @@ pure fn unguarded_pat(a: arm) -> option<~[@pat]> { } pure fn class_item_ident(ci: @class_member) -> ident { - alt ci.node { + match ci.node { instance_var(i,_,_,_,_) => /* FIXME (#2543) */ copy i, class_method(it) => /* FIXME (#2543) */ copy it.ident } @@ -306,7 +306,7 @@ type ivar = {ident: ident, ty: @ty, cm: class_mutability, fn public_methods(ms: ~[@method]) -> ~[@method] { vec::filter(ms, - |m| alt m.vis { + |m| match m.vis { public => true, _ => false }) @@ -315,7 +315,7 @@ fn public_methods(ms: ~[@method]) -> ~[@method] { fn split_class_items(cs: ~[@class_member]) -> (~[ivar], ~[@method]) { let mut vs = ~[], ms = ~[]; for cs.each |c| { - alt c.node { + match c.node { instance_var(i, t, cm, id, vis) => { vec::push(vs, {ident: /* FIXME (#2543) */ copy i, ty: t, @@ -332,7 +332,7 @@ fn split_class_items(cs: ~[@class_member]) -> (~[ivar], ~[@method]) { // extract a ty_method from a trait_method. if the trait_method is // a default, pull out the useful fields to make a ty_method fn trait_method_to_ty_method(method: trait_method) -> ty_method { - alt method { + match method { required(m) => m, provided(m) => { {ident: m.ident, attrs: m.attrs, @@ -346,7 +346,7 @@ fn split_trait_methods(trait_methods: ~[trait_method]) -> (~[ty_method], ~[@method]) { let mut reqd = ~[], provd = ~[]; for trait_methods.each |trt_method| { - alt trt_method { + match trt_method { required(tm) => vec::push(reqd, tm), provided(m) => vec::push(provd, m) } @@ -355,7 +355,7 @@ fn split_trait_methods(trait_methods: ~[trait_method]) } pure fn class_member_visibility(ci: @class_member) -> visibility { - alt ci.node { + match ci.node { instance_var(_, _, _, _, vis) => vis, class_method(m) => m.vis } @@ -369,7 +369,7 @@ trait inlined_item_utils { impl inlined_item_methods of inlined_item_utils for inlined_item { fn ident() -> ident { - alt self { + match self { ii_item(i) => /* FIXME (#2543) */ copy i.ident, ii_foreign(i) => /* FIXME (#2543) */ copy i.ident, ii_method(_, m) => /* FIXME (#2543) */ copy m.ident, @@ -379,7 +379,7 @@ impl inlined_item_methods of inlined_item_utils for inlined_item { } fn id() -> ast::node_id { - alt self { + match self { ii_item(i) => i.id, ii_foreign(i) => i.id, ii_method(_, m) => m.id, @@ -389,7 +389,7 @@ impl inlined_item_methods of inlined_item_utils for inlined_item { } fn accept<E>(e: E, v: visit::vt<E>) { - alt self { + match self { ii_item(i) => v.visit_item(i, e, v), ii_foreign(i) => v.visit_foreign_item(i, e, v), ii_method(_, m) => visit::visit_method_helper(m, e, v), @@ -406,7 +406,7 @@ impl inlined_item_methods of inlined_item_utils for inlined_item { /* True if d is either a def_self, or a chain of def_upvars referring to a def_self */ fn is_self(d: ast::def) -> bool { - alt d { + match d { def_self(_) => true, def_upvar(_, d, _) => is_self(*d), _ => false @@ -415,7 +415,7 @@ fn is_self(d: ast::def) -> bool { /// Maps a binary operator to its precedence fn operator_prec(op: ast::binop) -> uint { - alt op { + match op { mul | div | rem => 12u, // 'as' sits between here with 11 add | subtract => 10u, @@ -455,11 +455,11 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_view_item: fn@(vi: @view_item) { - alt vi.node { + match vi.node { view_item_use(_, _, id) => vfn(id), view_item_import(vps) | view_item_export(vps) => { do vec::iter(vps) |vp| { - alt vp.node { + match vp.node { view_path_simple(_, _, id) => vfn(id), view_path_glob(_, id) => vfn(id), view_path_list(_, _, id) => vfn(id) @@ -475,7 +475,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { visit_item: fn@(i: @item) { vfn(i.id); - alt i.node { + match i.node { item_enum(vs, _) => for vs.each |v| { vfn(v.node.id); } _ => () } @@ -511,7 +511,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_ty: fn@(t: @ty) { - alt t.node { + match t.node { ty_path(_, id) => vfn(id), _ => { /* fall through */ } } @@ -525,7 +525,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { _b: ast::blk, _sp: span, id: ast::node_id) { vfn(id); - alt fk { + match fk { visit::fk_ctor(nm, _, tps, self_id, parent_id) => { vec::iter(tps, |tp| vfn(tp.id)); vfn(id); @@ -565,7 +565,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_class_item: fn@(c: @class_member) { - alt c.node { + match c.node { instance_var(_, _, _, id,_) => vfn(id), class_method(_) => () } @@ -592,7 +592,7 @@ fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { } pure fn is_item_impl(item: @ast::item) -> bool { - alt item.node { + match item.node { item_impl(*) => true, _ => false } @@ -600,7 +600,7 @@ pure fn is_item_impl(item: @ast::item) -> bool { fn walk_pat(pat: @pat, it: fn(@pat)) { it(pat); - alt pat.node { + match pat.node { pat_ident(_, pth, some(p)) => walk_pat(p, it), pat_rec(fields, _) => for fields.each |f| { walk_pat(f.pat, it) } pat_enum(_, some(s)) | pat_tup(s) => for s.each |p| { @@ -613,7 +613,7 @@ fn walk_pat(pat: @pat, it: fn(@pat)) { } fn view_path_id(p: @view_path) -> node_id { - alt p.node { + match p.node { view_path_simple(_, _, id) | view_path_glob(_, id) | view_path_list(_, _, id) => id } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f04a8e42ab7..0838a1a70d9 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -114,7 +114,7 @@ fn get_attr_name(attr: ast::attribute) -> ast::ident { // All "bad" FIXME copies are as per #2543 fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident { - alt meta.node { + match meta.node { ast::meta_word(n) => /* FIXME (#2543) */ copy n, ast::meta_name_value(n, _) => /* FIXME (#2543) */ copy n, ast::meta_list(n, _) => /* FIXME (#2543) */ copy n @@ -126,8 +126,8 @@ fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident { * containing a string, otherwise none */ fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@~str> { - alt meta.node { - ast::meta_name_value(_, v) => alt v.node { + match meta.node { + ast::meta_name_value(_, v) => match v.node { ast::lit_str(s) => option::some(s), _ => option::none } @@ -137,7 +137,7 @@ fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@~str> { /// Gets a list of inner meta items from a list meta_item type fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { - alt meta.node { + match meta.node { ast::meta_list(_, l) => option::some(/* FIXME (#2543) */ copy l), _ => option::none } @@ -150,7 +150,7 @@ fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { fn get_name_value_str_pair( item: @ast::meta_item ) -> option<(ast::ident, @~str)> { - alt attr::get_meta_item_value_str(item) { + match attr::get_meta_item_value_str(item) { some(value) => { let name = attr::get_meta_item_name(item); some((name, value)) @@ -203,12 +203,12 @@ fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool { } fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { - return alt a.node { - ast::meta_word(na) => alt b.node { + return match a.node { + ast::meta_word(na) => match b.node { ast::meta_word(nb) => na == nb, _ => false } - ast::meta_name_value(na, va) => alt b.node { + ast::meta_name_value(na, va) => match b.node { ast::meta_name_value(nb, vb) => na == nb && va.node == vb.node, _ => false } @@ -253,8 +253,8 @@ fn last_meta_item_value_str_by_name( items: ~[@ast::meta_item], +name: ~str ) -> option<@~str> { - alt last_meta_item_by_name(items, name) { - some(item) => alt attr::get_meta_item_value_str(item) { + match last_meta_item_by_name(items, name) { + some(item) => match attr::get_meta_item_value_str(item) { some(value) => some(value), none => none } @@ -266,7 +266,7 @@ fn last_meta_item_list_by_name( items: ~[@ast::meta_item], +name: ~str ) -> option<~[@ast::meta_item]> { - alt last_meta_item_by_name(items, name) { + match last_meta_item_by_name(items, name) { some(item) => attr::get_meta_item_list(item), none => none } @@ -280,7 +280,7 @@ fn last_meta_item_list_by_name( fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] { pure fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool { pure fn key(m: &ast::meta_item) -> ast::ident { - alt m.node { + match m.node { ast::meta_word(name) => /* FIXME (#2543) */ copy name, ast::meta_name_value(name, _) => /* FIXME (#2543) */ copy name, ast::meta_list(name, _) => /* FIXME (#2543) */ copy name @@ -310,7 +310,7 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ast::ident) -> fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] { let mut found = ~[]; for find_attrs_by_name(attrs, ~"link").each |attr| { - alt attr.node.value.node { + match attr.node.value.node { ast::meta_list(_, _) => vec::push(found, attr), _ => debug!{"ignoring link attribute that has incorrect type"} } @@ -324,14 +324,14 @@ fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] { */ fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { do find_linkage_attrs(attrs).flat_map |attr| { - alt check attr.node.value.node { + match check attr.node.value.node { ast::meta_list(_, items) => /* FIXME (#2543) */ copy items } } } fn foreign_abi(attrs: ~[ast::attribute]) -> either<~str, ast::foreign_abi> { - return alt attr::first_attr_value_str_by_name(attrs, ~"abi") { + return match attr::first_attr_value_str_by_name(attrs, ~"abi") { option::none => { either::right(ast::foreign_abi_cdecl) } @@ -361,7 +361,7 @@ enum inline_attr { fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr { // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] do vec::foldl(ia_none, attrs) |ia,attr| { - alt attr.node.value.node { + match attr.node.value.node { ast::meta_word(@~"inline") => ia_hint, ast::meta_list(@~"inline", items) => { if !vec::is_empty(find_meta_items_by_name(items, ~"always")) { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 575edaa771c..e725eaaa724 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -124,7 +124,7 @@ fn lookup_char_pos_adj(map: codemap, pos: uint) -> {filename: ~str, line: uint, col: uint, file: option<filemap>} { let loc = lookup_char_pos(map, pos); - alt (loc.file.substr) { + match (loc.file.substr) { fss_none => { {filename: /* FIXME (#2543) */ copy loc.file.name, line: loc.line, @@ -146,7 +146,7 @@ fn lookup_char_pos_adj(map: codemap, pos: uint) fn adjust_span(map: codemap, sp: span) -> span { pure fn lookup(pos: file_pos) -> uint { return pos.ch; } let line = lookup_line(map, sp.lo, lookup); - alt (line.fm.substr) { + match (line.fm.substr) { fss_none => sp, fss_internal(s) => { adjust_span(map, {lo: s.lo + (sp.lo - line.fm.start_pos.ch), @@ -196,7 +196,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { fn get_line(fm: filemap, line: int) -> ~str unsafe { let begin: uint = fm.lines[line].byte - fm.start_pos.byte; - let end = alt str::find_char_from(*fm.src, '\n', begin) { + let end = match str::find_char_from(*fm.src, '\n', begin) { some(e) => e, none => str::len(*fm.src) }; diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 6195849f340..bd5b37ab698 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -87,7 +87,7 @@ impl codemap_handler of handler for handler_t { fn has_errors() -> bool { self.err_count > 0u } fn abort_if_errors() { let s; - alt self.err_count { + match self.err_count { 0u => return, 1u => s = ~"aborting due to previous error", _ => { @@ -122,7 +122,7 @@ fn mk_span_handler(handler: handler, cm: codemap::codemap) -> span_handler { fn mk_handler(emitter: option<emitter>) -> handler { - let emit = alt emitter { + let emit = match emitter { some(e) => e, none => { let f = fn@(cmsp: option<(codemap::codemap, span)>, @@ -147,7 +147,7 @@ enum level { } fn diagnosticstr(lvl: level) -> ~str { - alt lvl { + match lvl { fatal => ~"error", error => ~"error", warning => ~"warning", @@ -156,7 +156,7 @@ fn diagnosticstr(lvl: level) -> ~str { } fn diagnosticcolor(lvl: level) -> u8 { - alt lvl { + match lvl { fatal => term::color_bright_red, error => term::color_bright_red, warning => term::color_bright_yellow, @@ -182,7 +182,7 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: ~str) { fn emit(cmsp: option<(codemap::codemap, span)>, msg: ~str, lvl: level) { - alt cmsp { + match cmsp { some((cm, sp)) => { let sp = codemap::adjust_span(cm,sp); let ss = codemap::span_to_str(sp, cm); @@ -266,7 +266,7 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) { fn expect<T: copy>(diag: span_handler, opt: option<T>, msg: fn() -> ~str) -> T { - alt opt { + match opt { some(t) => t, none => diag.handler().bug(msg()) } diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 6e9673f4bc2..c87ea71fc47 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -101,7 +101,7 @@ fn expand(cx: ext_ctxt, } do vec::flat_map(in_items) |in_item| { - alt in_item.node { + match in_item.node { ast::item_ty(ty, tps) => { vec::append(~[filter_attrs(in_item)], ty_fns(cx, in_item.ident, ty, tps)) @@ -375,7 +375,7 @@ fn ser_lambda(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty, } fn is_vec_or_str(ty: @ast::ty) -> bool { - alt ty.node { + match ty.node { ast::ty_vec(_) => true, // This may be wrong if the user has shadowed (!) str ast::ty_path(@{span: _, global: _, idents: ids, @@ -391,7 +391,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, let ext_cx = cx; // required for #ast{} - alt ty.node { + match ty.node { ast::ty_nil => { ~[#ast[stmt]{$(s).emit_nil()}] } @@ -447,7 +447,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, ast::ty_tup(tys) => { // Generate code like // - // alt v { + // match v { // (v1, v2, v3) { // .. serialize v1, v2, v3 .. // } @@ -483,7 +483,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, vec::is_empty(path.types) { let ident = path.idents[0]; - alt tps.find(*ident) { + match tps.find(*ident) { some(f) => f(v), none => ser_path(cx, tps, path, s, v) } @@ -634,7 +634,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, let ext_cx = cx; // required for #ast{} - alt ty.node { + match ty.node { ast::ty_nil => { #ast{ $(d).read_nil() } } @@ -709,7 +709,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, vec::is_empty(path.types) { let ident = path.idents[0]; - alt tps.find(*ident) { + match tps.find(*ident) { some(f) => f(), none => deser_path(cx, tps, path, d) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b8cce21190c..f2e1855c0f5 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -150,7 +150,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, fn mod_pop() { vec::pop(self.mod_path); } fn mod_path() -> ~[ast::ident] { return self.mod_path; } fn bt_push(ei: codemap::expn_info_) { - alt ei { + match ei { expanded_from({call_site: cs, callie: callie}) => { self.backtrace = some(@expanded_from({ @@ -161,7 +161,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, } } fn bt_pop() { - alt self.backtrace { + match self.backtrace { some(@expanded_from({call_site: {expn_info: prev, _}, _})) => { self.backtrace = prev } @@ -206,8 +206,8 @@ fn mk_ctxt(parse_sess: parse::parse_sess, } fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { - alt expr.node { - ast::expr_lit(l) => alt l.node { + match expr.node { + ast::expr_lit(l) => match l.node { ast::lit_str(s) => return *s, _ => cx.span_fatal(l.span, error) } @@ -216,7 +216,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { } fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { - alt expr.node { + match expr.node { ast::expr_path(p) => { if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { cx.span_fatal(expr.span, error); @@ -233,11 +233,11 @@ fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, min: uint, max: option<uint>, name: ~str) -> ~[@ast::expr] { - alt arg { - some(expr) => alt expr.node { + match arg { + some(expr) => match expr.node { ast::expr_vec(elts, _) => { let elts_len = vec::len(elts); - alt max { + match max { some(max) if ! (min <= elts_len && elts_len <= max) => { cx.span_fatal(sp, fmt!{"#%s takes between %u and %u arguments.", @@ -261,7 +261,7 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body) -> ast::mac_body_ { - alt (args) { + match (args) { some(body) => body, none => cx.span_fatal(sp, ~"missing macro body") } @@ -289,10 +289,10 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree]) let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic, cx.parse_sess().interner, none, arg); let args = - alt parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader, + match parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader, argument_gram).get(@~"arg") { @matched_seq(s, _) => do s.map() |lf| { - alt lf { + match lf { @matched_nonterminal(parse::token::nt_expr(arg)) => { arg /* whew! list of exprs, here we come! */ } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 143a675fa63..01030591da9 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -16,7 +16,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, // option<str> rather than just an maybe-empty string. let var = expr_to_str(cx, args[0], ~"#env requires a string"); - alt os::getenv(var) { + match os::getenv(var) { option::none => return mk_uniq_str(cx, sp, ~""), option::some(s) => return mk_uniq_str(cx, sp, s) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index ee1ec62e4e2..9b50101683a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -15,18 +15,18 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, orig: fn@(expr_, span, ast_fold) -> (expr_, span)) -> (expr_, span) { - return alt e { + return match e { // expr_mac should really be expr_ext or something; it's the // entry-point for all syntax extensions. expr_mac(mac) => { // Old-style macros, for compatibility, will erase this whole // block once we've transitioned. - alt mac.node { + match mac.node { mac_invoc(pth, args, body) => { assert (vec::len(pth.idents) > 0u); let extname = pth.idents[0]; - alt exts.find(*extname) { + match exts.find(*extname) { none => { cx.span_fatal(pth.span, fmt!{"macro undefined: '%s'", *extname}) @@ -69,13 +69,13 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, mac_invoc_tt(pth, tts) => { assert (vec::len(pth.idents) == 1u); let extname = pth.idents[0]; - alt exts.find(*extname) { + match exts.find(*extname) { none => { cx.span_fatal(pth.span, fmt!{"macro undefined: '%s'", *extname}) } some(expr_tt({expander: exp, span: exp_sp})) => { - let expanded = alt exp(cx, mac.span, tts) { + let expanded = match exp(cx, mac.span, tts) { mr_expr(e) => e, _ => cx.span_fatal( pth.span, fmt!{"non-expr macro in expr pos: %s", @@ -141,12 +141,12 @@ fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, // the item into a new set of items. let new_items = do vec::flat_map(module_.items) |item| { do vec::foldr(item.attrs, ~[item]) |attr, items| { - let mname = alt attr.node.value.node { + let mname = match attr.node.value.node { ast::meta_word(n) => n, ast::meta_name_value(n, _) => n, ast::meta_list(n, _) => n }; - alt exts.find(*mname) { + match exts.find(*mname) { none | some(normal(_)) | some(macro_defining(_)) | some(expr_tt(_)) | some(item_tt(*)) => items, some(item_decorator(dec_fn)) => { @@ -166,16 +166,16 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, orig: fn@(&&@ast::item, ast_fold) -> option<@ast::item>) -> option<@ast::item> { - let is_mod = alt it.node { + let is_mod = match it.node { ast::item_mod(_) | ast::item_foreign_mod(_) => true, _ => false }; - let maybe_it = alt it.node { + let maybe_it = match it.node { ast::item_mac(*) => expand_item_mac(exts, cx, it, fld), _ => some(it) }; - alt maybe_it { + match maybe_it { some(it) => { if is_mod { cx.mod_push(it.ident); } let ret_val = orig(it, fld); @@ -192,10 +192,10 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold) -> option<@ast::item> { - alt it.node { + match it.node { item_mac({node: mac_invoc_tt(pth, tts), span}) => { let extname = pth.idents[0]; - alt exts.find(*extname) { + match exts.find(*extname) { none => { cx.span_fatal(pth.span, fmt!{"macro undefined: '%s'", *extname}) @@ -205,7 +205,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx.bt_push(expanded_from({call_site: it.span, callie: {name: *extname, span: expand.span}})); - let maybe_it = alt expanded { + let maybe_it = match expanded { mr_item(it) => fld.fold_item(it), mr_expr(e) => cx.span_fatal(pth.span, ~"expr macro in item position: " + diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index d1acf622c1f..19b5fefc1cf 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -52,7 +52,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, fn make_flags(cx: ext_ctxt, sp: span, flags: ~[flag]) -> @ast::expr { let mut tmp_expr = make_rt_path_expr(cx, sp, @~"flag_none"); for flags.each |f| { - let fstr = alt f { + let fstr = match f { flag_left_justify => ~"flag_left_justify", flag_left_zero_pad => ~"flag_left_zero_pad", flag_space_for_sign => ~"flag_space_for_sign", @@ -65,7 +65,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, return tmp_expr; } fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { - alt cnt { + match cnt { count_implied => { return make_rt_path_expr(cx, sp, @~"count_implied"); } @@ -80,8 +80,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } fn make_ty(cx: ext_ctxt, sp: span, t: ty) -> @ast::expr { let mut rt_type; - alt t { - ty_hex(c) => alt c { + match t { + ty_hex(c) => match c { case_upper => rt_type = ~"ty_hex_upper", case_lower => rt_type = ~"ty_hex_lower" } @@ -121,8 +121,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, // FIXME: Move validation code into core::extfmt (Issue #2249) fn is_signed_type(cnv: conv) -> bool { - alt cnv.ty { - ty_int(s) => alt s { + match cnv.ty { + ty_int(s) => match s { signed => return true, unsigned => return false } @@ -131,12 +131,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } } let unsupported = ~"conversion not supported in #fmt string"; - alt cnv.param { + match cnv.param { option::none => (), _ => cx.span_unimpl(sp, unsupported) } for cnv.flags.each |f| { - alt f { + match f { flag_left_justify => (), flag_sign_always => { if !is_signed_type(cnv) { @@ -156,19 +156,19 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, _ => cx.span_unimpl(sp, unsupported) } } - alt cnv.width { + match cnv.width { count_implied => (), count_is(_) => (), _ => cx.span_unimpl(sp, unsupported) } - alt cnv.precision { + match cnv.precision { count_implied => (), count_is(_) => (), _ => cx.span_unimpl(sp, unsupported) } - alt cnv.ty { + match cnv.ty { ty_str => return make_conv_call(cx, arg.span, ~"str", cnv, arg), - ty_int(sign) => alt sign { + ty_int(sign) => match sign { signed => return make_conv_call(cx, arg.span, ~"int", cnv, arg), unsigned => { return make_conv_call(cx, arg.span, ~"uint", cnv, arg) @@ -188,12 +188,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } } fn log_conv(c: conv) { - alt c.param { + match c.param { some(p) => { log(debug, ~"param: " + int::to_str(p, 10u)); } _ => debug!{"param: none"} } for c.flags.each |f| { - alt f { + match f { flag_left_justify => debug!{"flag: left justify"}, flag_left_zero_pad => debug!{"flag: left zero pad"}, flag_space_for_sign => debug!{"flag: left space pad"}, @@ -201,7 +201,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, flag_alternate => debug!{"flag: alternate"} } } - alt c.width { + match c.width { count_is(i) => log( debug, ~"width: count is " + int::to_str(i, 10u)), count_is_param(i) => log( @@ -209,7 +209,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, count_is_next_param => debug!{"width: count is next param"}, count_implied => debug!{"width: count is implied"} } - alt c.precision { + match c.precision { count_is(i) => log( debug, ~"prec: count is " + int::to_str(i, 10u)), count_is_param(i) => log( @@ -217,16 +217,16 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, count_is_next_param => debug!{"prec: count is next param"}, count_implied => debug!{"prec: count is implied"} } - alt c.ty { + match c.ty { ty_bool => debug!{"type: bool"}, ty_str => debug!{"type: str"}, ty_char => debug!{"type: char"}, - ty_int(s) => alt s { + ty_int(s) => match s { signed => debug!{"type: signed"}, unsigned => debug!{"type: unsigned"} } ty_bits => debug!{"type: bits"}, - ty_hex(cs) => alt cs { + ty_hex(cs) => match cs { case_upper => debug!{"type: uhex"}, case_lower => debug!{"type: lhex"}, } @@ -240,7 +240,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let mut piece_exprs = ~[]; let nargs = args.len(); for pieces.each |pc| { - alt pc { + match pc { piece_string(s) => { vec::push(piece_exprs, mk_uniq_str(cx, fmt_sp, s)) } diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 59687eda96d..8595a991e24 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -44,7 +44,7 @@ impl proto_check of proto::visitor<(), (), ()> for ext_ctxt { fn visit_message(name: ident, _span: span, _tys: &[@ast::ty], this: state, next: next_state) { - alt next { + match next { some({state: next, tys: next_tys}) => { let proto = this.proto; if !proto.has_state(next) { diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 678f5b36c45..aa553d8ae53 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -25,12 +25,12 @@ impl proto_parser of proto_parser for parser { fn parse_state(proto: protocol) { let id = self.parse_ident(); self.expect(token::COLON); - let dir = alt copy self.token { + let dir = match copy self.token { token::IDENT(n, _) => self.get_str(n), _ => fail }; self.bump(); - let dir = alt dir { + let dir = match dir { @~"send" => send, @~"recv" => recv, _ => fail @@ -64,7 +64,7 @@ impl proto_parser of proto_parser for parser { self.expect(token::RARROW); - let next = alt copy self.token { + let next = match copy self.token { token::IDENT(_, _) => { let name = self.parse_ident(); let ntys = if self.token == token::LT { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index f61601a2aa0..16ba6d3a063 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -47,7 +47,7 @@ trait gen_init { impl compile of gen_send for message { fn gen_send(cx: ext_ctxt) -> @ast::item { debug!{"pipec: gen_send"}; - alt self { + match self { message(id, span, tys, this, some({state: next, tys: next_tys})) => { debug!{"pipec: next state exists"}; @@ -71,7 +71,7 @@ impl compile of gen_send for message { let mut body = ~"{\n"; if this.proto.is_bounded() { - let (sp, rp) = alt (this.dir, next.dir) { + let (sp, rp) = match (this.dir, next.dir) { (send, send) => (~"c", ~"s"), (send, recv) => (~"s", ~"c"), (recv, send) => (~"s", ~"c"), @@ -87,7 +87,7 @@ impl compile of gen_send for message { rp, *next.name}; } else { - let pat = alt (this.dir, next.dir) { + let pat = match (this.dir, next.dir) { (send, send) => ~"(c, s)", (send, recv) => ~"(s, c)", (recv, send) => ~"(s, c)", @@ -181,12 +181,12 @@ impl compile of to_type_decls for state { for self.messages.each |m| { let message(name, _span, tys, this, next) = m; - let tys = alt next { + let tys = match next { some({state: next, tys: next_tys}) => { let next = this.proto.get_state(next); let next_name = next.data_name(); - let dir = alt this.dir { + let dir = match this.dir { send => @~"server", recv => @~"client" }; @@ -208,7 +208,7 @@ impl compile of to_type_decls for state { fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] { debug!{"pipec: to_endpoint_decls"}; - let dir = alt dir { + let dir = match dir { send => (*self).dir, recv => (*self).dir.reverse() }; @@ -255,7 +255,7 @@ impl compile of gen_init for protocol { let start_state = self.states[0]; let body = if !self.is_bounded() { - alt start_state.dir { + match start_state.dir { send => #ast { pipes::entangle() }, recv => { #ast {{ @@ -267,7 +267,7 @@ impl compile of gen_init for protocol { } else { let body = self.gen_init_bounded(ext_cx); - alt start_state.dir { + match start_state.dir { send => body, recv => { #ast {{ @@ -322,7 +322,7 @@ impl compile of gen_init for protocol { let mut params: ~[ast::ty_param] = ~[]; for (copy self.states).each |s| { for s.ty_params.each |tp| { - alt params.find(|tpp| *tp.ident == *tpp.ident) { + match params.find(|tpp| *tp.ident == *tpp.ident) { none => vec::push(params, tp), _ => () } @@ -338,7 +338,7 @@ impl compile of gen_init for protocol { let mut params: ~[ast::ty_param] = ~[]; let fields = do (copy self.states).map_to_vec |s| { for s.ty_params.each |tp| { - alt params.find(|tpp| *tp.ident == *tpp.ident) { + match params.find(|tpp| *tp.ident == *tpp.ident) { none => vec::push(params, tp), _ => () } @@ -439,7 +439,7 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt { self.cfg(), ~[], self.parse_sess()); - alt res { + match res { some(ast) => ast, none => { error!{"Parse error with ```\n%s\n```", s}; diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index bd9ea96ee33..5769125225e 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -11,7 +11,7 @@ enum direction { impl of to_str for direction { fn to_str() -> ~str { - alt self { + match self { send => ~"send", recv => ~"recv" } @@ -20,7 +20,7 @@ impl of to_str for direction { impl methods for direction { fn reverse() -> direction { - alt self { + match self { send => recv, recv => send } @@ -36,20 +36,20 @@ enum message { impl methods for message { fn name() -> ident { - alt self { + match self { message(id, _, _, _, _) => id } } fn span() -> span { - alt self { + match self { message(_, span, _, _, _) => span } } /// Return the type parameters actually used by this message fn get_params() -> ~[ast::ty_param] { - alt self { + match self { message(_, _, _, this, _) => this.ty_params } } @@ -92,7 +92,7 @@ impl methods for state { /// from this state. fn reachable(f: fn(state) -> bool) { for self.messages.each |m| { - alt m { + match m { message(_, _, _, _, some({state: id, _})) => { let state = self.proto.get_state(id); if !f(state) { break } diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 21ba9599240..491d6104c7b 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -48,7 +48,7 @@ impl of qq_helper for @ast::expr { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_expr(self, cx, v);} fn extract_mac() -> option<ast::mac_> { - alt (self.node) { + match (self.node) { ast::expr_mac({node: mac, _}) => some(mac), _ => none } @@ -63,7 +63,7 @@ impl of qq_helper for @ast::ty { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_ty(self, cx, v);} fn extract_mac() -> option<ast::mac_> { - alt (self.node) { + match (self.node) { ast::ty_mac({node: mac, _}) => some(mac), _ => none } @@ -124,7 +124,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>) { - alt (node.extract_mac()) { + match (node.extract_mac()) { some(mac_aq(sp, e)) => { cx.gather.push(gather_item { lo: sp.lo - cx.lo, @@ -147,7 +147,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, let mut what = ~"expr"; do option::iter(arg) |arg| { let args: ~[@ast::expr] = - alt arg.node { + match arg.node { ast::expr_vec(elts, _) => elts, _ => { ecx.span_fatal @@ -157,7 +157,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, if vec::len::<@ast::expr>(args) != 1u { ecx.span_fatal(_sp, ~"#ast requires exactly one arg"); } - alt (args[0].node) { + match (args[0].node) { ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u => what = *id[0], _ => ecx.span_fatal(args[0].span, ~"expected an identifier") @@ -165,7 +165,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, } let body = get_mac_body(ecx,_sp,body); - return alt what { + return match what { ~"crate" => finish(ecx, body, parse_crate), ~"expr" => finish(ecx, body, parse_expr), ~"ty" => finish(ecx, body, parse_ty), @@ -183,7 +183,7 @@ fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() } fn parse_pat(p: parser) -> @ast::pat { p.parse_pat(true) } fn parse_item(p: parser) -> @ast::item { - alt p.parse_item(~[]) { + match p.parse_item(~[]) { some(item) => item, none => fail ~"parse_item: parsing an item failed" } @@ -225,7 +225,7 @@ fn finish<T: qq_helper> state = skip(str::char_len(repl)); str2 += repl; } - alt copy state { + match copy state { active => str::push_char(str2, ch), skip(1u) => state = blank, skip(sk) => state = skip (sk-1u), @@ -308,8 +308,8 @@ fn replace_expr(repls: ~[fragment], orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span)) -> (ast::expr_, span) { - alt e { - ast::expr_mac({node: mac_var(i), _}) => alt (repls[i]) { + match e { + ast::expr_mac({node: mac_var(i), _}) => match (repls[i]) { from_expr(r) => (r.node, r.span), _ => fail /* fixme error message */ } @@ -322,8 +322,8 @@ fn replace_ty(repls: ~[fragment], orig: fn@(ast::ty_, span, ast_fold)->(ast::ty_, span)) -> (ast::ty_, span) { - alt e { - ast::ty_mac({node: mac_var(i), _}) => alt (repls[i]) { + match e { + ast::ty_mac({node: mac_var(i), _}) => match (repls[i]) { from_ty(r) => (r.node, r.span), _ => fail /* fixme error message */ } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 79b609113ab..bdb0c663fc7 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -36,7 +36,7 @@ enum matchable { /* for when given an incompatible bit of AST */ fn match_error(cx: ext_ctxt, m: matchable, expected: ~str) -> ! { - alt m { + match m { match_expr(x) => cx.span_fatal( x.span, ~"this argument is an expr, expected " + expected), match_path(x) => cx.span_fatal( @@ -65,8 +65,8 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> let mut idx: uint = 0u; let mut res = none; for elts.each |elt| { - alt elt.node { - expr_mac(m) => alt m.node { + match elt.node { + expr_mac(m) => match m.node { ast::mac_ellipsis => { if res != none { cx.span_fatal(m.span, ~"only one ellipsis allowed"); @@ -82,7 +82,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> } idx += 1u; } - return alt res { + return match res { some(val) => val, none => {pre: elts, rep: none, post: ~[]} } @@ -92,7 +92,7 @@ fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: ~[T]) -> option<~[U]> { let mut res = ~[]; for v.each |elem| { - alt f(elem) { + match f(elem) { none => return none, some(fv) => vec::push(res, fv) } @@ -101,9 +101,9 @@ fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: ~[T]) -> } fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { - alt ad { + match ad { leaf(x) => return f(x), - seq(ads, span) => alt option_flatten_map(|x| a_d_map(x, f), *ads) { + seq(ads, span) => match option_flatten_map(|x| a_d_map(x, f), *ads) { none => return none, some(ts) => return some(seq(@ts, span)) } @@ -112,7 +112,7 @@ fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { fn compose_sels(s1: selector, s2: selector) -> selector { fn scomp(s1: selector, s2: selector, m: matchable) -> match_result { - return alt s1(m) { + return match s1(m) { none => none, some(matches) => a_d_map(matches, s2) } @@ -156,11 +156,11 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { let res = box_str_hash::<arb_depth<matchable>>(); //need to do this first, to check vec lengths. for b.literal_ast_matchers.each |sel| { - alt sel(match_expr(e)) { none => return none, _ => () } + match sel(match_expr(e)) { none => return none, _ => () } } let mut never_mind: bool = false; for b.real_binders.each |key, val| { - alt val(match_expr(e)) { + match val(match_expr(e)) { none => never_mind = true, some(mtc) => { res.insert(key, mtc); } } @@ -209,7 +209,7 @@ fn follow(m: arb_depth<matchable>, idx_path: @mut ~[uint]) -> arb_depth<matchable> { let mut res: arb_depth<matchable> = m; for vec::each(*idx_path) |idx| { - res = alt res { + res = match res { leaf(_) => return res,/* end of the line */ seq(new_ms, _) => new_ms[idx] } @@ -219,10 +219,10 @@ fn follow(m: arb_depth<matchable>, idx_path: @mut ~[uint]) -> fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, idx_path: @mut ~[uint]) -> option<matchable> { - alt mmaybe { + match mmaybe { none => return none, some(m) => { - return alt follow(m, idx_path) { + return match follow(m, idx_path) { seq(_, sp) => { cx.span_fatal(sp, ~"syntax matched under ... but not " + @@ -258,10 +258,10 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], recur: fn@(&&@expr) -> @expr, exprs: ~[@expr]) -> ~[@expr] { - alt elts_to_ell(cx, exprs) { + match elts_to_ell(cx, exprs) { {pre: pre, rep: repeat_me_maybe, post: post} => { let mut res = vec::map(pre, recur); - alt repeat_me_maybe { + match repeat_me_maybe { none => (), some(repeat_me) => { let mut repeat: option<{rep_count: uint, name: ident}> = none; @@ -269,10 +269,10 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], the leaves, which are just duplicated */ do free_vars(b, repeat_me) |fv| { let cur_pos = follow(b.get(fv), idx_path); - alt cur_pos { + match cur_pos { leaf(_) => (), seq(ms, _) => { - alt repeat { + match repeat { none => { repeat = some({rep_count: vec::len(*ms), name: fv}); } @@ -290,7 +290,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], } } }; - alt repeat { + match repeat { none => { cx.span_fatal(repeat_me.span, ~"'...' surrounds an expression without any" + @@ -320,7 +320,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], // substitute, in a position that's required to be an ident fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], &&i: ident, _fld: ast_fold) -> ident { - return alt follow_for_trans(cx, b.find(i), idx_path) { + return match follow_for_trans(cx, b.find(i), idx_path) { some(match_ident(a_id)) => a_id.node, some(m) => match_error(cx, m, ~"an identifier"), none => i @@ -332,7 +332,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], p: path, _fld: ast_fold) -> path { // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { return p; } - alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) { + match follow_for_trans(cx, b.find(p.idents[0]), idx_path) { some(match_ident(id)) => { {span: id.span, global: false, idents: ~[id.node], rp: none, types: ~[]} @@ -349,13 +349,13 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span)) -> (ast::expr_, span) { - return alt e { + return match e { expr_path(p) => { // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { (e, s); } - alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) { + match follow_for_trans(cx, b.find(p.idents[0]), idx_path) { some(match_ident(id)) => { (expr_path(@{span: id.span, global: false, @@ -378,11 +378,11 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(ast::ty_, span, ast_fold) -> (ast::ty_, span)) -> (ast::ty_, span) { - return alt t { + return match t { ast::ty_path(pth, _) => { - alt path_to_ident(pth) { + match path_to_ident(pth) { some(id) => { - alt follow_for_trans(cx, b.find(id), idx_path) { + match follow_for_trans(cx, b.find(id), idx_path) { some(match_ty(ty)) => (ty.node, ty.span), some(m) => match_error(cx, m, ~"a type"), none => orig(t, s, fld) @@ -404,9 +404,9 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(blk_, span, ast_fold) -> (blk_, span)) -> (blk_, span) { - return alt block_to_ident(blk) { + return match block_to_ident(blk) { some(id) => { - alt follow_for_trans(cx, b.find(id), idx_path) { + match follow_for_trans(cx, b.find(id), idx_path) { some(match_block(new_blk)) => (new_blk.node, new_blk.span), // possibly allow promotion of ident/path/expr to blocks? @@ -424,12 +424,12 @@ argument. ps accumulates instructions on navigating the tree.*/ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { //it might be possible to traverse only exprs, not matchables - alt m { + match m { match_expr(e) => { - alt e.node { + match e.node { expr_path(p_pth) => p_t_s_r_path(cx, p_pth, s, b), expr_vec(p_elts, _) => { - alt elts_to_ell(cx, p_elts) { + match elts_to_ell(cx, p_elts) { {pre: pre, rep: some(repeat_me), post: post} => { p_t_s_r_length(cx, vec::len(pre) + vec::len(post), true, s, b); @@ -459,7 +459,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { _ => { fn select(cx: ext_ctxt, m: matchable, pat: @expr) -> match_result { - return alt m { + return match m { match_expr(e) => { if e == pat { some(leaf(match_exact)) } else { none } } @@ -477,11 +477,11 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { /* make a match more precise */ fn specialize_match(m: matchable) -> matchable { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_path(pth) => { - alt path_to_ident(pth) { + match path_to_ident(pth) { some(id) => match_ident(respan(pth.span, id)), none => match_path(pth) } @@ -495,10 +495,10 @@ fn specialize_match(m: matchable) -> matchable { /* pattern_to_selectors helper functions */ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { - alt path_to_ident(p) { + match path_to_ident(p) { some(p_id) => { fn select(cx: ext_ctxt, m: matchable) -> match_result { - return alt m { + return match m { match_expr(e) => some(leaf(specialize_match(m))), _ => cx.bug(~"broken traversal in p_t_s_r") } @@ -514,8 +514,8 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { fn block_to_ident(blk: blk_) -> option<ident> { if vec::len(blk.stmts) != 0u { return none; } - return alt blk.expr { - some(expr) => alt expr.node { + return match blk.expr { + some(expr) => match expr.node { expr_path(pth) => path_to_ident(pth), _ => none } @@ -526,8 +526,8 @@ fn block_to_ident(blk: blk_) -> option<ident> { fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) { fn select_pt_1(cx: ext_ctxt, m: matchable, fn_m: fn(ast::mac) -> match_result) -> match_result { - return alt m { - match_expr(e) => alt e.node { + return match m { + match_expr(e) => match e.node { expr_mac(mac) => fn_m(mac), _ => none } @@ -537,7 +537,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) { fn no_des(cx: ext_ctxt, sp: span, syn: ~str) -> ! { cx.span_fatal(sp, ~"destructuring " + syn + ~" is not yet supported"); } - alt mac.node { + match mac.node { ast::mac_ellipsis => cx.span_fatal(mac.span, ~"misused `...`"), ast::mac_invoc(_, _, _) => no_des(cx, mac.span, ~"macro calls"), ast::mac_invoc_tt(_, _) => no_des(cx, mac.span, ~"macro calls"), @@ -550,9 +550,9 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, b: binders) { fn select(cx: ext_ctxt, repeat_me: @expr, offset: uint, m: matchable) -> match_result { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_vec(arg_elts, _) => { let mut elts = ~[]; let mut idx = offset; @@ -580,9 +580,9 @@ fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector, b: binders) { fn len_select(_cx: ext_ctxt, m: matchable, at_least: bool, len: uint) -> match_result { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_vec(arg_elts, _) => { let actual_len = vec::len(arg_elts); if at_least && actual_len >= len || actual_len == len { @@ -604,9 +604,9 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, let mut idx: uint = 0u; while idx < vec::len(elts) { fn select(cx: ext_ctxt, m: matchable, idx: uint) -> match_result { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_vec(arg_elts, _) => { some(leaf(match_expr(arg_elts[idx]))) } @@ -629,7 +629,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let mut macro_name: option<@~str> = none; let mut clauses: ~[@clause] = ~[]; for args.each |arg| { - alt arg.node { + match arg.node { expr_vec(elts, mutbl) => { if vec::len(elts) != 2u { cx.span_fatal((*arg).span, @@ -638,12 +638,12 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, } - alt elts[0u].node { + match elts[0u].node { expr_mac(mac) => { - alt mac.node { + match mac.node { mac_invoc(pth, invoc_arg, body) => { - alt path_to_ident(pth) { - some(id) => alt macro_name { + match path_to_ident(pth) { + some(id) => match macro_name { none => macro_name = some(id), some(other_id) => if id != other_id { cx.span_fatal(pth.span, @@ -654,7 +654,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, none => cx.span_fatal(pth.span, ~"macro name must not be a path") } - let arg = alt invoc_arg { + let arg = match invoc_arg { some(arg) => arg, none => cx.span_fatal(mac.span, ~"macro must have arguments") @@ -689,7 +689,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let ext = |a,b,c,d, move clauses| generic_extension(a,b,c,d,clauses); return {ident: - alt macro_name { + match macro_name { some(id) => id, none => cx.span_fatal(sp, ~"macro definition must have " + ~"at least one clause") @@ -699,12 +699,12 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body, clauses: ~[@clause]) -> @expr { - let arg = alt arg { + let arg = match arg { some(arg) => arg, none => cx.span_fatal(sp, ~"macro must have arguments") }; for clauses.each |c| { - alt use_selectors_to_bind(c.params, arg) { + match use_selectors_to_bind(c.params, arg) { some(bindings) => return transcribe(cx, bindings, c.body), none => again } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index c55f1e67be2..3fdd5239e65 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -70,7 +70,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let res = io::read_whole_file_str(res_rel_file(cx, sp, file)); - alt res { + match res { result::ok(_) => { /* Continue. */ } result::err(e) => { cx.parse_sess().span_diagnostic.handler().fatal(e); @@ -86,7 +86,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); - alt io::read_whole_file(res_rel_file(cx, sp, file)) { + match io::read_whole_file(res_rel_file(cx, sp, file)) { result::ok(src) => { let u8_exprs = vec::map(src, |char: u8| { mk_u8(cx, sp, char) diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index 6a801f33aa6..f1c7ebb7dad 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -31,7 +31,7 @@ enum matcher_pos_up { /* to break a circularity */ } fn is_some(&&mpu: matcher_pos_up) -> bool { - alt mpu { + match mpu { matcher_pos_up(none) => false, _ => true } @@ -48,7 +48,7 @@ type matcher_pos = ~{ }; fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { - alt mpu { + match mpu { matcher_pos_up(some(mp)) => copy mp, _ => fail } @@ -56,7 +56,7 @@ fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { fn count_names(ms: &[matcher]) -> uint { vec::foldl(0u, ms, |ct, m| { - ct + alt m.node { + ct + match m.node { match_tok(_) => 0u, match_seq(more_ms, _, _, _, _) => count_names(more_ms), match_nonterminal(_,_,_) => 1u @@ -68,7 +68,7 @@ fn initial_matcher_pos(ms: ~[matcher], sep: option<token>, lo: uint) -> matcher_pos { let mut match_idx_hi = 0u; for ms.each() |elt| { - alt elt.node { + match elt.node { match_tok(_) => (), match_seq(_,_,_,_,hi) => { match_idx_hi = hi; // it is monotonic... @@ -113,7 +113,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) -> hashmap<ident,@named_match> { fn n_rec(p_s: parse_sess, m: matcher, res: ~[@named_match], ret_val: hashmap<ident, @named_match>) { - alt m { + match m { {node: match_tok(_), span: _} => (), {node: match_seq(more_ms, _, _, _, _), span: _} => { for more_ms.each() |next_m| { n_rec(p_s, next_m, res, ret_val) }; @@ -139,7 +139,7 @@ enum parse_result { fn parse_or_else(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) -> hashmap<ident, @named_match> { - alt parse(sess, cfg, rdr, ms) { + match parse(sess, cfg, rdr, ms) { success(m) => m, failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str) } @@ -202,7 +202,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) // can we go around again? // the *_t vars are workarounds for the lack of unary move - alt copy ei.sep { + match copy ei.sep { some(t) if idx == len => { // we need a separator if tok == t { //pass the separator let ei_t <- ei; @@ -220,7 +220,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) vec::push(eof_eis, ei); } } else { - alt copy ei.elts[idx].node { + match copy ei.elts[idx].node { /* need to descend into sequence */ match_seq(matchers, sep, zero_ok, match_idx_lo, match_idx_hi) => { @@ -270,7 +270,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { let nts = str::connect(vec::map(bb_eis, |ei| { - alt ei.elts[ei.idx].node { + match ei.elts[ei.idx].node { match_nonterminal(bind,name,_) => { fmt!{"%s ('%s')", *name, *bind} } @@ -293,7 +293,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE); let ei = vec::pop(bb_eis); - alt ei.elts[ei.idx].node { + match ei.elts[ei.idx].node { match_nonterminal(_, name, idx) => { ei.matches[idx].push(@matched_nonterminal( parse_nt(rust_parser, *name))); @@ -318,8 +318,8 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } fn parse_nt(p: parser, name: ~str) -> nonterminal { - alt name { - ~"item" => alt p.parse_item(~[]) { + match name { + ~"item" => match p.parse_item(~[]) { some(i) => token::nt_item(i), none => p.fatal(~"expected an item keyword") } @@ -329,7 +329,7 @@ fn parse_nt(p: parser, name: ~str) -> nonterminal { ~"expr" => token::nt_expr(p.parse_expr()), ~"ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one - ~"ident" => alt copy p.token { + ~"ident" => match copy p.token { token::IDENT(sn,b) => { p.bump(); token::nt_ident(sn,b) } _ => p.fatal(~"expected ident, found " + token::to_str(*p.reader.interner(), copy p.token)) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index b4fc1f5c484..a870928d50b 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -37,11 +37,11 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, arg_reader as reader, argument_gram); // Extract the arguments: - let lhses:~[@named_match] = alt argument_map.get(@~"lhs") { + let lhses:~[@named_match] = match argument_map.get(@~"lhs") { @matched_seq(s, sp) => s, _ => cx.span_bug(sp, ~"wrong-structured lhs") }; - let rhses:~[@named_match] = alt argument_map.get(@~"rhs") { + let rhses:~[@named_match] = match argument_map.get(@~"rhs") { @matched_seq(s, sp) => s, _ => cx.span_bug(sp, ~"wrong-structured rhs") }; @@ -58,13 +58,14 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, let itr = cx.parse_sess().interner; for lhses.eachi() |i, lhs| { // try each arm's matchers - alt lhs { + match lhs { @matched_nonterminal(nt_matchers(mtcs)) => { // `none` is because we're not interpolating let arg_rdr = new_tt_reader(s_d, itr, none, arg) as reader; - alt parse(cx.parse_sess(), cx.cfg(), arg_rdr, mtcs) { + match parse(cx.parse_sess(), cx.cfg(), arg_rdr, mtcs) { success(named_matches) => { - let rhs = alt rhses[i] { // okay, what's your transcriber? + let rhs = match rhses[i] { + // okay, what's your transcriber? @matched_nonterminal(nt_tt(@tt)) => tt, _ => cx.span_bug(sp, ~"bad thing in rhs") }; diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index c704fd351ec..693b538ec6d 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -46,7 +46,7 @@ fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, let r = @{sp_diag: sp_diag, interner: itr, mut cur: @{readme: src, mut idx: 0u, dotdotdoted: false, sep: none, up: tt_frame_up(option::none)}, - interpolations: alt interp { /* just a convienience */ + interpolations: match interp { /* just a convienience */ none => std::map::box_str_hash::<@named_match>(), some(x) => x }, @@ -61,7 +61,7 @@ fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, pure fn dup_tt_frame(&&f: tt_frame) -> tt_frame { @{readme: f.readme, mut idx: f.idx, dotdotdoted: f.dotdotdoted, - sep: f.sep, up: alt f.up { + sep: f.sep, up: match f.up { tt_frame_up(some(up_frame)) => { tt_frame_up(some(dup_tt_frame(up_frame))) } @@ -82,7 +82,7 @@ pure fn dup_tt_reader(&&r: tt_reader) -> tt_reader { pure fn lookup_cur_matched_by_matched(r: tt_reader, start: @named_match) -> @named_match { pure fn red(&&ad: @named_match, &&idx: uint) -> @named_match { - alt *ad { + match *ad { matched_nonterminal(_) => { // end of the line; duplicate henceforth ad @@ -102,10 +102,10 @@ enum lis { fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis { fn lis_merge(lhs: lis, rhs: lis) -> lis { - alt lhs { + match lhs { lis_unconstrained => rhs, lis_contradiction(_) => lhs, - lis_constraint(l_len, l_id) => alt rhs { + lis_constraint(l_len, l_id) => match rhs { lis_unconstrained => lhs, lis_contradiction(_) => rhs, lis_constraint(r_len, _) if l_len == r_len => lhs, @@ -117,13 +117,13 @@ fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis { } } } - alt t { + match t { tt_delim(tts) | tt_seq(_, tts, _, _) => { vec::foldl(lis_unconstrained, tts, {|lis, tt| lis_merge(lis, lockstep_iter_size(tt, r)) }) } tt_tok(*) => lis_unconstrained, - tt_nonterminal(_, name) => alt *lookup_cur_matched(r, name) { + tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { matched_nonterminal(_) => lis_unconstrained, matched_seq(ads, _) => lis_constraint(ads.len(), name) } @@ -138,7 +138,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { if ! r.cur.dotdotdoted || r.repeat_idx.last() == r.repeat_len.last() - 1 { - alt r.cur.up { + match r.cur.up { tt_frame_up(none) => { r.cur_tok = EOF; return ret_val; @@ -156,7 +156,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } else { /* repeat */ r.cur.idx = 0u; r.repeat_idx[r.repeat_idx.len() - 1u] += 1u; - alt r.cur.sep { + match r.cur.sep { some(tk) => { r.cur_tok = tk; /* repeat same span, I guess */ return ret_val; @@ -167,7 +167,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } loop { /* because it's easiest, this handles `tt_delim` not starting with a `tt_tok`, even though it won't happen */ - alt r.cur.readme[r.cur.idx] { + match r.cur.readme[r.cur.idx] { tt_delim(tts) => { r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: false, sep: none, up: tt_frame_up(option::some(r.cur)) }; @@ -179,7 +179,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { return ret_val; } tt_seq(sp, tts, sep, zerok) => { - alt lockstep_iter_size(tt_seq(sp, tts, sep, zerok), r) { + match lockstep_iter_size(tt_seq(sp, tts, sep, zerok), r) { lis_unconstrained => { r.sp_diag.span_fatal( sp, /* blame macro writer */ @@ -212,7 +212,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } // FIXME #2887: think about span stuff here tt_nonterminal(sp, ident) => { - alt *lookup_cur_matched(r, ident) { + match *lookup_cur_matched(r, ident) { /* sidestep the interpolation tricks for ident because (a) idents can be in lots of places, so it'd be a pain (b) we actually can, since it's a token. */ diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 71c23ff4fa6..40c676f8b80 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -80,7 +80,7 @@ type ast_fold_precursor = @{ //used in noop_fold_item and noop_fold_crate and noop_fold_crate_directive fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { return @{node: - alt mi.node { + match mi.node { meta_word(id) => meta_word(fld.fold_ident(id)), meta_list(id, mis) => { let fold_meta_item = |x|fold_meta_item_(x, fld); @@ -112,7 +112,7 @@ fn fold_arg_(a: arg, fld: ast_fold) -> arg { //used in noop_fold_expr, and possibly elsewhere in the future fn fold_mac_(m: mac, fld: ast_fold) -> mac { return {node: - alt m.node { + match m.node { mac_invoc(pth, arg, body) => { mac_invoc(fld.fold_path(pth), option::map(arg, |x| fld.fold_expr(x)), body) @@ -133,7 +133,7 @@ fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { } fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound { - alt tpb { + match tpb { bound_copy | bound_send | bound_const | bound_owned => tpb, bound_trait(ty) => bound_trait(fld.fold_ty(ty)) } @@ -163,7 +163,7 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) -> crate_directive_ { - return alt cd { + return match cd { cdir_src_mod(id, attrs) => { cdir_src_mod(fld.fold_ident(id), /* FIXME (#2543) */ copy attrs) } @@ -190,7 +190,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) return @{ident: fld.fold_ident(ni.ident), attrs: vec::map(ni.attrs, fold_attribute), node: - alt ni.node { + match ni.node { foreign_item_fn(fdec, typms) => { foreign_item_fn({inputs: vec::map(fdec.inputs, fold_arg), output: fld.fold_ty(fdec.output), @@ -216,7 +216,7 @@ fn noop_fold_item(&&i: @item, fld: ast_fold) -> option<@item> { fn noop_fold_class_item(&&ci: @class_member, fld: ast_fold) -> @class_member { - @{node: alt ci.node { + @{node: match ci.node { instance_var(ident, t, cm, id, p) => { instance_var(/* FIXME (#2543) */ copy ident, fld.fold_ty(t), cm, id, p) @@ -227,7 +227,7 @@ fn noop_fold_class_item(&&ci: @class_member, fld: ast_fold) } fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { - return alt i { + return match i { item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)), item_fn(decl, typms, body) => { item_fn(fold_fn_decl(decl, fld), @@ -244,7 +244,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { } item_class(typms, traits, items, m_ctor, m_dtor) => { let resulting_optional_constructor; - alt m_ctor { + match m_ctor { none => { resulting_optional_constructor = none; } @@ -319,7 +319,7 @@ fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { } fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { - return alt s { + return match s { stmt_decl(d, nid) => stmt_decl(fld.fold_decl(d), fld.new_id(nid)), stmt_expr(e, nid) => stmt_expr(fld.fold_expr(e), fld.new_id(nid)), stmt_semi(e, nid) => stmt_semi(fld.fold_expr(e), fld.new_id(nid)) @@ -333,7 +333,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { } fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { - return alt p { + return match p { pat_wild => pat_wild, pat_ident(binding_mode, pth, sub) => { pat_ident(binding_mode, @@ -364,9 +364,9 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { } fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ { - alt d { + match d { decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(x))), - decl_item(it) => alt fld.fold_item(it) { + decl_item(it) => match fld.fold_item(it) { some(it_folded) => decl_item(it_folded), none => decl_local(~[]) } @@ -393,7 +393,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { let fold_mac = |x| fold_mac_(x, fld); - return alt e { + return match e { expr_vstore(e, v) => { expr_vstore(fld.fold_expr(e), v) } @@ -496,7 +496,7 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { mt: fold_mt(f.node.mt, fld)}, span: fld.new_span(f.span)} } - alt t { + match t { ty_nil | ty_bot | ty_infer => copy t, ty_box(mt) => ty_box(fold_mt(mt, fld)), ty_uniq(mt) => ty_uniq(fold_mt(mt, fld)), @@ -533,7 +533,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { let fold_attribute = |x| fold_attribute_(x, fld); let attrs = vec::map(v.attrs, fold_attribute); - let de = alt v.disr_expr { + let de = match v.disr_expr { some(e) => some(fld.fold_expr(e)), none => none }; @@ -560,7 +560,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { ty: fld.fold_ty(l.ty), pat: fld.fold_pat(l.pat), init: - alt l.init { + match l.init { option::none::<initializer> => l.init, option::some::<initializer>(init) => { option::some::<initializer>({op: init.op, @@ -635,7 +635,7 @@ impl of ast_fold for ast_fold_precursor { return self.fold_item(i, self as ast_fold); } fn fold_class_item(&&ci: @class_member) -> @class_member { - @{node: alt ci.node { + @{node: match ci.node { instance_var(nm, t, mt, id, p) => { instance_var(/* FIXME (#2543) */ copy nm, (self as ast_fold).fold_ty(t), mt, id, p) diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 71e7c4a04e5..0a6df808530 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -189,7 +189,7 @@ fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: ~str, ftype: parser::file_type) -> (parser, string_reader) { let res = io::read_whole_file_str(path); - alt res { + match res { result::ok(_) => { /* Continue. */ } result::err(e) => sess.span_diagnostic.handler().fatal(e) } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 006bd3909d8..aefa7264bf6 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -29,7 +29,7 @@ impl parser_attr of parser_attr for parser { -> attr_or_ext { let expect_item_next = vec::is_not_empty(first_item_attrs); - alt self.token { + match self.token { token::POUND => { let lo = self.span.lo; if self.look_ahead(1u) == token::LBRACKET { @@ -57,7 +57,7 @@ impl parser_attr of parser_attr for parser { fn parse_outer_attributes() -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; loop { - alt copy self.token { + match copy self.token { token::POUND => { if self.look_ahead(1u) != token::LBRACKET { break; @@ -106,7 +106,7 @@ impl parser_attr of parser_attr for parser { let mut inner_attrs: ~[ast::attribute] = ~[]; let mut next_outer_attrs: ~[ast::attribute] = ~[]; loop { - alt copy self.token { + match copy self.token { token::POUND => { if self.look_ahead(1u) != token::LBRACKET { // This is an extension @@ -146,7 +146,7 @@ impl parser_attr of parser_attr for parser { fn parse_meta_item() -> @ast::meta_item { let lo = self.span.lo; let ident = self.parse_ident(); - alt self.token { + match self.token { token::EQ => { self.bump(); let lit = self.parse_lit(); @@ -172,7 +172,7 @@ impl parser_attr of parser_attr for parser { } fn parse_optional_meta() -> ~[@ast::meta_item] { - alt self.token { + match self.token { token::LPAREN => return self.parse_meta_seq(), _ => return ~[] } diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 8450ce0038d..38599907e6f 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -5,7 +5,7 @@ import ast_util::operator_prec; fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { - alt e.node { + match e.node { ast::expr_if(_, _, _) | ast::expr_alt(_, _, _) | ast::expr_block(_) | ast::expr_while(_, _) | ast::expr_loop(_) | ast::expr_call(_, _, true) => false, @@ -14,9 +14,9 @@ fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { } fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { - alt stmt.node { + match stmt.node { ast::stmt_decl(d, _) => { - return alt d.node { + return match d.node { ast::decl_local(_) => true, ast::decl_item(_) => false } @@ -31,7 +31,7 @@ fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { } fn need_parens(expr: @ast::expr, outer_prec: uint) -> bool { - alt expr.node { + match expr.node { ast::expr_binary(op, _, _) => operator_prec(op) < outer_prec, ast::expr_cast(_, _) => parse::prec::as_prec < outer_prec, // This may be too conservative in some cases @@ -47,8 +47,8 @@ fn need_parens(expr: @ast::expr, outer_prec: uint) -> bool { } fn ends_in_lit_int(ex: @ast::expr) -> bool { - alt ex.node { - ast::expr_lit(node) => alt node { + match ex.node { + ast::expr_lit(node) => match node { @{node: ast::lit_int(_, ast::ty_i), _} | @{node: ast::lit_int_unsuffixed(_), _} => true, _ => false @@ -60,7 +60,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool { ast::expr_log(_, _, sub) | ast::expr_assert(sub) => { ends_in_lit_int(sub) } - ast::expr_fail(osub) | ast::expr_ret(osub) => alt osub { + ast::expr_fail(osub) | ast::expr_ret(osub) => match osub { some(ex) => ends_in_lit_int(ex), _ => false } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 6b31b53eaa5..445e4c20eed 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -84,7 +84,7 @@ impl parser_common of parser_common for parser { } fn parse_ident() -> ast::ident { - alt copy self.token { + match copy self.token { token::IDENT(i, _) => { self.bump(); return self.get_str(i); } token::INTERPOLATED(token::nt_ident(*)) => { self.bug( ~"ident interpolation not converted to real token"); } @@ -118,7 +118,7 @@ impl parser_common of parser_common for parser { } fn token_is_word(word: ~str, ++tok: token::token) -> bool { - alt tok { + match tok { token::IDENT(sid, false) => { word == *self.get_str(sid) } _ => { false } } @@ -134,7 +134,7 @@ impl parser_common of parser_common for parser { } fn is_any_keyword(tok: token::token) -> bool { - alt tok { + match tok { token::IDENT(sid, false) => { self.keywords.contains_key_ref(self.get_str(sid)) } @@ -146,7 +146,7 @@ impl parser_common of parser_common for parser { self.require_keyword(word); let mut bump = false; - let val = alt self.token { + let val = match self.token { token::IDENT(sid, false) => { if word == *self.get_str(sid) { bump = true; @@ -173,7 +173,7 @@ impl parser_common of parser_common for parser { } fn check_restricted_keywords() { - alt self.token { + match self.token { token::IDENT(_, false) => { let w = token_to_str(self.reader, self.token); self.check_restricted_keywords_(w); @@ -209,7 +209,7 @@ impl parser_common of parser_common for parser { let mut v = ~[]; while self.token != token::GT && self.token != token::BINOP(token::SHR) { - alt sep { + match sep { some(t) => { if first { first = false; } else { self.expect(t); } @@ -253,7 +253,7 @@ impl parser_common of parser_common for parser { let mut first: bool = true; let mut v: ~[T] = ~[]; while self.token != ket { - alt sep.sep { + match sep.sep { some(t) => { if first { first = false; } else { self.expect(t); } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 154e653e890..6b0112922a5 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -47,7 +47,7 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) -> (~[@ast::view_item], ~[@ast::item], ~[ast::attribute]) { fn companion_file(+prefix: ~str, suffix: option<~str>) -> ~str { - return alt suffix { + return match suffix { option::some(s) => path::connect(prefix, s), option::none => prefix } + ~".rs"; @@ -56,7 +56,7 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) fn file_exists(path: ~str) -> bool { // Crude, but there's no lib function for this and I'm not // up to writing it just now - alt io::file_reader(path) { + match io::file_reader(path) { result::ok(_) => true, result::err(_) => false } @@ -79,7 +79,7 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) } fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str { - alt ::attr::first_attr_value_str_by_name(attrs, ~"path") { + match ::attr::first_attr_value_str_by_name(attrs, ~"path") { some(d) => return d, none => return id } @@ -88,7 +88,7 @@ fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str { fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: ~str, &view_items: ~[@ast::view_item], &items: ~[@ast::item]) { - alt cdir.node { + match cdir.node { ast::cdir_src_mod(id, attrs) => { let file_path = cdir_path_opt(@(*id + ~".rs"), attrs); let full_path = diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index bc5aba5283c..e9bfbc753f7 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -206,7 +206,7 @@ fn consume_whitespace_and_comments(rdr: string_reader) fn consume_any_line_comment(rdr: string_reader) -> option<{tok: token::token, sp: span}> { if rdr.curr == '/' { - alt nextch(rdr) { + match nextch(rdr) { '/' => { bump(rdr); bump(rdr); @@ -313,7 +313,7 @@ fn scan_digits(rdr: string_reader, radix: uint) -> ~str { loop { let c = rdr.curr; if c == '_' { bump(rdr); again; } - alt char::to_digit(c, radix) { + match char::to_digit(c, radix) { some(d) => { str::push_char(rslt, c); bump(rdr); @@ -371,7 +371,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { rdr.fatal(~"no valid digits found for number"); } let parsed = option::get(u64::from_str_radix(num_str, base as u64)); - alt tp { + match tp { either::left(t) => return token::LIT_INT(parsed as i64, t), either::right(t) => return token::LIT_UINT(parsed, t) } @@ -383,7 +383,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { let dec_part = scan_digits(rdr, 10u); num_str += ~"." + dec_part; } - alt scan_exponent(rdr) { + match scan_exponent(rdr) { some(s) => { is_float = true; num_str += s; @@ -472,7 +472,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { return token::BINOPEQ(op); } else { return token::BINOP(op); } } - alt c { + match c { @@ -539,12 +539,12 @@ fn next_token_inner(rdr: string_reader) -> token::token { } '<' => { bump(rdr); - alt rdr.curr { + match rdr.curr { '=' => { bump(rdr); return token::LE; } '<' => { return binop(rdr, token::SHL); } '-' => { bump(rdr); - alt rdr.curr { + match rdr.curr { '>' => { bump(rdr); return token::DARROW; } _ => { return token::LARROW; } } @@ -554,7 +554,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { } '>' => { bump(rdr); - alt rdr.curr { + match rdr.curr { '=' => { bump(rdr); return token::GE; } '>' => { return binop(rdr, token::SHR); } _ => { return token::GT; } @@ -567,7 +567,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { if c2 == '\\' { let escaped = rdr.curr; bump(rdr); - alt escaped { + match escaped { 'n' => { c2 = '\n'; } 'r' => { c2 = '\r'; } 't' => { c2 = '\t'; } @@ -599,11 +599,11 @@ fn next_token_inner(rdr: string_reader) -> token::token { let ch = rdr.curr; bump(rdr); - alt ch { + match ch { '\\' => { let escaped = rdr.curr; bump(rdr); - alt escaped { + match escaped { 'n' => str::push_char(accum_str, '\n'), 'r' => str::push_char(accum_str, '\r'), 't' => str::push_char(accum_str, '\t'), @@ -646,7 +646,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { } else { return binop(rdr, token::AND); } } '|' => { - alt nextch(rdr) { + match nextch(rdr) { '|' => { bump(rdr); bump(rdr); return token::OROR; } _ => { return binop(rdr, token::OR); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4a34b667937..7684c66c364 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -107,7 +107,7 @@ type item_info = (ident, item_, option<~[attribute]>); The important thing is to make sure that lookahead doesn't balk at INTERPOLATED tokens */ macro_rules! maybe_whole_expr { - {$p:expr} => { alt copy $p.token { + {$p:expr} => { match copy $p.token { INTERPOLATED(token::nt_expr(e)) => { $p.bump(); return pexpr(e); @@ -122,19 +122,19 @@ macro_rules! maybe_whole_expr { } macro_rules! maybe_whole { - {$p:expr, $constructor:ident} => { alt copy $p.token { + {$p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return x; } _ => () }} ; - {deref $p:expr, $constructor:ident} => { alt copy $p.token { + {deref $p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; } _ => () }} ; - {some $p:expr, $constructor:ident} => { alt copy $p.token { + {some $p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return some(x); } _ => () }} ; - {pair_empty $p:expr, $constructor:ident} => { alt copy $p.token { + {pair_empty $p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return (~[], x); } _ => () }} @@ -284,7 +284,7 @@ class parser { debug!{"parse_trait_methods(): trait method signature ends in \ `%s`", token_to_str(p.reader, p.token)}; - alt p.token { + match p.token { token::SEMI => { p.bump(); debug!{"parse_trait_methods(): parsing required method"}; @@ -356,7 +356,7 @@ class parser { } fn region_from_name(s: option<@~str>) -> @region { - let r = alt s { + let r = match s { some (string) => re_named(string), none => re_anon }; @@ -368,7 +368,7 @@ class parser { fn parse_region() -> @region { self.expect(token::BINOP(token::AND)); - alt copy self.token { + match copy self.token { token::IDENT(sid, _) => { self.bump(); let n = self.get_str(sid); @@ -383,7 +383,7 @@ class parser { // Parses something like "&x/" (note the trailing slash) fn parse_region_with_sep() -> @region { let name = - alt copy self.token { + match copy self.token { token::IDENT(sid, _) => { if self.look_ahead(1u) == token::BINOP(token::SLASH) { self.bump(); self.bump(); @@ -402,7 +402,7 @@ class parser { let lo = self.span.lo; - alt self.maybe_parse_dollar_mac() { + match self.maybe_parse_dollar_mac() { some(e) => { return @{id: self.get_id(), node: ty_mac(spanned(lo, self.span.hi, e)), @@ -471,7 +471,7 @@ class parser { let sp = mk_sp(lo, self.last_span.hi); return @{id: self.get_id(), - node: alt self.maybe_parse_fixed_vstore() { + node: match self.maybe_parse_fixed_vstore() { // Consider a fixed vstore suffix (/N or /_) none => t, some(v) => { @@ -542,11 +542,11 @@ class parser { } fn maybe_parse_dollar_mac() -> option<mac_> { - alt copy self.token { + match copy self.token { token::DOLLAR => { let lo = self.span.lo; self.bump(); - alt copy self.token { + match copy self.token { token::LIT_INT_UNSUFFIXED(num) => { self.bump(); some(mac_var(num as uint)) @@ -570,7 +570,7 @@ class parser { fn maybe_parse_fixed_vstore() -> option<option<uint>> { if self.token == token::BINOP(token::SLASH) { self.bump(); - alt copy self.token { + match copy self.token { token::UNDERSCORE => { self.bump(); some(none) } @@ -585,7 +585,7 @@ class parser { } fn lit_from_token(tok: token::token) -> lit_ { - alt tok { + match tok { token::LIT_INT(i, it) => lit_int(i, it), token::LIT_UINT(u, ut) => lit_uint(u, ut), token::LIT_INT_UNSUFFIXED(i) => lit_int_unsuffixed(i), @@ -733,7 +733,7 @@ class parser { } fn to_expr(e: pexpr) -> @expr { - alt e.node { + match e.node { expr_tup(es) if vec::len(es) == 1u => es[0u], _ => *e } @@ -746,7 +746,7 @@ class parser { let mut ex: expr_; - alt self.maybe_parse_dollar_mac() { + match self.maybe_parse_dollar_mac() { some(x) => return pexpr(self.mk_mac_expr(lo, self.span.hi, x)), _ => () } @@ -794,11 +794,11 @@ class parser { return pexpr(self.parse_while_expr()); } else if self.eat_keyword(~"loop") { return pexpr(self.parse_loop_expr()); - } else if self.eat_keyword(~"alt") || self.eat_keyword(~"match") { + } else if self.eat_keyword(~"match") { return pexpr(self.parse_alt_expr()); } else if self.eat_keyword(~"fn") { let proto = self.parse_fn_ty_proto(); - alt proto { + match proto { proto_bare => self.fatal(~"fn expr are deprecated, use fn@"), _ => { /* fallthrough */ } } @@ -893,7 +893,7 @@ class parser { /* `!`, as an operator, is prefix, so we know this isn't that */ if self.token == token::NOT { self.bump(); - let tts = alt self.token { + let tts = match self.token { token::LPAREN | token::LBRACE | token::LBRACKET => { let ket = token::flip_delimiter(self.token); self.parse_unspanned_seq(copy self.token, ket, @@ -948,9 +948,9 @@ class parser { // Vstore is legal following expr_lit(lit_str(...)) and expr_vec(...) // only. - alt ex { + match ex { expr_lit(@{node: lit_str(_), span: _}) | - expr_vec(_, _) => alt self.maybe_parse_fixed_vstore() { + expr_vec(_, _) => match self.maybe_parse_fixed_vstore() { none => (), some(v) => { hi = self.span.hi; @@ -976,7 +976,7 @@ class parser { } fn parse_syntax_ext_naked(lo: uint) -> @expr { - alt self.token { + match self.token { token::IDENT(_, _) => (), _ => self.fatal(~"expected a syntax expander name") } @@ -1003,7 +1003,7 @@ class parser { let lo = self.span.lo; let mut depth = 1u; while (depth > 0u) { - alt (self.token) { + match (self.token) { token::LBRACE => depth += 1u, token::RBRACE => depth -= 1u, token::EOF => self.fatal(~"unexpected EOF in macro body"), @@ -1033,7 +1033,7 @@ class parser { loop { // expr.f if self.eat(token::DOT) { - alt copy self.token { + match copy self.token { token::IDENT(i, _) => { hi = self.span.hi; self.bump(); @@ -1051,7 +1051,7 @@ class parser { again; } if self.expr_is_complete(e) { break; } - alt copy self.token { + match copy self.token { // expr(...) token::LPAREN if self.permits_call() => { let es = self.parse_unspanned_seq( @@ -1103,7 +1103,7 @@ class parser { maybe_whole!{deref self, nt_tt}; fn parse_tt_tok(p: parser, delim_ok: bool) -> token_tree { - alt p.token { + match p.token { token::RPAREN | token::RBRACE | token::RBRACKET if !delim_ok => { p.fatal(~"incorrect close delimiter: `" @@ -1134,7 +1134,7 @@ class parser { return res; } - return alt self.token { + return match self.token { token::LPAREN | token::LBRACE | token::LBRACKET => { let ket = token::flip_delimiter(self.token); tt_delim(vec::append( @@ -1154,7 +1154,7 @@ class parser { // the interpolation of matchers maybe_whole!{self, nt_matchers}; let name_idx = @mut 0u; - return alt self.token { + return match self.token { token::LBRACE | token::LPAREN | token::LBRACKET => { self.parse_matcher_subseq(name_idx, copy self.token, token::flip_delimiter(self.token)) @@ -1222,7 +1222,7 @@ class parser { let mut hi; let mut ex; - alt copy self.token { + match copy self.token { token::NOT => { self.bump(); let e = self.to_expr(self.parse_prefix_expr()); @@ -1231,7 +1231,7 @@ class parser { ex = expr_unary(not, e); } token::BINOP(b) => { - alt b { + match b { token::MINUS => { self.bump(); let e = self.to_expr(self.parse_prefix_expr()); @@ -1251,7 +1251,7 @@ class parser { let e = self.to_expr(self.parse_prefix_expr()); hi = e.span.hi; // HACK: turn &[...] into a &-evec - ex = alt e.node { + ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => { expr_vstore(e, vstore_slice(self.region_from_name(none))) @@ -1268,7 +1268,7 @@ class parser { let e = self.to_expr(self.parse_prefix_expr()); hi = e.span.hi; // HACK: turn @[...] into a @-evec - ex = alt e.node { + ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => expr_vstore(e, vstore_box), _ => expr_unary(box(m), e) @@ -1280,7 +1280,7 @@ class parser { let e = self.to_expr(self.parse_prefix_expr()); hi = e.span.hi; // HACK: turn ~[...] into a ~-evec - ex = alt e.node { + ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => expr_vstore(e, vstore_uniq), _ => expr_unary(uniq(m), e) @@ -1311,7 +1311,7 @@ class parser { return lhs; } let cur_opt = token_to_binop(peeked); - alt cur_opt { + match cur_opt { some(cur_op) => { let cur_prec = operator_prec(cur_op); if cur_prec > min_prec { @@ -1338,7 +1338,7 @@ class parser { fn parse_assign_expr() -> @expr { let lo = self.span.lo; let lhs = self.parse_binops(); - alt copy self.token { + match copy self.token { token::EQ => { self.bump(); let rhs = self.parse_expr(); @@ -1348,7 +1348,7 @@ class parser { self.bump(); let rhs = self.parse_expr(); let mut aop; - alt op { + match op { token::PLUS => aop = add, token::MINUS => aop = subtract, token::STAR => aop = mul, @@ -1412,7 +1412,7 @@ class parser { fn parse_lambda_block_expr() -> @expr { self.parse_lambda_expr_( || { - alt self.token { + match self.token { token::BINOP(token::OR) | token::OROR => { self.parse_fn_block_decl() } @@ -1481,7 +1481,7 @@ class parser { // Turn on the restriction to stop at | or || so we can parse // them as the lambda arguments let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP); - alt e.node { + match e.node { expr_call(f, args, false) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, @@ -1608,7 +1608,7 @@ class parser { } fn parse_initializer() -> option<initializer> { - alt self.token { + match self.token { token::EQ => { self.bump(); return some({op: init_assign, expr: self.parse_expr()}); @@ -1645,14 +1645,14 @@ class parser { let lo = self.span.lo; let mut hi = self.span.hi; let mut pat; - alt self.token { + match self.token { token::UNDERSCORE => { self.bump(); pat = pat_wild; } token::AT => { self.bump(); let sub = self.parse_pat(refutable); hi = sub.span.hi; // HACK: parse @"..." as a literal of a vstore @str - pat = alt sub.node { + pat = match sub.node { pat_lit(e@@{ node: expr_lit(@{node: lit_str(_), span: _}), _ }) => { @@ -1669,7 +1669,7 @@ class parser { let sub = self.parse_pat(refutable); hi = sub.span.hi; // HACK: parse ~"..." as a literal of a vstore ~str - pat = alt sub.node { + pat = match sub.node { pat_lit(e@@{ node: expr_lit(@{node: lit_str(_), span: _}), _ }) => { @@ -1775,7 +1775,7 @@ class parser { } if is_plain_ident(self.token) && - alt self.look_ahead(1) { + match self.look_ahead(1) { token::LPAREN | token::LBRACKET | token::LT => { false } @@ -1794,8 +1794,8 @@ class parser { hi = enum_path.span.hi; let mut args: ~[@pat] = ~[]; let mut star_pat = false; - alt self.token { - token::LPAREN => alt self.look_ahead(1u) { + match self.token { + token::LPAREN => match self.look_ahead(1u) { token::BINOP(token::STAR) => { // This is a "top constructor only" pat self.bump(); self.bump(); @@ -1890,7 +1890,7 @@ class parser { return @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id())); } else { let mut item_attrs; - alt self.parse_outer_attrs_or_ext(first_item_attrs) { + match self.parse_outer_attrs_or_ext(first_item_attrs) { none => item_attrs = ~[], some(left(attrs)) => item_attrs = attrs, some(right(ext)) => { @@ -1901,7 +1901,7 @@ class parser { let item_attrs = vec::append(first_item_attrs, item_attrs); - alt self.parse_item(item_attrs) { + match self.parse_item(item_attrs) { some(i) => { let mut hi = i.span.hi; let decl = @spanned(lo, hi, decl_item(i)); @@ -1993,16 +1993,16 @@ class parser { } while self.token != token::RBRACE { - alt self.token { + match self.token { token::SEMI => { self.bump(); // empty } _ => { let stmt = self.parse_stmt(initial_attrs); initial_attrs = ~[]; - alt stmt.node { + match stmt.node { stmt_expr(e, stmt_id) => { // Expression without semicolon: - alt self.token { + match self.token { token::SEMI => { self.bump(); push(stmts, @@ -2086,7 +2086,7 @@ class parser { } fn is_self_ident() -> bool { - alt self.token { + match self.token { token::IDENT(sid, false) if ~"self" == *self.get_str(sid) => true, _ => false } @@ -2111,7 +2111,7 @@ class parser { // backwards compatible. let lo = self.span.lo; let self_ty; - alt copy self.token { + match copy self.token { token::BINOP(token::AND) => { // We need to make sure it isn't a mode. self.bump(); @@ -2126,10 +2126,10 @@ class parser { // Parse an explicit region, if possible. let region_name; - alt copy self.token { + match copy self.token { token::BINOP(token::SLASH) => { self.bump(); - alt copy self.token { + match copy self.token { token::IDENT(sid, false) => { self.bump(); region_name = some(self.get_str(sid)); @@ -2174,7 +2174,7 @@ class parser { // If we parsed a self type, expect a comma before the argument list. let args_or_capture_items; if self_ty != sty_by_ref { - alt copy self.token { + match copy self.token { token::COMMA => { self.bump(); let sep = seq_sep_trailing_disallowed(token::COMMA); @@ -2265,7 +2265,7 @@ class parser { } fn parse_method_name() -> ident { - alt copy self.token { + match copy self.token { token::BINOP(op) => { self.bump(); @token::binop_to_str(op) } token::NOT => { self.bump(); @~"!" } token::LBRACKET => { @@ -2387,7 +2387,7 @@ class parser { } else { traits = ~[]; }; - ident = alt ident_old { + ident = match ident_old { some(name) => name, none => { self.expect_keyword(~"of"); fail; } }; @@ -2445,7 +2445,7 @@ class parser { codemap::span)> = none; let mut the_dtor : option<(blk, ~[attribute], codemap::span)> = none; while self.token != token::RBRACE { - alt self.parse_class_item(class_path) { + match self.parse_class_item(class_path) { ctor_decl(a_fn_decl, attrs, blk, s) => { the_ctor = some((a_fn_decl, attrs, blk, s)); } @@ -2463,7 +2463,7 @@ class parser { body: d_body}, span: d_s}}; self.bump(); - alt the_ctor { + match the_ctor { some((ct_d, ct_attrs, ct_b, ct_s)) => { (class_name, item_class(ty_params, traits, ms, some({ @@ -2487,7 +2487,7 @@ class parser { } fn token_is_pound_or_doc_comment(++tok: token::token) -> bool { - alt tok { + match tok { token::POUND | token::DOC_COMMENT(_) => true, _ => false } @@ -2582,7 +2582,7 @@ class parser { first = false; } debug!{"parse_mod_items: parse_item(attrs=%?)", attrs}; - alt self.parse_item(attrs) { + match self.parse_item(attrs) { some(i) => vec::push(items, i), _ => { self.fatal(~"expected item but found `" + @@ -2764,7 +2764,7 @@ class parser { } fn parse_fn_ty_proto() -> proto { - alt self.token { + match self.token { token::AT => { self.bump(); proto_box @@ -2784,7 +2784,7 @@ class parser { } fn fn_expr_lookahead(tok: token::token) -> bool { - alt tok { + match tok { token::LPAREN | token::AT | token::TILDE | token::BINOP(_) => true, _ => false } @@ -2846,7 +2846,7 @@ class parser { let pth = self.parse_path_without_tps(); self.expect(token::NOT); let id = self.parse_ident(); - let tts = alt self.token { + let tts = match self.token { token::LPAREN | token::LBRACE | token::LBRACKET => { let ket = token::flip_delimiter(self.token); self.parse_unspanned_seq(copy self.token, ket, @@ -2863,7 +2863,7 @@ class parser { (id, item_mac(m), none) } else { return none; }; some(self.mk_item(lo, self.last_span.hi, ident, item_, visibility, - alt extra_attrs { + match extra_attrs { some(as) => vec::append(attrs, as), none => attrs })) @@ -2880,7 +2880,7 @@ class parser { let first_ident = self.parse_ident(); let mut path = ~[first_ident]; debug!{"parsed view_path: %s", *first_ident}; - alt self.token { + match self.token { token::EQ => { // x = foo::bar self.bump(); @@ -2901,7 +2901,7 @@ class parser { while self.token == token::MOD_SEP { self.bump(); - alt copy self.token { + match copy self.token { token::IDENT(i, _) => { self.bump(); @@ -3004,7 +3004,7 @@ class parser { } fn parse_str() -> @~str { - alt copy self.token { + match copy self.token { token::LIT_STR(s) => { self.bump(); self.get_str(s) } _ => self.fatal(~"expected string literal") } @@ -3035,7 +3035,7 @@ class parser { self.expect_keyword(~"module"); } let id = self.parse_ident(); - alt self.token { + match self.token { // mod x = "foo.rs"; token::SEMI => { let mut hi = self.span.hi; diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs index 45bbe3b8e3b..bd9ada9a338 100644 --- a/src/libsyntax/parse/prec.rs +++ b/src/libsyntax/parse/prec.rs @@ -20,7 +20,7 @@ const as_prec: uint = 11u; * operator and its precedence */ fn token_to_binop(tok: token) -> option<ast::binop> { - alt tok { + match tok { BINOP(STAR) => some(mul), BINOP(SLASH) => some(div), BINOP(PERCENT) => some(rem), diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 9e9a3bbca56..a99d071b6ef 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -102,7 +102,7 @@ enum nonterminal { } fn binop_to_str(o: binop) -> ~str { - alt o { + match o { PLUS => ~"+", MINUS => ~"-", STAR => ~"*", @@ -117,7 +117,7 @@ fn binop_to_str(o: binop) -> ~str { } fn to_str(in: interner<@~str>, t: token) -> ~str { - alt t { + match t { EQ => ~"=", LT => ~"<", LE => ~"<=", @@ -186,7 +186,7 @@ fn to_str(in: interner<@~str>, t: token) -> ~str { EOF => ~"<eof>", INTERPOLATED(nt) => { ~"an interpolated " + - alt nt { + match nt { nt_item(*) => ~"item", nt_block(*) => ~"block", nt_stmt(*) => ~"statement", @@ -203,7 +203,7 @@ fn to_str(in: interner<@~str>, t: token) -> ~str { } pure fn can_begin_expr(t: token) -> bool { - alt t { + match t { LPAREN => true, LBRACE => true, LBRACKET => true, @@ -234,7 +234,7 @@ pure fn can_begin_expr(t: token) -> bool { /// what's the opposite delimiter? fn flip_delimiter(&t: token::token) -> token::token { - alt t { + match t { token::LPAREN => token::RPAREN, token::LBRACE => token::RBRACE, token::LBRACKET => token::RBRACKET, @@ -248,7 +248,7 @@ fn flip_delimiter(&t: token::token) -> token::token { fn is_lit(t: token) -> bool { - alt t { + match t { LIT_INT(_, _) => true, LIT_UINT(_, _) => true, LIT_INT_UNSUFFIXED(_) => true, @@ -259,22 +259,22 @@ fn is_lit(t: token) -> bool { } pure fn is_ident(t: token) -> bool { - alt t { IDENT(_, _) => true, _ => false } + match t { IDENT(_, _) => true, _ => false } } pure fn is_ident_or_path(t: token) -> bool { - alt t { + match t { IDENT(_, _) | INTERPOLATED(nt_path(*)) => true, _ => false } } pure fn is_plain_ident(t: token) -> bool { - alt t { IDENT(_, false) => true, _ => false } + match t { IDENT(_, false) => true, _ => false } } pure fn is_bar(t: token) -> bool { - alt t { BINOP(OR) | OROR => true, _ => false } + match t { BINOP(OR) | OROR => true, _ => false } } /** @@ -333,7 +333,7 @@ fn contextual_keyword_table() -> hashmap<~str, ()> { fn restricted_keyword_table() -> hashmap<~str, ()> { let words = str_hash(); let keys = ~[ - ~"alt", ~"again", ~"assert", + ~"again", ~"assert", ~"break", ~"check", ~"class", ~"const", ~"copy", ~"do", ~"drop", diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 12ef7149f6b..a8f9cf756a8 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -62,7 +62,7 @@ type begin_t = {offset: int, breaks: breaks}; enum token { STRING(@~str, int), BREAK(break_t), BEGIN(begin_t), END, EOF, } fn tok_str(++t: token) -> ~str { - alt t { + match t { STRING(s, len) => return fmt!{"STR(%s,%d)", *s, len}, BREAK(_) => return ~"BREAK", BEGIN(_) => return ~"BEGIN", @@ -238,7 +238,7 @@ impl printer for printer { fn replace_last_token(t: token) { self.token[self.right] = t; } fn pretty_print(t: token) { debug!{"pp ~[%u,%u]", self.left, self.right}; - alt t { + match t { EOF => { if !self.scan_stack_empty { self.check_stack(0); @@ -357,7 +357,7 @@ impl printer for printer { self.left, L}; if L >= 0 { self.print(x, L); - alt x { + match x { BREAK(b) => self.left_total += b.blank_space, STRING(_, len) => { assert (len == L); self.left_total += len; } _ => () @@ -373,7 +373,7 @@ impl printer for printer { fn check_stack(k: int) { if !self.scan_stack_empty { let x = self.scan_top(); - alt copy self.token[x] { + match copy self.token[x] { BEGIN(b) => { if k > 0 { self.size[self.scan_pop()] = self.size[x] + @@ -422,7 +422,7 @@ impl printer for printer { debug!{"print %s %d (remaining line space=%d)", tok_str(x), L, self.space}; log(debug, buf_str(self.token, self.size, self.left, self.right, 6u)); - alt x { + match x { BEGIN(b) => { if L > self.space { let col = self.margin - self.space + b.offset; @@ -442,7 +442,7 @@ impl printer for printer { } BREAK(b) => { let top = self.get_top(); - alt top.pbreak { + match top.pbreak { fits => { debug!{"print BREAK in fitting block"}; self.space -= b.blank_space; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index eca571b9ccd..e968fb92ad6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -222,11 +222,11 @@ fn bclose_(s: ps, span: codemap::span, indented: uint) { fn bclose(s: ps, span: codemap::span) { bclose_(s, span, indent_unit); } fn is_begin(s: ps) -> bool { - alt s.s.last_token() { pp::BEGIN(_) => true, _ => false } + match s.s.last_token() { pp::BEGIN(_) => true, _ => false } } fn is_end(s: ps) -> bool { - alt s.s.last_token() { pp::END => true, _ => false } + match s.s.last_token() { pp::END => true, _ => false } } fn is_bol(s: ps) -> bool { @@ -318,7 +318,7 @@ fn print_foreign_mod(s: ps, nmod: ast::foreign_mod, } fn print_region(s: ps, region: @ast::region) { - alt region.node { + match region.node { ast::re_anon => word_space(s, ~"&"), ast::re_named(name) => { word(s.s, ~"&"); @@ -334,14 +334,14 @@ fn print_type(s: ps, &&ty: @ast::ty) { fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { maybe_print_comment(s, ty.span.lo); ibox(s, 0u); - alt ty.node { + match ty.node { ast::ty_nil => word(s.s, ~"()"), ast::ty_bot => word(s.s, ~"!"), ast::ty_box(mt) => { word(s.s, ~"@"); print_mt(s, mt); } ast::ty_uniq(mt) => { word(s.s, ~"~"); print_mt(s, mt); } ast::ty_vec(mt) => { word(s.s, ~"["); - alt mt.mutbl { + match mt.mutbl { ast::m_mutbl => word_space(s, ~"mut"), ast::m_const => word_space(s, ~"const"), ast::m_imm => () @@ -351,7 +351,7 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { } ast::ty_ptr(mt) => { word(s.s, ~"*"); print_mt(s, mt); } ast::ty_rptr(region, mt) => { - alt region.node { + match region.node { ast::re_anon => word(s.s, ~"&"), _ => { print_region(s, region); word(s.s, ~"/"); } } @@ -400,7 +400,7 @@ fn print_foreign_item(s: ps, item: @ast::foreign_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); - alt item.node { + match item.node { ast::foreign_item_fn(decl, typarams) => { print_fn(s, decl, item.ident, typarams); end(s); // end head-ibox @@ -416,7 +416,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_outer_attributes(s, item.attrs); let ann_node = node_item(s, item); s.ann.pre(ann_node); - alt item.node { + match item.node { ast::item_const(ty, expr) => { head(s, ~"const"); word_space(s, *item.ident + ~":"); @@ -538,7 +538,7 @@ fn print_item(s: ps, &&item: @ast::item) { hardbreak_if_not_bol(s); maybe_print_comment(s, ci.span.lo); let pr = ast_util::class_member_visibility(ci); - alt pr { + match pr { ast::private => { head(s, ~"priv"); bopen(s); @@ -546,10 +546,10 @@ fn print_item(s: ps, &&item: @ast::item) { } _ => () } - alt ci.node { + match ci.node { ast::instance_var(nm, t, mt, _,_) => { word_nbsp(s, ~"let"); - alt mt { + match mt { ast::class_mutable => word_nbsp(s, ~"mut"), _ => () } @@ -562,7 +562,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_method(s, m); } } - alt pr { + match pr { ast::private => bclose(s, ci.span), _ => () } @@ -625,10 +625,10 @@ fn print_item(s: ps, &&item: @ast::item) { /// and then pretty-print the resulting AST nodes (so, e.g., we print /// expression arguments as expressions). It can be done! I think. fn print_tt(s: ps, tt: ast::token_tree) { - alt tt { + match tt { ast::tt_delim(tts) => for tts.each() |tt_elt| { print_tt(s, tt_elt); } ast::tt_tok(_, tk) => { - alt tk { + match tk { parse::token::IDENT(*) => { // don't let idents run together if s.s.token_tree_last_was_ident { word(s.s, ~" ") } s.s.token_tree_last_was_ident = true; @@ -641,7 +641,7 @@ fn print_tt(s: ps, tt: ast::token_tree) { word(s.s, ~"$("); for tts.each() |tt_elt| { print_tt(s, tt_elt); } word(s.s, ~")"); - alt sep { + match sep { some(tk) => word(s.s, parse::token::to_str(*s.intr, tk)), none => () } @@ -665,7 +665,7 @@ fn print_variant(s: ps, v: ast::variant) { commasep(s, consistent, v.node.args, print_variant_arg); pclose(s); } - alt v.node.disr_expr { + match v.node.disr_expr { some(d) => { space(s.s); word_space(s, ~"="); @@ -684,7 +684,7 @@ fn print_ty_method(s: ps, m: ast::ty_method) { } fn print_trait_method(s: ps, m: ast::trait_method) { - alt m { + match m { required(ty_m) => print_ty_method(s, ty_m), provided(m) => print_method(s, m) } @@ -702,7 +702,7 @@ fn print_method(s: ps, meth: @ast::method) { fn print_outer_attributes(s: ps, attrs: ~[ast::attribute]) { let mut count = 0; for attrs.each |attr| { - alt attr.node.style { + match attr.node.style { ast::attr_outer => { print_attribute(s, attr); count += 1; } _ => {/* fallthrough */ } } @@ -713,7 +713,7 @@ fn print_outer_attributes(s: ps, attrs: ~[ast::attribute]) { fn print_inner_attributes(s: ps, attrs: ~[ast::attribute]) { let mut count = 0; for attrs.each |attr| { - alt attr.node.style { + match attr.node.style { ast::attr_inner => { print_attribute(s, attr); if !attr.node.is_sugared_doc { @@ -744,7 +744,7 @@ fn print_attribute(s: ps, attr: ast::attribute) { fn print_stmt(s: ps, st: ast::stmt) { maybe_print_comment(s, st.span.lo); - alt st.node { + match st.node { ast::stmt_decl(decl, _) => { print_decl(s, decl); } @@ -780,7 +780,7 @@ fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type, fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, indented: uint, attrs: ~[ast::attribute]) { - alt blk.node.rules { + match blk.node.rules { ast::unchecked_blk => word(s.s, ~"unchecked"), ast::unsafe_blk => word(s.s, ~"unsafe"), ast::default_blk => () @@ -788,7 +788,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, maybe_print_comment(s, blk.span.lo); let ann_node = node_block(s, blk); s.ann.pre(ann_node); - alt embedded { + match embedded { block_block_fn => end(s), block_normal => bopen(s) } @@ -799,7 +799,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, for blk.node.stmts.each |st| { print_stmt(s, *st); } - alt blk.node.expr { + match blk.node.expr { some(expr) => { space_if_not_bol(s); print_expr(s, expr); @@ -814,7 +814,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, // return and fail, without arguments cannot appear is the discriminant of if, // alt, do, & while unambiguously without being parenthesized fn print_maybe_parens_discrim(s: ps, e: @ast::expr) { - let disambig = alt e.node { + let disambig = match e.node { ast::expr_ret(none) | ast::expr_fail(none) => true, _ => false }; @@ -831,9 +831,9 @@ fn print_if(s: ps, test: @ast::expr, blk: ast::blk, space(s.s); print_block(s, blk); fn do_else(s: ps, els: option<@ast::expr>) { - alt els { + match els { some(_else) => { - alt _else.node { + match _else.node { // "another else-if" ast::expr_if(i, t, e) => { cbox(s, indent_unit - 1u); @@ -864,11 +864,11 @@ fn print_if(s: ps, test: @ast::expr, blk: ast::blk, } fn print_mac(s: ps, m: ast::mac) { - alt m.node { + match m.node { ast::mac_invoc(path, arg, body) => { word(s.s, ~"#"); print_path(s, path, false); - alt arg { + match arg { some(@{node: ast::expr_vec(_, _), _}) => (), _ => word(s.s, ~" ") } @@ -888,12 +888,12 @@ fn print_mac(s: ps, m: ast::mac) { } fn print_vstore(s: ps, t: ast::vstore) { - alt t { + match t { ast::vstore_fixed(some(i)) => word(s.s, fmt!{"%u", i}), ast::vstore_fixed(none) => word(s.s, ~"_"), ast::vstore_uniq => word(s.s, ~"~"), ast::vstore_box => word(s.s, ~"@"), - ast::vstore_slice(r) => alt r.node { + ast::vstore_slice(r) => match r.node { ast::re_anon => word(s.s, ~"&"), ast::re_named(name) => { word(s.s, ~"&"); @@ -919,8 +919,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ibox(s, indent_unit); let ann_node = node_expr(s, expr); s.ann.pre(ann_node); - alt expr.node { - ast::expr_vstore(e, v) => alt v { + match expr.node { + ast::expr_vstore(e, v) => match v { ast::vstore_fixed(_) => { print_expr(s, e); word(s.s, ~"/"); @@ -961,7 +961,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_rec(fields, wth) => { word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); - alt wth { + match wth { some(expr) => { if vec::len(fields) > 0u { space(s.s); } ibox(s, indent_unit); @@ -977,7 +977,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_path(s, path, true); word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); - alt wth { + match wth { some(expr) => { if vec::len(fields) > 0u { space(s.s); } ibox(s, indent_unit); @@ -998,7 +998,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { let mut base_args = args; let blk = if has_block { let blk_arg = vec::pop(base_args); - alt blk_arg.node { + match blk_arg.node { ast::expr_loop_body(_) => word_nbsp(s, ~"for"), ast::expr_do_body(_) => word_nbsp(s, ~"do"), _ => () @@ -1056,7 +1056,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_alt(expr, arms, mode) => { cbox(s, alt_indent_unit); ibox(s, 4u); - word_nbsp(s, ~"alt"); + word_nbsp(s, ~"match"); if mode == ast::alt_check { word_nbsp(s, ~"check"); } print_maybe_parens_discrim(s, expr); space(s.s); @@ -1074,7 +1074,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_pat(s, p); } space(s.s); - alt arm.guard { + match arm.guard { some(e) => { word_space(s, ~"if"); print_expr(s, e); @@ -1087,7 +1087,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { assert arm.body.node.view_items.is_empty(); assert arm.body.node.stmts.is_empty(); assert arm.body.node.rules == ast::default_blk; - alt arm.body.node.expr { + match arm.body.node.expr { some(expr) => { end(s); // close the ibox for the pattern print_expr(s, expr); @@ -1185,7 +1185,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_path(path) => print_path(s, path, true), ast::expr_fail(maybe_fail_val) => { word(s.s, ~"fail"); - alt maybe_fail_val { + match maybe_fail_val { some(expr) => { word(s.s, ~" "); print_expr(s, expr); } _ => () } @@ -1194,13 +1194,13 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_again => word(s.s, ~"again"), ast::expr_ret(result) => { word(s.s, ~"return"); - alt result { + match result { some(expr) => { word(s.s, ~" "); print_expr(s, expr); } _ => () } } ast::expr_log(lvl, lexp, expr) => { - alt check lvl { + match check lvl { 1 => { word_nbsp(s, ~"log"); print_expr(s, expr); } 0 => { word_nbsp(s, ~"log_err"); print_expr(s, expr); } 2 => { @@ -1225,7 +1225,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { } fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) { - let parens = alt ex.node { + let parens = match ex.node { ast::expr_fail(_) | ast::expr_ret(_) | ast::expr_binary(_, _, _) | ast::expr_unary(_, _) | ast::expr_move(_, _) | ast::expr_copy(_) | @@ -1243,7 +1243,7 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) { fn print_local_decl(s: ps, loc: @ast::local) { print_pat(s, loc.node.pat); - alt loc.node.ty.node { + match loc.node.ty.node { ast::ty_infer => (), _ => { word_space(s, ~":"); print_type(s, loc.node.ty); } } @@ -1251,7 +1251,7 @@ fn print_local_decl(s: ps, loc: @ast::local) { fn print_decl(s: ps, decl: @ast::decl) { maybe_print_comment(s, decl.span.lo); - alt decl.node { + match decl.node { ast::decl_local(locs) => { space_if_not_bol(s); ibox(s, indent_unit); @@ -1267,10 +1267,10 @@ fn print_decl(s: ps, decl: @ast::decl) { ibox(s, indent_unit); print_local_decl(s, loc); end(s); - alt loc.node.init { + match loc.node.init { some(init) => { nbsp(s); - alt init.op { + match init.op { ast::init_assign => word_space(s, ~"="), ast::init_move => word_space(s, ~"<-") } @@ -1306,7 +1306,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) { if path.rp.is_some() || !path.types.is_empty() { if colons_before_params { word(s.s, ~"::"); } - alt path.rp { + match path.rp { none => { /* ok */ } some(r) => { word(s.s, ~"/"); @@ -1328,22 +1328,22 @@ fn print_pat(s: ps, &&pat: @ast::pat) { s.ann.pre(ann_node); /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ - alt pat.node { + match pat.node { ast::pat_wild => word(s.s, ~"_"), ast::pat_ident(binding_mode, path, sub) => { - alt binding_mode { + match binding_mode { ast::bind_by_ref => word_space(s, ~"ref"), ast::bind_by_value => () } print_path(s, path, true); - alt sub { + match sub { some(p) => { word(s.s, ~"@"); print_pat(s, p); } none => () } } ast::pat_enum(path, args_) => { print_path(s, path, true); - alt args_ { + match args_ { none => word(s.s, ~"(*)"), some(args) => { if vec::len(args) > 0u { @@ -1391,7 +1391,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) { fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident, typarams: ~[ast::ty_param]) { - alt decl.purity { + match decl.purity { ast::impure_fn => head(s, ~"fn"), _ => head(s, purity_to_str(decl.purity) + ~" fn") } @@ -1442,7 +1442,7 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl, } fn mode_to_str(m: ast::mode) -> ~str { - alt m { + match m { ast::expl(ast::by_mutbl_ref) => ~"&", ast::expl(ast::by_move) => ~"-", ast::expl(ast::by_ref) => ~"&&", @@ -1462,7 +1462,7 @@ fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) { word(s.s, ~":"); for vec::each(*bounds) |bound| { nbsp(s); - alt bound { + match bound { ast::bound_copy => word(s.s, ~"copy"), ast::bound_send => word(s.s, ~"send"), ast::bound_const => word(s.s, ~"const"), @@ -1487,7 +1487,7 @@ fn print_type_params(s: ps, &¶ms: ~[ast::ty_param]) { fn print_meta_item(s: ps, &&item: @ast::meta_item) { ibox(s, indent_unit); - alt item.node { + match item.node { ast::meta_word(name) => word(s.s, *name), ast::meta_name_value(name, value) => { word_space(s, *name); @@ -1505,7 +1505,7 @@ fn print_meta_item(s: ps, &&item: @ast::meta_item) { } fn print_view_path(s: ps, &&vp: @ast::view_path) { - alt vp.node { + match vp.node { ast::view_path_simple(ident, path, _) => { if path.idents[vec::len(path.idents)-1u] != ident { word_space(s, *ident); @@ -1538,7 +1538,7 @@ fn print_view_item(s: ps, item: @ast::view_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); - alt item.node { + match item.node { ast::view_item_use(id, mta, _) => { head(s, ~"use"); word(s.s, *id); @@ -1572,7 +1572,7 @@ fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: uint) { } fn print_mutability(s: ps, mutbl: ast::mutability) { - alt mutbl { + match mutbl { ast::m_mutbl => word_nbsp(s, ~"mut"), ast::m_const => word_nbsp(s, ~"const"), ast::m_imm => {/* nothing */ } @@ -1587,7 +1587,7 @@ fn print_mt(s: ps, mt: ast::mt) { fn print_arg(s: ps, input: ast::arg) { ibox(s, indent_unit); print_arg_mode(s, input.mode); - alt input.ty.node { + match input.ty.node { ast::ty_infer => word(s.s, *input.ident), _ => { if str::len(*input.ident) > 0u { @@ -1604,8 +1604,8 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>, tps: option<~[ast::ty_param]>) { ibox(s, indent_unit); word(s.s, opt_proto_to_str(opt_proto)); - alt id { some(id) => { word(s.s, ~" "); word(s.s, *id); } _ => () } - alt tps { some(tps) => print_type_params(s, tps), _ => () } + match id { some(id) => { word(s.s, ~" "); word(s.s, *id); } _ => () } + match tps { some(tps) => print_type_params(s, tps), _ => () } zerobreak(s.s); popen(s); commasep(s, inconsistent, decl.inputs, print_arg); @@ -1625,14 +1625,14 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>, fn maybe_print_trailing_comment(s: ps, span: codemap::span, next_pos: option<uint>) { let mut cm; - alt s.cm { some(ccm) => cm = ccm, _ => return } - alt next_comment(s) { + match s.cm { some(ccm) => cm = ccm, _ => return } + match next_comment(s) { some(cmnt) => { if cmnt.style != comments::trailing { return; } let span_line = codemap::lookup_char_pos(cm, span.hi); let comment_line = codemap::lookup_char_pos(cm, cmnt.pos); let mut next = cmnt.pos + 1u; - alt next_pos { none => (), some(p) => next = p } + match next_pos { none => (), some(p) => next = p } if span.hi < cmnt.pos && cmnt.pos < next && span_line.line == comment_line.line { print_comment(s, cmnt); @@ -1648,7 +1648,7 @@ fn print_remaining_comments(s: ps) { // make sure there is a line break at the end. if option::is_none(next_comment(s)) { hardbreak(s.s); } loop { - alt next_comment(s) { + match next_comment(s) { some(cmnt) => { print_comment(s, cmnt); s.cur_cmnt += 1u; } _ => break } @@ -1657,14 +1657,14 @@ fn print_remaining_comments(s: ps) { fn print_literal(s: ps, &&lit: @ast::lit) { maybe_print_comment(s, lit.span.lo); - alt next_lit(s, lit.span.lo) { + match next_lit(s, lit.span.lo) { some(ltrl) => { word(s.s, ltrl.lit); return; } _ => () } - alt lit.node { + match lit.node { ast::lit_str(st) => print_string(s, *st), ast::lit_int(ch, ast::ty_char) => { word(s.s, ~"'" + char::escape_default(ch as char) + ~"'"); @@ -1705,7 +1705,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) { fn lit_to_str(l: @ast::lit) -> ~str { return to_str(l, print_literal); } fn next_lit(s: ps, pos: uint) -> option<comments::lit> { - alt s.literals { + match s.literals { some(lits) => { while s.cur_lit < vec::len(lits) { let ltrl = lits[s.cur_lit]; @@ -1721,7 +1721,7 @@ fn next_lit(s: ps, pos: uint) -> option<comments::lit> { fn maybe_print_comment(s: ps, pos: uint) { loop { - alt next_comment(s) { + match next_comment(s) { some(cmnt) => { if cmnt.pos < pos { print_comment(s, cmnt); @@ -1734,7 +1734,7 @@ fn maybe_print_comment(s: ps, pos: uint) { } fn print_comment(s: ps, cmnt: comments::cmnt) { - alt cmnt.style { + match cmnt.style { comments::mixed => { assert (vec::len(cmnt.lines) == 1u); zerobreak(s.s); @@ -1767,7 +1767,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { comments::blank_line => { // We need to do at least one, possibly two hardbreaks. let is_semi = - alt s.s.last_token() { + match s.s.last_token() { pp::STRING(s, _) => *s == ~";", _ => false }; @@ -1792,7 +1792,7 @@ fn to_str<T>(t: T, f: fn@(ps, T)) -> ~str { } fn next_comment(s: ps) -> option<comments::cmnt> { - alt s.comments { + match s.comments { some(cmnts) => { if s.cur_cmnt < vec::len(cmnts) { return some(cmnts[s.cur_cmnt]); @@ -1803,14 +1803,14 @@ fn next_comment(s: ps) -> option<comments::cmnt> { } fn opt_proto_to_str(opt_p: option<ast::proto>) -> ~str { - alt opt_p { + match opt_p { none => ~"fn", some(p) => proto_to_str(p) } } pure fn purity_to_str(p: ast::purity) -> ~str { - alt p { + match p { ast::impure_fn => ~"impure", ast::unsafe_fn => ~"unsafe", ast::pure_fn => ~"pure", @@ -1819,14 +1819,14 @@ pure fn purity_to_str(p: ast::purity) -> ~str { } fn print_purity(s: ps, p: ast::purity) { - alt p { + match p { ast::impure_fn => (), _ => word_nbsp(s, purity_to_str(p)) } } fn proto_to_str(p: ast::proto) -> ~str { - return alt p { + return match p { ast::proto_bare => ~"extern fn", ast::proto_block => ~"fn&", ast::proto_uniq => ~"fn~", diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 80bd9e3a6d1..ccc53020155 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -27,7 +27,7 @@ trait interner<T: const copy> { impl <T: const copy> of interner<T> for hash_interner<T> { fn intern(val: T) -> uint { - alt self.map.find(val) { + match self.map.find(val) { some(idx) => return idx, none => { let new_idx = self.vect.len(); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 1c92f26cabe..7df0fc739ad 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -25,7 +25,7 @@ enum fn_kind { } fn name_of_fn(fk: fn_kind) -> ident { - alt fk { + match fk { fk_item_fn(name, _) | fk_method(name, _, _) | fk_ctor(name, _, _, _, _) => /* FIXME (#2543) */ copy name, fk_anon(*) | fk_fn_block(*) => @~"anon", @@ -34,7 +34,7 @@ fn name_of_fn(fk: fn_kind) -> ident { } fn tps_of_fn(fk: fn_kind) -> ~[ty_param] { - alt fk { + match fk { fk_item_fn(_, tps) | fk_method(_, tps, _) | fk_ctor(_, _, tps, _, _) | fk_dtor(tps, _, _, _) => { /* FIXME (#2543) */ copy tps @@ -89,7 +89,7 @@ fn visit_crate<E>(c: crate, e: E, v: vt<E>) { } fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) { - alt cd.node { + match cd.node { cdir_src_mod(_, _) => (), cdir_dir_mod(_, cdirs, _) => for cdirs.each |cdir| { visit_crate_directive(cdir, e, v); @@ -109,14 +109,14 @@ fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { } fn visit_local<E>(loc: @local, e: E, v: vt<E>) { v.visit_pat(loc.node.pat, e, v); v.visit_ty(loc.node.ty, e, v); - alt loc.node.init { + match loc.node.init { none => (), some(i) => v.visit_expr(i.expr, e, v) } } fn visit_item<E>(i: @item, e: E, v: vt<E>) { - alt i.node { + match i.node { item_const(t, ex) => { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); } item_fn(decl, tp, body) => { v.visit_fn(fk_item_fn(/* FIXME (#2543) */ copy i.ident, @@ -175,7 +175,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) { } fn visit_class_item<E>(cm: @class_member, e:E, v:vt<E>) { - alt cm.node { + match cm.node { instance_var(_, t, _, _, _) => v.visit_ty(t, e, v), class_method(m) => visit_method_helper(m, e, v) } @@ -184,7 +184,7 @@ fn visit_class_item<E>(cm: @class_member, e:E, v:vt<E>) { fn skip_ty<E>(_t: @ty, _e: E, _v: vt<E>) {} fn visit_ty<E>(t: @ty, e: E, v: vt<E>) { - alt t.node { + match t.node { ty_box(mt) | ty_uniq(mt) | ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { v.visit_ty(mt.ty, e, v); @@ -213,7 +213,7 @@ fn visit_path<E>(p: @path, e: E, v: vt<E>) { } fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { - alt p.node { + match p.node { pat_enum(path, children) => { visit_path(path, e, v); do option::iter(children) |children| { @@ -237,7 +237,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { } fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) { - alt ni.node { + match ni.node { foreign_item_fn(fd, tps) => { v.visit_ty_params(tps, e, v); visit_fn_decl(fd, e, v); @@ -248,7 +248,7 @@ fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) { fn visit_ty_params<E>(tps: ~[ty_param], e: E, v: vt<E>) { for tps.each |tp| { for vec::each(*tp.bounds) |bound| { - alt bound { + match bound { bound_trait(t) => v.visit_ty(t, e, v), bound_copy | bound_send | bound_const | bound_owned => () } @@ -304,7 +304,7 @@ fn visit_ty_method<E>(m: ty_method, e: E, v: vt<E>) { } fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) { - alt m { + match m { required(ty_m) => v.visit_ty_method(ty_m, e, v), provided(m) => visit_method_helper(m, e, v) } @@ -317,7 +317,7 @@ fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) { } fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) { - alt s.node { + match s.node { stmt_decl(d, _) => v.visit_decl(d, e, v), stmt_expr(ex, _) => v.visit_expr(ex, e, v), stmt_semi(ex, _) => v.visit_expr(ex, e, v) @@ -325,7 +325,7 @@ fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) { } fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { - alt d.node { + match d.node { decl_local(locs) => for locs.each |loc| { v.visit_local(loc, e, v) } @@ -334,7 +334,7 @@ fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { } fn visit_expr_opt<E>(eo: option<@expr>, e: E, v: vt<E>) { - alt eo { none => (), some(ex) => v.visit_expr(ex, e, v) } + match eo { none => (), some(ex) => v.visit_expr(ex, e, v) } } fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { @@ -342,7 +342,7 @@ fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { } fn visit_mac<E>(m: mac, e: E, v: vt<E>) { - alt m.node { + match m.node { ast::mac_invoc(pth, arg, body) => { option::map(arg, |arg| v.visit_expr(arg, e, v)); } ast::mac_invoc_tt(pth, tt) => { /* no user-serviceable parts inside */ } @@ -353,7 +353,7 @@ fn visit_mac<E>(m: mac, e: E, v: vt<E>) { } fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { - alt ex.node { + match ex.node { expr_vstore(x, _) => v.visit_expr(x, e, v), expr_vec(es, _) => visit_exprs(es, e, v), expr_repeat(element, count, _) => { diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index c4dc6efe7b2..e7fe5fa3e3d 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -61,7 +61,7 @@ mod write { // and the extension to use. fn mk_intermediate_name(output_path: ~str, extension: ~str) -> ~str unsafe { - let stem = alt str::find_char(output_path, '.') { + let stem = match str::find_char(output_path, '.') { some(dot_pos) => str::slice(output_path, 0u, dot_pos), none => output_path }; @@ -82,7 +82,7 @@ mod write { // specified. if opts.save_temps { - alt opts.output_type { + match opts.output_type { output_type_bitcode => { if opts.optimize != 0u { let filename = mk_intermediate_name(output, ~"no-opt.bc"); @@ -146,7 +146,7 @@ mod write { let LLVMOptDefault = 2 as c_int; // -O2, -Os let LLVMOptAggressive = 3 as c_int; // -O3 - let mut CodeGenOptLevel = alt check opts.optimize { + let mut CodeGenOptLevel = match check opts.optimize { 0u => LLVMOptNone, 1u => LLVMOptLess, 2u => LLVMOptDefault, @@ -323,12 +323,12 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, attr::require_unique_names(sess.diagnostic(), linkage_metas); for linkage_metas.each |meta| { if *attr::get_meta_item_name(meta) == ~"name" { - alt attr::get_meta_item_value_str(meta) { + match attr::get_meta_item_value_str(meta) { some(v) => { name = some(v); } none => vec::push(cmh_items, meta) } } else if *attr::get_meta_item_name(meta) == ~"vers" { - alt attr::get_meta_item_value_str(meta) { + match attr::get_meta_item_value_str(meta) { some(v) => { vers = some(v); } none => vec::push(cmh_items, meta) } @@ -355,7 +355,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, symbol_hasher.reset(); for cmh_items.each |m_| { let m = m_; - alt m.node { + match m.node { ast::meta_name_value(key, value) => { symbol_hasher.write_str(len_and_str(*key)); symbol_hasher.write_str(len_and_str_lit(value)); @@ -385,7 +385,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, fn crate_meta_name(sess: session, _crate: ast::crate, output: ~str, metas: provided_metas) -> @~str { - return alt metas.name { + return match metas.name { some(v) => v, none => { let name = @@ -407,7 +407,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, fn crate_meta_vers(sess: session, _crate: ast::crate, metas: provided_metas) -> @~str { - return alt metas.vers { + return match metas.vers { some(v) => v, none => { let vers = ~"0.0"; @@ -451,7 +451,7 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t, } fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { - alt ccx.type_hashcodes.find(t) { + match ccx.type_hashcodes.find(t) { some(h) => return h, none => { let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta); @@ -467,7 +467,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { fn sanitize(s: ~str) -> ~str { let mut result = ~""; do str::chars_iter(s) |c| { - alt c { + match c { '@' => result += ~"_sbox_", '~' => result += ~"_ubox_", '*' => result += ~"_ptr_", @@ -503,7 +503,7 @@ fn mangle(ss: path) -> ~str { let mut n = ~"_ZN"; // Begin name-sequence. for ss.each |s| { - alt s { path_name(s) | path_mod(s) => { + match s { path_name(s) | path_mod(s) => { let sani = sanitize(*s); n += fmt!{"%u%s", str::len(sani), sani}; } } @@ -566,7 +566,7 @@ fn link_binary(sess: session, vec::pop(parts); return str::connect(parts, ~"."); } - return alt config.os { + return match config.os { session::os_macos => rmext(rmlib(filename)), session::os_linux => rmext(rmlib(filename)), session::os_freebsd => rmext(rmlib(filename)), diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index f74ffe8f067..e06b0a2fe72 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -7,7 +7,7 @@ import metadata::filesearch; export get_rpath_flags; pure fn not_win32(os: session::os) -> bool { - alt os { + match os { session::os_win32 => false, _ => true } @@ -108,7 +108,7 @@ fn get_rpath_relative_to_output(os: session::os, assert not_win32(os); // Mac doesn't appear to support $ORIGIN - let prefix = alt os { + let prefix = match os { session::os_linux => ~"$ORIGIN" + path::path_sep(), session::os_freebsd => ~"$ORIGIN" + path::path_sep(), session::os_macos => ~"@executable_path" + path::path_sep(), diff --git a/src/rustc/back/x86.rs b/src/rustc/back/x86.rs index 045a90de495..78270f31e37 100644 --- a/src/rustc/back/x86.rs +++ b/src/rustc/back/x86.rs @@ -8,7 +8,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), - data_layout: alt target_os { + data_layout: match target_os { session::os_macos => { ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + ~"-i32:32:32-i64:32:64" + @@ -29,7 +29,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { } }, - target_triple: alt target_os { + target_triple: match target_os { session::os_macos => ~"i686-apple-darwin", session::os_win32 => ~"i686-pc-mingw32", session::os_linux => ~"i686-unknown-linux-gnu", diff --git a/src/rustc/back/x86_64.rs b/src/rustc/back/x86_64.rs index 70a35eb3289..18c2232c0fc 100644 --- a/src/rustc/back/x86_64.rs +++ b/src/rustc/back/x86_64.rs @@ -8,7 +8,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), - data_layout: alt target_os { + data_layout: match target_os { session::os_macos => { ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ @@ -35,7 +35,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { } }, - target_triple: alt target_os { + target_triple: match target_os { session::os_macos => ~"x86_64-apple-darwin", session::os_win32 => ~"x86_64-pc-mingw32", session::os_linux => ~"x86_64-unknown-linux-gnu", diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 5a07c8f411c..2f6bd86592f 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -26,7 +26,7 @@ enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified, fn anon_src() -> ~str { ~"<anon>" } fn source_name(input: input) -> ~str { - alt input { + match input { file_input(ifile) => ifile, str_input(_) => anon_src() } @@ -34,7 +34,7 @@ fn source_name(input: input) -> ~str { fn default_configuration(sess: session, argv0: ~str, input: input) -> ast::crate_cfg { - let libc = alt sess.targ_cfg.os { + let libc = match sess.targ_cfg.os { session::os_win32 => ~"msvcrt.dll", session::os_macos => ~"libc.dylib", session::os_linux => ~"libc.so.6", @@ -44,7 +44,7 @@ fn default_configuration(sess: session, argv0: ~str, input: input) -> let mk = attr::mk_name_value_item_str; - let (arch,wordsz) = alt sess.targ_cfg.arch { + let (arch,wordsz) = match sess.targ_cfg.arch { session::arch_x86 => (~"x86",~"32"), session::arch_x86_64 => (~"x86_64",~"64"), session::arch_arm => (~"arm",~"32") @@ -99,7 +99,7 @@ enum input { fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) -> @ast::crate { - alt input { + match input { file_input(file) => { parse::parse_crate_from_file(file, cfg, sess.parse_sess) } @@ -270,13 +270,13 @@ fn compile_input(sess: session, cfg: ast::crate_cfg, input: input, fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, ppm: pp_mode) { fn ann_paren_for_expr(node: pprust::ann_node) { - alt node { + match node { pprust::node_expr(s, expr) => pprust::popen(s), _ => () } } fn ann_typed_post(tcx: ty::ctxt, node: pprust::ann_node) { - alt node { + match node { pprust::node_expr(s, expr) => { pp::space(s.s); pp::word(s.s, ~"as"); @@ -288,7 +288,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, } } fn ann_identified_post(node: pprust::ann_node) { - alt node { + match node { pprust::node_item(s, item) => { pp::space(s.s); pprust::synth_comment(s, int::to_str(item.id, 10u)); @@ -314,14 +314,14 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, // to collect comments and literals, and we need to support reading // from stdin, we're going to just suck the source into a string // so both the parser and pretty-printer can use it. - let upto = alt ppm { + let upto = match ppm { ppm_expanded | ppm_expanded_identified => cu_expand, ppm_typed => cu_typeck, _ => cu_parse }; let {crate, tcx} = compile_upto(sess, cfg, input, upto, none); - let ann = alt ppm { + let ann = match ppm { ppm_typed => { {pre: ann_paren_for_expr, post: |a| ann_typed_post(option::get(tcx), a) } @@ -371,21 +371,21 @@ fn get_arch(triple: ~str) -> option<session::arch> { fn build_target_config(sopts: @session::options, demitter: diagnostic::emitter) -> @session::config { - let os = alt get_os(sopts.target_triple) { + let os = match get_os(sopts.target_triple) { some(os) => os, none => early_error(demitter, ~"unknown operating system") }; - let arch = alt get_arch(sopts.target_triple) { + let arch = match get_arch(sopts.target_triple) { some(arch) => arch, none => early_error(demitter, ~"unknown architecture: " + sopts.target_triple) }; - let (int_type, uint_type, float_type) = alt arch { + let (int_type, uint_type, float_type) = match arch { session::arch_x86 => (ast::ty_i32, ast::ty_u32, ast::ty_f64), session::arch_x86_64 => (ast::ty_i64, ast::ty_u64, ast::ty_f64), session::arch_arm => (ast::ty_i32, ast::ty_u32, ast::ty_f64) }; - let target_strs = alt arch { + let target_strs = match arch { session::arch_x86 => x86::get_target_strs(os), session::arch_x86_64 => x86_64::get_target_strs(os), session::arch_arm => x86::get_target_strs(os) @@ -438,7 +438,7 @@ fn build_session_options(matches: getopts::matches, getopts::opt_strs(matches, level_name)); for flags.each |lint_name| { let lint_name = str::replace(lint_name, ~"-", ~"_"); - alt lint_dict.find(lint_name) { + match lint_dict.find(lint_name) { none => { early_error(demitter, fmt!{"unknown %s flag: %s", level_name, lint_name}); @@ -486,7 +486,7 @@ fn build_session_options(matches: getopts::matches, let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot"); let target_opt = getopts::opt_maybe_str(matches, ~"target"); let save_temps = getopts::opt_present(matches, ~"save-temps"); - alt output_type { + match output_type { // unless we're emitting huamn-readable assembly, omit comments. link::output_type_llvm_assembly | link::output_type_assembly => (), _ => debugging_opts |= session::no_asm_comments @@ -498,7 +498,7 @@ fn build_session_options(matches: getopts::matches, } 2u } else if opt_present(matches, ~"opt-level") { - alt getopts::opt_str(matches, ~"opt-level") { + match getopts::opt_str(matches, ~"opt-level") { ~"0" => 0u, ~"1" => 1u, ~"2" => 2u, @@ -510,7 +510,7 @@ fn build_session_options(matches: getopts::matches, } } else { 0u }; let target = - alt target_opt { + match target_opt { none => host_triple(), some(s) => s }; @@ -577,7 +577,7 @@ fn build_session_(sopts: @session::options, } fn parse_pretty(sess: session, &&name: ~str) -> pp_mode { - alt name { + match name { ~"normal" => ppm_normal, ~"expanded" => ppm_expanded, ~"typed" => ppm_typed, @@ -628,7 +628,7 @@ fn build_output_filenames(input: input, let obj_suffix = - alt sopts.output_type { + match sopts.output_type { link::output_type_none => ~"none", link::output_type_bitcode => ~"bc", link::output_type_assembly => ~"s", @@ -637,20 +637,20 @@ fn build_output_filenames(input: input, link::output_type_object | link::output_type_exe => ~"o" }; - alt ofile { + match ofile { none => { // "-" as input file will cause the parser to read from stdin so we // have to make up a name // We want to toss everything after the final '.' - let dirname = alt odir { + let dirname = match odir { some(d) => d, - none => alt input { + none => match input { str_input(_) => os::getcwd(), file_input(ifile) => path::dirname(ifile) } }; - let base_filename = alt input { + let base_filename = match input { file_input(ifile) => { let (path, _) = path::splitext(ifile); path::basename(path) @@ -714,7 +714,7 @@ mod test { #[test] fn test_switch_implies_cfg_test() { let matches = - alt getopts::getopts(~[~"--test"], opts()) { + match getopts::getopts(~[~"--test"], opts()) { ok(m) => m, err(f) => fail ~"test_switch_implies_cfg_test: " + getopts::fail_str(f) @@ -730,7 +730,7 @@ mod test { #[test] fn test_switch_implies_cfg_test_unless_cfg_test() { let matches = - alt getopts::getopts(~[~"--test", ~"--cfg=test"], opts()) { + match getopts::getopts(~[~"--test", ~"--cfg=test"], opts()) { ok(m) => m, err(f) => { fail ~"test_switch_implies_cfg_test_unless_cfg_test: " + diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 483e1ca5808..dbbe48f84b2 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -95,7 +95,7 @@ fn describe_warnings() { let k = str::replace(k, ~"_", ~"-"); io::println(fmt!{" %s %7.7s %s", padded(max_key, k), - alt v.default { + match v.default { lint::allow => ~"allow", lint::warn => ~"warn", lint::deny => ~"deny", @@ -124,7 +124,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { if vec::len(args) == 0u { usage(binary); return; } let matches = - alt getopts::getopts(args, opts()) { + match getopts::getopts(args, opts()) { ok(m) => m, err(f) => { early_error(demitter, getopts::fail_str(f)) @@ -152,7 +152,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { version(binary); return; } - let input = alt vec::len(matches.free) { + let input = match vec::len(matches.free) { 0u => early_error(demitter, ~"no input filename given"), 1u => { let ifile = matches.free[0]; @@ -175,7 +175,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { option::map(getopts::opt_default(matches, ~"pretty", ~"normal"), |a| parse_pretty(sess, a) ); - alt pretty { + match pretty { some::<pp_mode>(ppm) => { pretty_print_input(sess, cfg, input, ppm); return; @@ -184,7 +184,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { } let ls = opt_present(matches, ~"ls"); if ls { - alt input { + match input { file_input(ifile) => { list_metadata(sess, ifile, io::stdout()); } @@ -219,7 +219,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { let p = comm::port(); let ch = comm::chan(p); - alt do task::try { + match do task::try { // The 'diagnostics emitter'. Every error, warning, etc. should // go through this function. diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 200dd1b00d7..df9370afaea 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -152,7 +152,7 @@ impl session for session { } fn span_lint_level(level: lint::level, sp: span, msg: ~str) { - alt level { + match level { lint::allow => { }, lint::warn => self.span_warn(sp, msg), lint::deny | lint::forbid => { @@ -219,14 +219,14 @@ fn expect<T: copy>(sess: session, opt: option<T>, msg: fn() -> ~str) -> T { fn building_library(req_crate_type: crate_type, crate: @ast::crate, testing: bool) -> bool { - alt req_crate_type { + match req_crate_type { bin_crate => false, lib_crate => true, unknown_crate => { if testing { false } else { - alt syntax::attr::first_attr_value_str_by_name( + match syntax::attr::first_attr_value_str_by_name( crate.node.attrs, ~"crate_type") { option::some(@~"lib") => true, @@ -240,7 +240,7 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate, fn sess_os_to_meta_os(os: os) -> metadata::loader::os { import metadata::loader; - alt os { + match os { os_win32 => loader::os_win32, os_linux => loader::os_linux, os_macos => loader::os_macos, diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index 92035856ddf..ee9000b80e0 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -82,9 +82,9 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod, fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) -> option<@ast::stmt> { - alt stmt.node { + match stmt.node { ast::stmt_decl(decl, _) => { - alt decl.node { + match decl.node { ast::decl_item(item) => { if item_in_cfg(cx, item) { option::some(stmt) diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index cc80a524f31..85770b7b6dd 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -15,7 +15,7 @@ fn inject_intrinsic(sess: session, ~[], sess.parse_sess); let item = - alt item { + match item { some(i) => i, none => { sess.fatal(~"no item found in intrinsic module"); diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 66e430f27cd..9c54f6fa981 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -70,7 +70,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { // FIXME (#2403): This is sloppy. Instead we should have some mechanism to // indicate to the translation pass which function we want to be main. fn nomain(&&item: @ast::item) -> option<@ast::item> { - alt item.node { + match item.node { ast::item_fn(_, _, _) => { if *item.ident == ~"main" { option::none @@ -102,7 +102,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> debug!{"current path: %s", ast_util::path_name_i(cx.path)}; if is_test_fn(i) { - alt i.node { + match i.node { ast::item_fn(decl, _, _) if decl.purity == ast::unsafe_fn => { cx.sess.span_fatal( i.span, @@ -129,7 +129,7 @@ fn is_test_fn(i: @ast::item) -> bool { vec::len(attr::find_attrs_by_name(i.attrs, ~"test")) > 0u; fn has_test_signature(i: @ast::item) -> bool { - alt i.node { + match i.node { ast::item_fn(decl, tps, _) => { let input_cnt = vec::len(decl.inputs); let no_output = decl.output.node == ast::ty_nil; @@ -246,7 +246,7 @@ fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] { // the paths with std:: let is_std = { let items = attr::find_linkage_metas(cx.crate.node.attrs); - alt attr::last_meta_item_value_str_by_name(items, ~"name") { + match attr::last_meta_item_value_str_by_name(items, ~"name") { some(@~"std") => true, _ => false } diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 1effed07f13..2250d3d3086 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -1015,7 +1015,7 @@ fn type_to_str(names: type_names, ty: TypeRef) -> ~str { fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> ~str { - alt type_has_name(names, ty) { + match type_has_name(names, ty) { option::some(n) => return n, _ => {} } @@ -1035,7 +1035,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> return s; } - alt kind { + match kind { Void => return ~"Void", Half => return ~"Half", Float => return ~"Float", @@ -1103,7 +1103,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> } fn float_width(llt: TypeRef) -> uint { - return alt llvm::LLVMGetTypeKind(llt) as int { + return match llvm::LLVMGetTypeKind(llt) as int { 1 => 32u, 2 => 64u, 3 => 80u, diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 03dd9c389dd..5b72a6caa6c 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -100,7 +100,7 @@ type env = @{diag: span_handler, mut next_crate_num: ast::crate_num}; fn visit_view_item(e: env, i: @ast::view_item) { - alt i.node { + match i.node { ast::view_item_use(ident, meta_items, id) => { debug!{"resolving use stmt. ident: %?, meta: %?", ident, meta_items}; let cnum = resolve_crate(e, ident, meta_items, ~"", i.span); @@ -111,9 +111,9 @@ fn visit_view_item(e: env, i: @ast::view_item) { } fn visit_item(e: env, i: @ast::item) { - alt i.node { + match i.node { ast::item_foreign_mod(m) => { - alt attr::foreign_abi(i.attrs) { + match attr::foreign_abi(i.attrs) { either::right(abi) => { if abi != ast::foreign_abi_cdecl && abi != ast::foreign_abi_stdcall { return; } @@ -123,7 +123,7 @@ fn visit_item(e: env, i: @ast::item) { let cstore = e.cstore; let foreign_name = - alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { + match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { some(nn) => { if *nn == ~"" { e.diag.span_fatal( @@ -144,7 +144,7 @@ fn visit_item(e: env, i: @ast::item) { ~"' already added: can't specify link_args."); } for link_args.each |a| { - alt attr::get_meta_item_value_str(attr::attr_meta(a)) { + match attr::get_meta_item_value_str(attr::attr_meta(a)) { some(linkarg) => { cstore::add_used_link_args(cstore, *linkarg); } @@ -187,7 +187,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], hash: ~str, span: span) -> ast::crate_num { let metas = metas_with_ident(ident, metas); - alt existing_match(e, metas, hash) { + match existing_match(e, metas, hash) { none => { let load_ctxt: loader::ctxt = { diag: e.diag, @@ -218,7 +218,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], let cnum_map = resolve_crate_deps(e, cdata); let cname = - alt attr::last_meta_item_value_str_by_name(metas, ~"name") { + match attr::last_meta_item_value_str_by_name(metas, ~"name") { option::some(v) => v, option::none => ident }; @@ -248,7 +248,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { let cmetas = metas_with(dep.vers, @~"vers", ~[]); debug!{"resolving dep crate %s ver: %s hash: %s", *dep.name, *dep.vers, *dep.hash}; - alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { + match existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { some(local_cnum) => { debug!{"already have it"}; // We've already seen this crate diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 1a536ca1bdd..627d7a326d0 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -57,7 +57,7 @@ fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num, fn lookup_method_purity(cstore: cstore::cstore, did: ast::def_id) -> ast::purity { let cdata = cstore::get_crate_data(cstore, did.crate).data; - alt check decoder::lookup_def(did.crate, cdata, did) { + match check decoder::lookup_def(did.crate, cdata, did) { ast::def_fn(_, p) => p } } diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index a177b264e5b..75c7c8dd9fe 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -64,7 +64,7 @@ type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>; // Internal method to retrieve the data from the cstore pure fn p(cstore: cstore) -> cstore_private { - alt cstore { private(p) => p } + match cstore { private(p) => p } } fn mk_cstore() -> cstore { diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 2e4a670c841..2fae50785af 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -99,7 +99,7 @@ fn find_item(item_id: int, items: ebml::doc) -> ebml::doc { // to the item data. fn lookup_item(item_id: int, data: @~[u8]) -> ebml::doc { let items = ebml::get_doc(ebml::doc(data), tag_items); - alt maybe_find_item(item_id, items) { + match maybe_find_item(item_id, items) { none => fail(fmt!{"lookup_item: id not found: %d", item_id}), some(d) => d } @@ -135,7 +135,7 @@ fn field_mutability(d: ebml::doc) -> ast::class_mutability { ebml::maybe_get_doc(d, tag_class_mut), ast::class_immutable, |d| { - alt ebml::doc_as_u8(d) as char { + match ebml::doc_as_u8(d) as char { 'm' => ast::class_mutable, _ => ast::class_immutable } @@ -184,7 +184,7 @@ fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) } fn item_ty_region_param(item: ebml::doc) -> bool { - alt ebml::maybe_get_doc(item, tag_region_param) { + match ebml::maybe_get_doc(item, tag_region_param) { some(_) => true, none => false } @@ -275,7 +275,7 @@ fn lookup_item_name(data: @~[u8], id: ast::node_id) -> ast::ident { fn item_to_def_like(item: ebml::doc, did: ast::def_id, cnum: ast::crate_num) -> def_like { let fam_ch = item_family(item); - alt fam_ch { + match fam_ch { 'c' => dl_def(ast::def_const(did)), 'C' => dl_def(ast::def_class(did, true)), 'S' => dl_def(ast::def_class(did, false)), @@ -349,7 +349,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { let items = ebml::get_doc(ebml::doc(cdata.data), tag_items); let mut found = none; - let cls_items = alt maybe_find_item(id, items) { + let cls_items = match maybe_find_item(id, items) { some(it) => it, none => fail (fmt!{"get_class_method: class id not found \ when looking up method %s", *name}) @@ -360,7 +360,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, found = some(m_did); } } - alt found { + match found { some(found) => found, none => fail (fmt!{"get_class_method: no method named %s", *name}) } @@ -369,7 +369,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> { let items = ebml::get_doc(ebml::doc(cdata.data), tag_items); let mut found = none; - let cls_items = alt maybe_find_item(id, items) { + let cls_items = match maybe_find_item(id, items) { some(it) => it, none => fail (fmt!{"class_dtor: class id not found \ when looking up dtor for %d", id}) @@ -394,7 +394,7 @@ enum def_like { } fn def_like_to_def(def_like: def_like) -> ast::def { - alt def_like { + match def_like { dl_def(def) => return def, dl_impl(*) => fail ~"found impl in def_like_to_def", dl_field => fail ~"found field in def_like_to_def" @@ -467,7 +467,7 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { let def_id = class_member_id(path_doc, cdata); // Get the item. - alt maybe_find_item(def_id.node, items) { + match maybe_find_item(def_id.node, items) { none => { debug!{"(each_path) ignoring implicit item: %s", *path}; @@ -515,14 +515,14 @@ fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt, debug!{"Looking up item: %d", id}; let item_doc = lookup_item(id, cdata.data); let path = vec::init(item_path(item_doc)); - alt decode_inlined_item(cdata, tcx, path, item_doc) { + match decode_inlined_item(cdata, tcx, path, item_doc) { some(ii) => csearch::found(ii), none => { - alt item_parent_item(item_doc) { + match item_parent_item(item_doc) { some(did) => { let did = translate_def_id(cdata, did); let parent_item = lookup_item(did.node, cdata.data); - alt decode_inlined_item(cdata, tcx, path, + match decode_inlined_item(cdata, tcx, path, parent_item) { some(ii) => csearch::found_parent(did, ii), none => csearch::not_found @@ -548,13 +548,13 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) tcx, cdata); let name = item_name(item); let mut arg_tys: ~[ty::t] = ~[]; - alt ty::get(ctor_ty).struct { + match ty::get(ctor_ty).struct { ty::ty_fn(f) => { for f.inputs.each |a| { vec::push(arg_tys, a.ty); } } _ => { /* Nullary enum variant. */ } } - alt variant_disr_val(item) { + match variant_disr_val(item) { some(val) => { disr_val = val; } _ => { /* empty */ } } @@ -577,7 +577,7 @@ type _impl = {did: ast::def_id, ident: ast::ident, methods: ~[@method_info]}; fn get_self_ty(item: ebml::doc) -> ast::self_ty_ { fn get_mutability(ch: u8) -> ast::mutability { - alt ch as char { + match ch as char { 'i' => { ast::m_imm } 'm' => { ast::m_mutbl } 'c' => { ast::m_const } @@ -591,7 +591,7 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ { let string = ebml::doc_as_str(self_type_doc); let self_ty_kind = string[0]; - alt self_ty_kind as char { + match self_ty_kind as char { 'r' => { return ast::sty_by_ref; } 'v' => { return ast::sty_value; } '@' => { return ast::sty_box(get_mutability(string[1])); } @@ -654,7 +654,7 @@ fn get_impls_for_mod(cdata: cmd, let impl_data = impl_cdata.data; let item = lookup_item(local_did.node, impl_data); let nm = item_name(item); - if alt name { some(n) => { n == nm } none => { true } } { + if match name { some(n) => { n == nm } none => { true } } { let base_tps = item_ty_param_count(item); vec::push(result, @{ did: local_did, ident: nm, @@ -675,7 +675,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let bounds = item_ty_param_bounds(mth, tcx, cdata); let name = item_name(mth); let ty = doc_type(mth, tcx, cdata); - let fty = alt ty::get(ty).struct { + let fty = match ty::get(ty).struct { ty::ty_fn(f) => f, _ => { tcx.diag.handler().bug( @@ -684,7 +684,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let self_ty = get_self_ty(mth); vec::push(result, {ident: name, tps: bounds, fty: fty, self_ty: self_ty, - purity: alt check item_family(mth) { + purity: match check item_family(mth) { 'u' => ast::unsafe_fn, 'f' => ast::impure_fn, 'p' => ast::pure_fn @@ -742,7 +742,7 @@ fn get_class_members(cdata: cmd, id: ast::node_id, } pure fn family_to_visibility(family: char) -> ast::visibility { - alt family { + match family { 'g' => ast::public, 'j' => ast::private, 'N' => ast::inherited, @@ -756,7 +756,7 @@ fn get_class_fields(cdata: cmd, id: ast::node_id) -> ~[ty::field_ty] { } fn family_has_type_params(fam_ch: char) -> bool { - alt check fam_ch { + match check fam_ch { 'c' | 'T' | 'm' | 'n' | 'g' | 'h' | 'j' => false, 'f' | 'u' | 'p' | 'F' | 'U' | 'P' | 'y' | 't' | 'v' | 'i' | 'I' | 'C' | 'a' | 'S' @@ -765,7 +765,7 @@ fn family_has_type_params(fam_ch: char) -> bool { } fn family_names_type(fam_ch: char) -> bool { - alt fam_ch { 'y' | 't' | 'I' => true, _ => false } + match fam_ch { 'y' | 't' | 'I' => true, _ => false } } fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { @@ -778,7 +778,7 @@ fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { if id.crate != ast::local_crate { return ~"external"; } - let it = alt maybe_find_item(id.node, items) { + let it = match maybe_find_item(id.node, items) { some(it) => it, none => fail (fmt!{"describe_def: item not found %?", id}) }; @@ -786,7 +786,7 @@ fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { } fn item_family_to_str(fam: char) -> ~str { - alt check fam { + match check fam { 'c' => return ~"const", 'f' => return ~"fn", 'u' => return ~"unsafe fn", @@ -837,7 +837,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] { fn get_attributes(md: ebml::doc) -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; - alt ebml::maybe_get_doc(md, tag_attributes) { + match ebml::maybe_get_doc(md, tag_attributes) { option::some(attrs_d) => { for ebml::tagged_docs(attrs_d, tag_attribute) |attr_doc| { let meta_items = get_meta_items(attr_doc); @@ -916,7 +916,7 @@ fn get_crate_hash(data: @~[u8]) -> @~str { fn get_crate_vers(data: @~[u8]) -> @~str { let attrs = decoder::get_crate_attributes(data); - return alt attr::last_meta_item_value_str_by_name( + return match attr::last_meta_item_value_str_by_name( attr::find_linkage_metas(attrs), ~"vers") { some(ver) => ver, none => @~"0.0" @@ -997,7 +997,7 @@ fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { return {crate: cdata.cnum, node: did.node}; } - alt cdata.cnum_map.find(did.crate) { + match cdata.cnum_map.find(did.crate) { option::some(n) => return {crate: n, node: did.node}, option::none => fail ~"didn't find a crate in the cnum_map" } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index fc23c8b351c..39057647b7f 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -101,7 +101,7 @@ fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) { fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) { do ebml_w.wr_tag(tag_class_mut) { - let val = alt mt { + let val = match mt { class_immutable => 'i', class_mutable => 'm' }; @@ -145,10 +145,10 @@ fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod, fn encode_class_item_paths(ebml_w: ebml::writer, items: ~[@class_member], path: ~[ident], &index: ~[entry<~str>]) { for items.each |it| { - alt ast_util::class_member_visibility(it) { + match ast_util::class_member_visibility(it) { private => again, public | inherited => { - let (id, ident) = alt it.node { + let (id, ident) = match it.node { instance_var(v, _, _, vid, _) => (vid, v), class_method(it) => (it.id, it.ident) }; @@ -168,7 +168,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, if !ast_util::is_item_impl(it) { add_to_index(ebml_w, path, index, it.ident); } - alt it.node { + match it.node { item_const(_, _) => { encode_named_def_id(ebml_w, it.ident, local_def(it.id)); } @@ -205,7 +205,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, // class and for its ctor add_to_index(ebml_w, path, index, it.ident); - alt m_ctor { + match m_ctor { none => { // Nothing to do. } @@ -317,7 +317,7 @@ fn encode_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) { fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); - let sym = alt ecx.item_symbols.find(id) { + let sym = match ecx.item_symbols.find(id) { some(x) => x, none => { ecx.diag.handler().bug( @@ -382,7 +382,7 @@ fn encode_path(ebml_w: ebml::writer, path: ast_map::path, name: ast_map::path_elt) { fn encode_path_elt(ebml_w: ebml::writer, elt: ast_map::path_elt) { - let (tag, name) = alt elt { + let (tag, name) = match elt { ast_map::path_mod(name) => (tag_path_elt_mod, name), ast_map::path_name(name) => (tag_path_elt_name, name) }; @@ -416,7 +416,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, ast_util::is_exported(ident, md)}; ebml_w.start_tag(tag_mod_impl); - alt ecx.tcx.items.find(did.node) { + match ecx.tcx.items.find(did.node) { some(ast_map::node_item(it@@{node: cl@item_class(*),_},_)) => { /* If did stands for a trait ref, we need to map it to its parent class */ @@ -436,7 +436,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, } fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) { - encode_family(ebml_w, alt visibility { + encode_family(ebml_w, match visibility { public => 'g', private => 'j', inherited => 'N' @@ -444,7 +444,7 @@ fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) { } fn encode_region(ebml_w: ebml::writer, region: region) { - alt region.node { + match region.node { re_anon => { ebml_w.wr_tagged_str(tag_item_trait_method_self_ty, ~""); } @@ -459,7 +459,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) { // Encode the base self type. let ch; - alt self_type { + match self_type { sty_by_ref => { ch = 'r' as u8; } sty_value => { ch = 'v' as u8; } sty_region(_, _) => { ch = '&' as u8; } @@ -469,7 +469,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) { ebml_w.writer.write(&[ ch ]); // Encode mutability. - alt self_type { + match self_type { sty_by_ref | sty_value => { /* No-op. */ } sty_region(_, m_imm) | sty_box(m_imm) | sty_uniq(m_imm) => { ebml_w.writer.write(&[ 'i' as u8 ]); @@ -483,7 +483,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) { } // Encode the region. - alt self_type { + match self_type { sty_region(region, _) => { encode_region(ebml_w, *region); } @@ -508,7 +508,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, for items.each |ci| { /* We encode both private and public fields -- need to include private fields to get the offsets right */ - alt ci.node { + match ci.node { instance_var(nm, _, mt, id, vis) => { vec::push(*index, {val: id, pos: ebml_w.writer.tell()}); vec::push(*global_index, {val: id, pos: ebml_w.writer.tell()}); @@ -523,7 +523,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, ebml_w.end_tag(); } class_method(m) => { - alt m.vis { + match m.vis { public | inherited => { vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()}); vec::push(*global_index, @@ -557,7 +557,7 @@ fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer, util::ppaux::ty_to_str(ecx.tcx, its_ty), id}; encode_type(ecx, ebml_w, its_ty); encode_path(ebml_w, path, ast_map::path_name(ident)); - alt item { + match item { some(it) => { ecx.encode_inlined_item(ecx, ebml_w, path, it); } @@ -592,7 +592,7 @@ fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer, } fn purity_fn_family(p: purity) -> char { - alt p { + match p { unsafe_fn => 'u', pure_fn => 'p', impure_fn => 'f', @@ -602,7 +602,7 @@ fn purity_fn_family(p: purity) -> char { fn should_inline(attrs: ~[attribute]) -> bool { - alt attr::find_inline_attr(attrs) { + match attr::find_inline_attr(attrs) { attr::ia_none | attr::ia_never => false, attr::ia_hint | attr::ia_always => true } @@ -614,7 +614,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, let tcx = ecx.tcx; let must_write = - alt item.node { + match item.node { item_enum(_, _) | item_impl(*) | item_trait(*) | item_class(*) => true, _ => false @@ -627,7 +627,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, } let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index); - alt item.node { + match item.node { item_const(_, _) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); @@ -719,7 +719,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(item.id)); - alt ctor { + match ctor { none => encode_family(ebml_w, 'S'), some(_) => encode_family(ebml_w, 'C') } @@ -752,7 +752,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, ebml_w.end_tag(); } for ms.each |m| { - alt m.vis { + match m.vis { private => { /* do nothing */ } public | inherited => { /* Write the info that's needed when viewing this class @@ -823,7 +823,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_attributes(ebml_w, item.attrs); let mut i = 0u; for vec::each(*ty::trait_methods(tcx, local_def(item.id))) |mty| { - alt ms[i] { + match ms[i] { required(ty_m) => { ebml_w.start_tag(tag_item_trait_method); encode_name(ebml_w, mty.ident); @@ -859,7 +859,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer, vec::push(*index, {val: nitem.id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); - alt nitem.node { + match nitem.node { foreign_item_fn(fn_decl, tps) => { encode_def_id(ebml_w, local_def(nitem.id)); encode_family(ebml_w, purity_fn_family(fn_decl.purity)); @@ -888,11 +888,11 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, visit_expr: |_e, _cx, _v| { }, visit_item: |i, cx, v, copy ebml_w| { visit::visit_item(i, cx, v); - alt check ecx.tcx.items.get(i.id) { + match check ecx.tcx.items.get(i.id) { ast_map::node_item(_, pt) => { encode_info_for_item(ecx, ebml_w, i, index, *pt); /* encode ctor, then encode items */ - alt i.node { + match i.node { item_class(tps, _, _, some(ctor), m_dtor) => { debug!{"encoding info for ctor %s %d", *i.ident, ctor.node.id}; @@ -913,7 +913,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, }, visit_foreign_item: |ni, cx, v, copy ebml_w| { visit::visit_foreign_item(ni, cx, v); - alt check ecx.tcx.items.get(ni.id) { + match check ecx.tcx.items.get(ni.id) { ast_map::node_foreign_item(_, abi, pt) => { encode_info_for_foreign_item(ecx, ebml_w, ni, index, *pt, abi); @@ -981,7 +981,7 @@ fn write_int(writer: io::writer, &&n: int) { } fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) { - alt mi.node { + match mi.node { meta_word(name) => { ebml_w.start_tag(tag_meta_item_word); ebml_w.start_tag(tag_meta_item_name); @@ -990,7 +990,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) { ebml_w.end_tag(); } meta_name_value(name, value) => { - alt value.node { + match value.node { lit_str(value) => { ebml_w.start_tag(tag_meta_item_name_value); ebml_w.start_tag(tag_meta_item_name); @@ -1064,7 +1064,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { if *attr::get_attr_name(attr) != ~"link" { attr } else { - alt attr.node.value.node { + match attr.node.value.node { meta_list(n, l) => { found_link_attr = true;; synthesize_link_attr(ecx, l) diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index 656aa4a0ae2..54aef6e858f 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -43,11 +43,11 @@ fn mk_filesearch(maybe_sysroot: option<path>, vec::push(paths, make_target_lib_path(self.sysroot, self.target_triple)); - alt get_cargo_lib_path_nearest() { + match get_cargo_lib_path_nearest() { result::ok(p) => vec::push(paths, p), result::err(p) => () } - alt get_cargo_lib_path() { + match get_cargo_lib_path() { result::ok(p) => vec::push(paths, p), result::err(p) => () } @@ -101,14 +101,14 @@ fn make_target_lib_path(sysroot: path, } fn get_default_sysroot() -> path { - alt os::self_exe_path() { + match os::self_exe_path() { option::some(p) => path::normalize(path::connect(p, ~"..")), option::none => fail ~"can't determine value for sysroot" } } fn get_sysroot(maybe_sysroot: option<path>) -> path { - alt maybe_sysroot { + match maybe_sysroot { option::some(sr) => sr, option::none => get_default_sysroot() } @@ -120,9 +120,9 @@ fn get_cargo_sysroot() -> result<path, ~str> { } fn get_cargo_root() -> result<path, ~str> { - alt os::getenv(~"CARGO_ROOT") { + match os::getenv(~"CARGO_ROOT") { some(_p) => result::ok(_p), - none => alt os::homedir() { + none => match os::homedir() { some(_q) => result::ok(path::connect(_q, ~".cargo")), none => result::err(~"no CARGO_ROOT or home directory") } diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index e45fdeb06b8..e5a2e0848e9 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -37,7 +37,7 @@ type ctxt = { }; fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { - alt find_library_crate(cx) { + match find_library_crate(cx) { some(t) => return t, none => { cx.diag.span_fatal( @@ -53,7 +53,7 @@ fn find_library_crate(cx: ctxt) -> option<{ident: ~str, data: @~[u8]}> { fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} { if cx.static { return {prefix: ~"lib", suffix: ~".rlib"}; } - alt cx.os { + match cx.os { os_win32 => return {prefix: ~"", suffix: ~".dll"}, os_macos => return {prefix: ~"lib", suffix: ~".dylib"}, os_linux => return {prefix: ~"lib", suffix: ~".so"}, @@ -79,7 +79,7 @@ fn find_library_crate_aux(cx: ctxt, option::none::<()> } else { debug!{"%s is a candidate", path}; - alt get_metadata_section(cx.os, path) { + match get_metadata_section(cx.os, path) { option::some(cvec) => { if !crate_matches(cvec, cx.metas, cx.hash) { debug!{"skipping %s, metadata doesn't match", path}; @@ -118,9 +118,9 @@ fn find_library_crate_aux(cx: ctxt, fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @~str { let name_items = attr::find_meta_items_by_name(metas, ~"name"); - alt vec::last_opt(name_items) { + match vec::last_opt(name_items) { some(i) => { - alt attr::get_meta_item_value_str(i) { + match attr::get_meta_item_value_str(i) { some(n) => n, // FIXME (#2406): Probably want a warning here since the user // is using the wrong type of meta item. @@ -175,7 +175,7 @@ fn get_metadata_section(os: os, llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf) }); if mb as int == 0 { return option::none::<@~[u8]>; } - let of = alt mk_object_file(mb) { + let of = match mk_object_file(mb) { option::some(of) => of, _ => return option::none::<@~[u8]> }; @@ -197,7 +197,7 @@ fn get_metadata_section(os: os, } fn meta_section_name(os: os) -> ~str { - alt os { + match os { os_macos => ~"__DATA,__note.rustc", os_win32 => ~".note.rustc", os_linux => ~".note.rustc", @@ -207,7 +207,7 @@ fn meta_section_name(os: os) -> ~str { // A diagnostic function for dumping crate metadata to an output stream fn list_file_metadata(os: os, path: ~str, out: io::writer) { - alt get_metadata_section(os, path) { + match get_metadata_section(os, path) { option::some(bytes) => decoder::list_crate_metadata(bytes, out), option::none => { out.write_str(~"could not find metadata in " + path + ~".\n"); diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index fee68f5592d..a834147af96 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -57,7 +57,7 @@ fn parse_ty_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt, } fn parse_ret_ty(st: @pstate, conv: conv_did) -> (ast::ret_style, ty::t) { - alt peek(st) { + match peek(st) { '!' => { next(st); (ast::noreturn, ty::mk_bot(st.tcx)) } _ => (ast::return_val, parse_ty(st, conv)) } @@ -68,7 +68,7 @@ fn parse_path(st: @pstate) -> @ast::path { fn is_last(c: char) -> bool { return c == '(' || c == ':'; } vec::push(idents, parse_ident_(st, is_last)); loop { - alt peek(st) { + match peek(st) { ':' => { next(st); next(st); } c => { if c == '(' { @@ -86,7 +86,7 @@ fn parse_ty_rust_fn(st: @pstate, conv: conv_did) -> ty::t { } fn parse_proto(c: char) -> ast::proto { - alt c { + match c { '~' => ast::proto_uniq, '@' => ast::proto_box, '&' => ast::proto_block, @@ -105,7 +105,7 @@ fn parse_vstore(st: @pstate) -> ty::vstore { return ty::vstore_fixed(n); } - alt check next(st) { + match check next(st) { '~' => ty::vstore_uniq, '@' => ty::vstore_box, '&' => ty::vstore_slice(parse_region(st)) @@ -128,7 +128,7 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { } fn parse_bound_region(st: @pstate) -> ty::bound_region { - alt check next(st) { + match check next(st) { 's' => ty::br_self, 'a' => ty::br_anon, '[' => ty::br_named(@parse_str(st, ']')), @@ -141,7 +141,7 @@ fn parse_bound_region(st: @pstate) -> ty::bound_region { } fn parse_region(st: @pstate) -> ty::region { - alt check next(st) { + match check next(st) { 'b' => { ty::re_bound(parse_bound_region(st)) } @@ -165,7 +165,7 @@ fn parse_region(st: @pstate) -> ty::region { } fn parse_opt<T>(st: @pstate, f: fn() -> T) -> option<T> { - alt check next(st) { + match check next(st) { 'n' => none, 's' => some(f()) } @@ -181,7 +181,7 @@ fn parse_str(st: @pstate, term: char) -> ~str { } fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { - alt check next(st) { + match check next(st) { 'n' => return ty::mk_nil(st.tcx), 'z' => return ty::mk_bot(st.tcx), 'b' => return ty::mk_bool(st.tcx), @@ -189,7 +189,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { 'u' => return ty::mk_uint(st.tcx), 'l' => return ty::mk_float(st.tcx), 'M' => { - alt check next(st) { + match check next(st) { 'b' => return ty::mk_mach_uint(st.tcx, ast::ty_u8), 'w' => return ty::mk_mach_uint(st.tcx, ast::ty_u16), 'l' => return ty::mk_mach_uint(st.tcx, ast::ty_u32), @@ -267,7 +267,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'Y' => return ty::mk_type(st.tcx), 'C' => { - let ck = alt check next(st) { + let ck = match check next(st) { '&' => ty::ck_block, '@' => ty::ck_box, '~' => ty::ck_uniq @@ -279,7 +279,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { assert (next(st) == ':'); let len = parse_hex(st); assert (next(st) == '#'); - alt st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) { + match st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) { some(tt) => return tt, none => { let ps = @{pos: pos with *st}; @@ -311,7 +311,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { let mut m; - alt peek(st) { + match peek(st) { 'm' => { next(st); m = ast::m_mutbl; } '?' => { next(st); m = ast::m_const; } _ => { m = ast::m_imm; } @@ -351,7 +351,7 @@ fn parse_hex(st: @pstate) -> uint { } fn parse_purity(c: char) -> purity { - alt check c { + match check c { 'u' => unsafe_fn, 'p' => pure_fn, 'i' => impure_fn, @@ -365,7 +365,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { assert (next(st) == '['); let mut inputs: ~[ty::arg] = ~[]; while peek(st) != ']' { - let mode = alt check peek(st) { + let mode = match check peek(st) { '&' => ast::by_mutbl_ref, '-' => ast::by_move, '+' => ast::by_copy, @@ -394,12 +394,12 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_part = vec::slice(buf, 0u, colon_idx); let def_part = vec::slice(buf, colon_idx + 1u, len); - let crate_num = alt uint::parse_buf(crate_part, 10u) { + let crate_num = match uint::parse_buf(crate_part, 10u) { some(cn) => cn as int, none => fail (fmt!{"internal error: parse_def_id: crate number \ expected, but found %?", crate_part}) }; - let def_num = alt uint::parse_buf(def_part, 10u) { + let def_num = match uint::parse_buf(def_part, 10u) { some(dn) => dn as int, none => fail (fmt!{"internal error: parse_def_id: id expected, but \ found %?", def_part}) @@ -417,7 +417,7 @@ fn parse_bounds_data(data: @~[u8], start: uint, fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] { let mut bounds = ~[]; loop { - vec::push(bounds, alt check next(st) { + vec::push(bounds, match check next(st) { 'S' => ty::bound_send, 'C' => ty::bound_copy, 'K' => ty::bound_const, diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index a9685dabba7..458dc149802 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -34,16 +34,16 @@ type ty_abbrev = {pos: uint, len: uint, s: @~str}; enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap<ty::t, ty_abbrev>), } fn cx_uses_abbrevs(cx: @ctxt) -> bool { - alt cx.abbrevs { + match cx.abbrevs { ac_no_abbrevs => return false, ac_use_abbrevs(_) => return true } } fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { - alt cx.abbrevs { + match cx.abbrevs { ac_no_abbrevs => { - let result_str = alt cx.tcx.short_names_cache.find(t) { + let result_str = match cx.tcx.short_names_cache.find(t) { some(s) => *s, none => { let buf = io::mem_buffer(); @@ -55,11 +55,11 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { w.write_str(result_str); } ac_use_abbrevs(abbrevs) => { - alt abbrevs.find(t) { + match abbrevs.find(t) { some(a) => { w.write_str(*a.s); return; } none => { let pos = w.tell(); - alt ty::type_def_id(t) { + match ty::type_def_id(t) { some(def_id) => { // Do not emit node ids that map to unexported names. Those // are not helpful. @@ -96,7 +96,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { } } fn enc_mt(w: io::writer, cx: @ctxt, mt: ty::mt) { - alt mt.mutbl { + match mt.mutbl { m_imm => (), m_mutbl => w.write_char('m'), m_const => w.write_char('?') @@ -105,7 +105,7 @@ fn enc_mt(w: io::writer, cx: @ctxt, mt: ty::mt) { } fn enc_opt<T>(w: io::writer, t: option<T>, enc_f: fn(T)) { - alt t { + match t { none => w.write_char('n'), some(v) => { w.write_char('s'); @@ -123,7 +123,7 @@ fn enc_substs(w: io::writer, cx: @ctxt, substs: ty::substs) { } fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) { - alt r { + match r { ty::re_bound(br) => { w.write_char('b'); enc_bound_region(w, br); @@ -152,7 +152,7 @@ fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) { } fn enc_bound_region(w: io::writer, br: ty::bound_region) { - alt br { + match br { ty::br_self => w.write_char('s'), ty::br_anon => w.write_char('a'), ty::br_named(s) => { @@ -171,7 +171,7 @@ fn enc_bound_region(w: io::writer, br: ty::bound_region) { fn enc_vstore(w: io::writer, cx: @ctxt, v: ty::vstore) { w.write_char('/'); - alt v { + match v { ty::vstore_fixed(u) => { w.write_uint(u); w.write_char('|'); @@ -190,12 +190,12 @@ fn enc_vstore(w: io::writer, cx: @ctxt, v: ty::vstore) { } fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { - alt st { + match st { ty::ty_nil => w.write_char('n'), ty::ty_bot => w.write_char('z'), ty::ty_bool => w.write_char('b'), ty::ty_int(t) => { - alt t { + match t { ty_i => w.write_char('i'), ty_char => w.write_char('c'), ty_i8 => w.write_str(&"MB"), @@ -205,7 +205,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { } } ty::ty_uint(t) => { - alt t { + match t { ty_u => w.write_char('u'), ty_u8 => w.write_str(&"Mb"), ty_u16 => w.write_str(&"Mw"), @@ -214,7 +214,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { } } ty::ty_float(t) => { - alt t { + match t { ty_f => w.write_char('l'), ty_f32 => w.write_str(&"Mf"), ty_f64 => w.write_str(&"MF"), @@ -307,7 +307,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { } } fn enc_proto(w: io::writer, proto: proto) { - alt proto { + match proto { proto_uniq => w.write_str(&"f~"), proto_box => w.write_str(&"f@"), proto_block => w.write_str(~"f&"), @@ -316,7 +316,7 @@ fn enc_proto(w: io::writer, proto: proto) { } fn enc_mode(w: io::writer, cx: @ctxt, m: mode) { - alt ty::resolved_mode(cx.tcx, m) { + match ty::resolved_mode(cx.tcx, m) { by_mutbl_ref => w.write_char('&'), by_move => w.write_char('-'), by_copy => w.write_char('+'), @@ -326,7 +326,7 @@ fn enc_mode(w: io::writer, cx: @ctxt, m: mode) { } fn enc_purity(w: io::writer, p: purity) { - alt p { + match p { pure_fn => w.write_char('p'), impure_fn => w.write_char('i'), unsafe_fn => w.write_char('u'), @@ -343,7 +343,7 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) { enc_ty(w, cx, arg.ty); } w.write_char(']'); - alt ft.ret_style { + match ft.ret_style { noreturn => w.write_char('!'), _ => enc_ty(w, cx, ft.output) } @@ -351,7 +351,7 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) { fn enc_bounds(w: io::writer, cx: @ctxt, bs: @~[ty::param_bound]) { for vec::each(*bs) |bound| { - alt bound { + match bound { ty::bound_send => w.write_char('S'), ty::bound_copy => w.write_char('C'), ty::bound_const => w.write_char('K'), diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 054c51bfe36..b1b54816998 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -111,7 +111,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, path: ast_map::path, par_doc: ebml::doc) -> option<ast::inlined_item> { let dcx = @{cdata: cdata, tcx: tcx, maps: maps}; - alt par_doc.opt_child(c::tag_ast) { + match par_doc.opt_child(c::tag_ast) { none => none, some(ast_doc) => { debug!{"> Decoding inlined fn: %s::?", ast_map::path_to_str(path)}; @@ -129,7 +129,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, decode_side_tables(xcx, ast_doc); debug!{"< Decoded inlined fn: %s::%s", ast_map::path_to_str(path), *ii.ident()}; - alt ii { + match ii { ast::ii_item(i) => { debug!{">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", syntax::print::pprust::item_to_str(i)}; @@ -245,7 +245,7 @@ fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) { fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ { let stmts_sans_items = do vec::filter(blk.stmts) |stmt| { - alt stmt.node { + match stmt.node { ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) => true, ast::stmt_decl(@{node: ast::decl_item(_), span: _}, _) => false @@ -260,7 +260,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { with *fold::default_ast_fold() }); - alt ii { + match ii { ast::ii_item(i) => { ast::ii_item(fld.fold_item(i).get()) //hack: we're not dropping items } @@ -300,7 +300,7 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item) with *fold::default_ast_fold() }); - alt ii { + match ii { ast::ii_item(i) => { ast::ii_item(fld.fold_item(i).get()) } @@ -352,7 +352,7 @@ fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def { impl of tr for ast::def { fn tr(xcx: extended_decode_ctxt) -> ast::def { - alt self { + match self { ast::def_fn(did, p) => ast::def_fn(did.tr(xcx), p), ast::def_self(nid) => ast::def_self(xcx.tr_id(nid)), ast::def_mod(did) => ast::def_mod(did.tr(xcx)), @@ -422,7 +422,7 @@ impl helper of read_method_map_entry_helper for ebml::ebml_deserializer { impl of tr for method_origin { fn tr(xcx: extended_decode_ctxt) -> method_origin { - alt self { + match self { typeck::method_static(did) => { typeck::method_static(did.tr(xcx)) } @@ -455,7 +455,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, ebml_w: ebml::writer, vtable_origin: typeck::vtable_origin) { do ebml_w.emit_enum(~"vtable_origin") { - alt vtable_origin { + match vtable_origin { typeck::vtable_static(def_id, tys, vtable_res) => { do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { @@ -508,7 +508,7 @@ impl helpers of vtable_deserialization_helpers for ebml::ebml_deserializer { -> typeck::vtable_origin { do self.read_enum(~"vtable_origin") { do self.read_enum_variant |i| { - alt check i { + match check i { 0u => { typeck::vtable_static( do self.read_enum_variant_arg(0u) { @@ -992,7 +992,7 @@ fn test_simplification() { return {eq_fn: eq_int, mut data: ~[]}; } }); - alt (item_out, item_exp) { + match (item_out, item_exp) { (ast::ii_item(item_out), ast::ii_item(item_exp)) => { assert pprust::item_to_str(item_out) == pprust::item_to_str(item_exp); } diff --git a/src/rustc/middle/block_use.rs b/src/rustc/middle/block_use.rs index 3f7ddd94eed..2896ad32d6a 100644 --- a/src/rustc/middle/block_use.rs +++ b/src/rustc/middle/block_use.rs @@ -13,7 +13,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) { if !cx.allow_block { - alt ty::get(ty::expr_ty(cx.tcx, ex)).struct { + match ty::get(ty::expr_ty(cx.tcx, ex)).struct { ty::ty_fn({proto: p, _}) if is_blockish(p) => { cx.tcx.sess.span_err(ex.span, ~"expressions with stack closure type \ @@ -23,7 +23,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) { } } let outer = cx.allow_block; - alt ex.node { + match ex.node { expr_call(f, args, _) => { cx.allow_block = true; v.visit_expr(f, cx, v); diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 4e9f770232f..3df0cb3b25e 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -91,7 +91,7 @@ In other cases, like an enum on the stack, the memory cannot be freed but its type can change: let mut x = some(5); - alt x { + match x { some(ref y) => { ... } none => { ... } } @@ -105,7 +105,7 @@ Finally, in some cases, both dangers can arise. For example, something like the following: let mut x = ~some(5); - alt x { + match x { ~some(ref y) => { ... } ~none => { ... } } @@ -343,7 +343,7 @@ enum categorization { cat_stack_upvar(cmt), // upvar in stack closure cat_deref(cmt, uint, ptr_kind), // deref of a ptr cat_comp(cmt, comp_kind), // adjust to locate an internal component - cat_discr(cmt, ast::node_id), // alt discriminant (see preserve()) + cat_discr(cmt, ast::node_id), // match discriminant (see preserve()) } // different kinds of pointers: @@ -456,7 +456,7 @@ impl methods of get_type_for_node for ty::ctxt { impl error_methods for borrowck_ctxt { fn report_if_err(bres: bckres<()>) { - alt bres { + match bres { ok(()) => (), err(e) => self.report(e) } @@ -478,7 +478,7 @@ impl error_methods for borrowck_ctxt { } fn add_to_mutbl_map(cmt: cmt) { - alt cmt.cat { + match cmt.cat { cat_local(id) | cat_arg(id) => { self.mutbl_map.insert(id, ()); } @@ -492,7 +492,7 @@ impl error_methods for borrowck_ctxt { impl to_str_methods for borrowck_ctxt { fn cat_to_repr(cat: categorization) -> ~str { - alt cat { + match cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static_item", cat_special(sk_self) => ~"self", @@ -514,7 +514,7 @@ impl to_str_methods for borrowck_ctxt { } fn mut_to_str(mutbl: ast::mutability) -> ~str { - alt mutbl { + match mutbl { m_mutbl => ~"mutable", m_const => ~"const", m_imm => ~"immutable" @@ -522,7 +522,7 @@ impl to_str_methods for borrowck_ctxt { } fn ptr_sigil(ptr: ptr_kind) -> ~str { - alt ptr { + match ptr { uniq_ptr => ~"~", gc_ptr => ~"@", region_ptr(_) => ~"&", @@ -531,7 +531,7 @@ impl to_str_methods for borrowck_ctxt { } fn comp_to_repr(comp: comp_kind) -> ~str { - alt comp { + match comp { comp_field(fld, _) => *fld, comp_index(*) => ~"[]", comp_tuple => ~"()", @@ -540,7 +540,7 @@ impl to_str_methods for borrowck_ctxt { } fn lp_to_str(lp: @loan_path) -> ~str { - alt *lp { + match *lp { lp_local(node_id) => { fmt!{"local(%d)", node_id} } @@ -569,7 +569,7 @@ impl to_str_methods for borrowck_ctxt { fn cmt_to_str(cmt: cmt) -> ~str { let mut_str = self.mut_to_str(cmt.mutbl); - alt cmt.cat { + match cmt.cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static item", cat_special(sk_self) => ~"self reference", @@ -589,7 +589,7 @@ impl to_str_methods for borrowck_ctxt { cat_comp(_, comp_tuple) => ~"tuple content", cat_comp(_, comp_variant(_)) => ~"enum content", cat_comp(_, comp_index(t, _)) => { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_evec(*) => mut_str + ~" vec content", ty::ty_estr(*) => mut_str + ~" str content", _ => mut_str + ~" indexed content" @@ -602,7 +602,7 @@ impl to_str_methods for borrowck_ctxt { } fn bckerr_code_to_str(code: bckerr_code) -> ~str { - alt code { + match code { err_mutbl(req, act) => { fmt!{"creating %s alias to aliasable, %s memory", self.mut_to_str(req), self.mut_to_str(act)} @@ -644,7 +644,7 @@ impl to_str_methods for borrowck_ctxt { // mutability can be "overridden" if the component is embedded in a // mutable structure. fn inherent_mutability(ck: comp_kind) -> mutability { - alt ck { + match ck { comp_tuple | comp_variant(_) => m_imm, comp_field(_, m) | comp_index(_, m) => m } diff --git a/src/rustc/middle/borrowck/categorization.rs b/src/rustc/middle/borrowck/categorization.rs index f3d39aa91ef..e113c957c15 100644 --- a/src/rustc/middle/borrowck/categorization.rs +++ b/src/rustc/middle/borrowck/categorization.rs @@ -43,7 +43,7 @@ export opt_deref_kind; // derefable (we model an index as the combination of a deref and then a // pointer adjustment). fn opt_deref_kind(t: ty::t) -> option<deref_kind> { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_uniq(*) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) => { @@ -83,7 +83,7 @@ fn opt_deref_kind(t: ty::t) -> option<deref_kind> { } fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind { - alt opt_deref_kind(t) { + match opt_deref_kind(t) { some(k) => k, none => { tcx.sess.bug( @@ -97,7 +97,7 @@ impl public_methods for borrowck_ctxt { fn cat_borrow_of_expr(expr: @ast::expr) -> cmt { // a borrowed expression must be either an @, ~, or a @vec, ~vec let expr_ty = ty::expr_ty(self.tcx, expr); - alt ty::get(expr_ty).struct { + match ty::get(expr_ty).struct { ty::ty_evec(*) | ty::ty_estr(*) => { self.cat_index(expr, expr) } @@ -128,14 +128,14 @@ impl public_methods for borrowck_ctxt { let tcx = self.tcx; let expr_ty = tcx.ty(expr); - alt expr.node { + match expr.node { ast::expr_unary(ast::deref, e_base) => { if self.method_map.contains_key(expr.id) { return self.cat_rvalue(expr, expr_ty); } let base_cmt = self.cat_expr(e_base); - alt self.cat_deref(expr, base_cmt, 0u, true) { + match self.cat_deref(expr, base_cmt, 0u, true) { some(cmt) => return cmt, none => { tcx.sess.span_bug( @@ -190,7 +190,7 @@ impl public_methods for borrowck_ctxt { span: span, expr_ty: ty::t, def: ast::def) -> cmt { - alt def { + match def { ast::def_fn(*) | ast::def_mod(_) | ast::def_foreign_mod(_) | ast::def_const(_) | ast::def_use(_) | ast::def_variant(*) | @@ -208,7 +208,7 @@ impl public_methods for borrowck_ctxt { // m: mutability of the argument // lp: loan path, must be none for aliasable things - let {m,lp} = alt ty::resolved_mode(self.tcx, mode) { + let {m,lp} = match ty::resolved_mode(self.tcx, mode) { ast::by_mutbl_ref => { {m: m_mutbl, lp: none} } @@ -241,7 +241,7 @@ impl public_methods for borrowck_ctxt { ast::def_upvar(upvid, inner, fn_node_id) => { let ty = ty::node_id_to_type(self.tcx, fn_node_id); let proto = ty::ty_fn_proto(ty); - alt proto { + match proto { ast::proto_block => { let upcmt = self.cat_def(id, span, expr_ty, *inner); @{id:id, span:span, @@ -311,7 +311,7 @@ impl public_methods for borrowck_ctxt { /// or if the container is mutable. fn inherited_mutability(base_m: ast::mutability, comp_m: ast::mutability) -> ast::mutability { - alt comp_m { + match comp_m { m_imm => {base_m} // imm: as mutable as the container m_mutbl | m_const => {comp_m} } @@ -319,7 +319,7 @@ impl public_methods for borrowck_ctxt { fn cat_field<N:ast_node>(node: N, base_cmt: cmt, f_name: ast::ident) -> cmt { - let f_mutbl = alt field_mutbl(self.tcx, base_cmt.ty, f_name) { + let f_mutbl = match field_mutbl(self.tcx, base_cmt.ty, f_name) { some(f_mutbl) => f_mutbl, none => { self.tcx.sess.span_bug( @@ -339,7 +339,7 @@ impl public_methods for borrowck_ctxt { fn cat_deref<N:ast_node>(node: N, base_cmt: cmt, derefs: uint, expl: bool) -> option<cmt> { do ty::deref(self.tcx, base_cmt.ty, expl).map |mt| { - alt deref_kind(self.tcx, base_cmt.ty) { + match deref_kind(self.tcx, base_cmt.ty) { deref_ptr(ptr) => { let lp = do base_cmt.lp.chain |l| { // Given that the ptr itself is loanable, we can @@ -347,7 +347,7 @@ impl public_methods for borrowck_ctxt { // the only way to reach the data they point at. // Other ptr types admit aliases and are therefore // not loanable. - alt ptr { + match ptr { uniq_ptr => {some(@lp_deref(l, ptr))} gc_ptr | region_ptr(_) | unsafe_ptr => {none} } @@ -355,7 +355,7 @@ impl public_methods for borrowck_ctxt { // for unique ptrs, we inherit mutability from the // owning reference. - let m = alt ptr { + let m = match ptr { uniq_ptr => { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } @@ -383,7 +383,7 @@ impl public_methods for borrowck_ctxt { fn cat_index(expr: @ast::expr, base: @ast::expr) -> cmt { let base_cmt = self.cat_autoderef(base); - let mt = alt ty::index(self.tcx, base_cmt.ty) { + let mt = match ty::index(self.tcx, base_cmt.ty) { some(mt) => mt, none => { self.tcx.sess.span_bug( @@ -393,18 +393,18 @@ impl public_methods for borrowck_ctxt { } }; - return alt deref_kind(self.tcx, base_cmt.ty) { + return match deref_kind(self.tcx, base_cmt.ty) { deref_ptr(ptr) => { // (a) the contents are loanable if the base is loanable // and this is a *unique* vector - let deref_lp = alt ptr { + let deref_lp = match ptr { uniq_ptr => {base_cmt.lp.map(|lp| @lp_deref(lp, uniq_ptr))} _ => {none} }; // (b) for unique ptrs, we inherit mutability from the // owning reference. - let m = alt ptr { + let m = match ptr { uniq_ptr => { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } @@ -465,7 +465,7 @@ impl private_methods for borrowck_ctxt { let mut ctr = 0u; loop { ctr += 1u; - alt self.cat_deref(base, cmt, ctr, false) { + match self.cat_deref(base, cmt, ctr, false) { none => return cmt, some(cmt1) => cmt = cmt1 } @@ -477,7 +477,7 @@ fn field_mutbl(tcx: ty::ctxt, base_ty: ty::t, f_name: ast::ident) -> option<ast::mutability> { // Need to refactor so that records/class fields can be treated uniformly. - alt ty::get(base_ty).struct { + match ty::get(base_ty).struct { ty::ty_rec(fields) => { for fields.each |f| { if f.ident == f_name { @@ -488,7 +488,7 @@ fn field_mutbl(tcx: ty::ctxt, ty::ty_class(did, substs) => { for ty::lookup_class_fields(tcx, did).each |fld| { if fld.ident == f_name { - let m = alt fld.mutability { + let m = match fld.mutability { ast::class_mutable => ast::m_mutbl, ast::class_immutable => ast::m_imm }; diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index f84fca5c197..9b7d0e037c1 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -64,14 +64,14 @@ impl methods for assignment_type { fn checked_by_liveness() -> bool { // the liveness pass guarantees that immutable local variables // are only assigned once; but it doesn't consider &mut - alt self { + match self { at_straight_up => true, at_swap => true, at_mutbl_ref => false } } fn ing_form(desc: ~str) -> ~str { - alt self { + match self { at_straight_up => ~"assigning to " + desc, at_swap => ~"swapping to and from " + desc, at_mutbl_ref => ~"taking mut reference to " + desc @@ -83,7 +83,7 @@ impl methods for check_loan_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } fn purity(scope_id: ast::node_id) -> option<purity_cause> { - let default_purity = alt self.declared_purity { + let default_purity = match self.declared_purity { // an unsafe declaration overrides all ast::unsafe_fn => return none, @@ -101,12 +101,12 @@ impl methods for check_loan_ctxt { let region_map = self.tcx().region_map; let pure_map = self.req_maps.pure_map; loop { - alt pure_map.find(scope_id) { + match pure_map.find(scope_id) { none => (), some(e) => return some(pc_cmt(e)) } - alt region_map.find(scope_id) { + match region_map.find(scope_id) { none => return default_purity, some(next_scope_id) => scope_id = next_scope_id } @@ -128,7 +128,7 @@ impl methods for check_loan_ctxt { } } - alt region_map.find(scope_id) { + match region_map.find(scope_id) { none => return, some(next_scope_id) => scope_id = next_scope_id, } @@ -173,9 +173,9 @@ impl methods for check_loan_ctxt { // (c) B is a pure fn; // (d) B is not a fn. - alt opt_expr { + match opt_expr { some(expr) => { - alt expr.node { + match expr.node { ast::expr_path(_) if pc == pc_pure_fn => { let def = self.tcx().def_map.get(expr.id); let did = ast_util::def_id_of_def(def); @@ -198,9 +198,9 @@ impl methods for check_loan_ctxt { } let callee_ty = ty::node_id_to_type(tcx, callee_id); - alt ty::get(callee_ty).struct { + match ty::get(callee_ty).struct { ty::ty_fn(fn_ty) => { - alt fn_ty.purity { + match fn_ty.purity { ast::pure_fn => return, // case (c) above ast::impure_fn | ast::unsafe_fn | ast::extern_fn => { self.report_purity_error( @@ -219,14 +219,14 @@ impl methods for check_loan_ctxt { fn is_stack_closure(id: ast::node_id) -> bool { let fn_ty = ty::node_id_to_type(self.tcx(), id); let proto = ty::ty_fn_proto(fn_ty); - alt proto { + match proto { ast::proto_block => true, ast::proto_bare | ast::proto_uniq | ast::proto_box => false } } fn is_allowed_pure_arg(expr: @ast::expr) -> bool { - return alt expr.node { + return match expr.node { ast::expr_path(_) => { let def = self.tcx().def_map.get(expr.id); let did = ast_util::def_id_of_def(def); @@ -241,7 +241,7 @@ impl methods for check_loan_ctxt { } fn check_for_conflicting_loans(scope_id: ast::node_id) { - let new_loanss = alt self.req_maps.req_loan_map.find(scope_id) { + let new_loanss = match self.req_maps.req_loan_map.find(scope_id) { none => return, some(loanss) => loanss }; @@ -251,7 +251,7 @@ impl methods for check_loan_ctxt { for (*new_loanss).each |new_loans| { for (*new_loans).each |new_loan| { if old_loan.lp != new_loan.lp { again; } - alt (old_loan.mutbl, new_loan.mutbl) { + match (old_loan.mutbl, new_loan.mutbl) { (m_const, _) | (_, m_const) | (m_mutbl, m_mutbl) | (m_imm, m_imm) => { /*ok*/ @@ -276,16 +276,16 @@ impl methods for check_loan_ctxt { } fn is_local_variable(cmt: cmt) -> bool { - alt cmt.cat { + match cmt.cat { cat_local(_) => true, _ => false } } fn is_self_field(cmt: cmt) -> bool { - alt cmt.cat { + match cmt.cat { cat_comp(cmt_base, comp_field(*)) => { - alt cmt_base.cat { + match cmt_base.cat { cat_special(sk_self) => true, _ => false } @@ -307,7 +307,7 @@ impl methods for check_loan_ctxt { // liveness guarantees that immutable local variables // are only assigned once } else { - alt cmt.mutbl { + match cmt.mutbl { m_mutbl => { /*ok*/ } m_const | m_imm => { self.bccx.span_err( @@ -321,7 +321,7 @@ impl methods for check_loan_ctxt { // if this is a pure function, only loan-able state can be // assigned, because it is uniquely tied to this function and // is not visible from the outside - alt self.purity(ex.id) { + match self.purity(ex.id) { none => (), some(pc) => { if cmt.lp.is_none() { @@ -352,7 +352,7 @@ impl methods for check_loan_ctxt { lp: @loan_path) { for self.walk_loans_of(ex.id, lp) |loan| { - alt loan.mutbl { + match loan.mutbl { m_mutbl | m_const => { /*ok*/ } m_imm => { self.bccx.span_err( @@ -375,7 +375,7 @@ impl methods for check_loan_ctxt { // let mut x = {f: some(3)}; // let y = &x; // x loaned out as immutable // x.f = none; // changes type of y.f, which appears to be imm - alt *lp { + match *lp { lp_comp(lp_base, ck) if inherent_mutability(ck) != m_mutbl => { self.check_for_loan_conflicting_with_assignment( at, ex, cmt, lp_base); @@ -385,7 +385,7 @@ impl methods for check_loan_ctxt { } fn report_purity_error(pc: purity_cause, sp: span, msg: ~str) { - alt pc { + match pc { pc_pure_fn => { self.tcx().sess.span_err( sp, @@ -414,7 +414,7 @@ impl methods for check_loan_ctxt { debug!{"check_move_out_from_cmt(cmt=%s)", self.bccx.cmt_to_repr(cmt)}; - alt cmt.cat { + match cmt.cat { // Rvalues, locals, and arguments can be moved: cat_rvalue | cat_local(_) | cat_arg(_) => {} @@ -437,7 +437,7 @@ impl methods for check_loan_ctxt { self.bccx.add_to_mutbl_map(cmt); // check for a conflicting loan: - let lp = alt cmt.lp { + let lp = match cmt.lp { none => return, some(lp) => lp }; @@ -459,7 +459,7 @@ impl methods for check_loan_ctxt { // safe to consider the use a last_use. fn check_last_use(expr: @ast::expr) { let cmt = self.bccx.cat_expr(expr); - let lp = alt cmt.lp { + let lp = match cmt.lp { none => return, some(lp) => lp }; @@ -476,7 +476,7 @@ impl methods for check_loan_ctxt { callee_id: ast::node_id, callee_span: span, args: ~[@ast::expr]) { - alt self.purity(expr.id) { + match self.purity(expr.id) { none => {} some(pc) => { self.check_pure_callee_or_arg( @@ -491,7 +491,7 @@ impl methods for check_loan_ctxt { ty::ty_fn_args( ty::node_id_to_type(self.tcx(), callee_id)); do vec::iter2(args, arg_tys) |arg, arg_ty| { - alt ty::resolved_mode(self.tcx(), arg_ty.mode) { + match ty::resolved_mode(self.tcx(), arg_ty.mode) { ast::by_move => { self.check_move_out(arg); } @@ -521,7 +521,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, // of otherwise immutable fields and typestate wouldn't be // able to "see" into those functions anyway, so it // wouldn't be very helpful. - alt fk { + match fk { visit::fk_ctor(*) => { self.in_ctor = true; self.declared_purity = decl.purity; @@ -551,7 +551,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, fn check_loans_in_local(local: @ast::local, &&self: check_loan_ctxt, vt: visit::vt<check_loan_ctxt>) { - alt local.node.init { + match local.node.init { some({op: ast::init_move, expr: expr}) => { self.check_move_out(expr); } @@ -565,7 +565,7 @@ fn check_loans_in_expr(expr: @ast::expr, vt: visit::vt<check_loan_ctxt>) { self.check_for_conflicting_loans(expr.id); - alt expr.node { + match expr.node { ast::expr_path(*) if self.bccx.last_use_map.contains_key(expr.id) => { self.check_last_use(expr); } @@ -601,7 +601,7 @@ fn check_loans_in_expr(expr: @ast::expr, } } ast::expr_addr_of(mutbl, base) => { - alt mutbl { + match mutbl { m_const => { /*all memory is const*/ } m_mutbl => { // If we are taking an &mut ptr, make sure the memory @@ -645,7 +645,7 @@ fn check_loans_in_block(blk: ast::blk, do save_and_restore(self.declared_purity) { self.check_for_conflicting_loans(blk.node.id); - alt blk.node.rules { + match blk.node.rules { ast::default_blk => { } ast::unchecked_blk => { diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index 88e329f63c0..86455652faa 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -70,7 +70,7 @@ fn req_loans_in_fn(fk: visit::fn_kind, let old_root_ub = self.root_ub; self.root_ub = body.node.id; - alt fk { + match fk { visit::fk_anon(*) | visit::fk_fn_block(*) => {} visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_ctor(*) | visit::fk_dtor(*) => { @@ -99,14 +99,14 @@ fn req_loans_in_expr(ex: @ast::expr, } // Special checks for various kinds of expressions: - alt ex.node { + match ex.node { ast::expr_addr_of(mutbl, base) => { let base_cmt = self.bccx.cat_expr(base); // make sure that the thing we are pointing out stays valid // for the lifetime `scope_r` of the resulting ptr: let scope_r = - alt check ty::get(tcx.ty(ex)).struct { + match check ty::get(tcx.ty(ex)).struct { ty::ty_rptr(r, _) => r }; self.guarantee_valid(base_cmt, mutbl, scope_r); @@ -117,7 +117,7 @@ fn req_loans_in_expr(ex: @ast::expr, let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f)); let scope_r = ty::re_scope(ex.id); do vec::iter2(args, arg_tys) |arg, arg_ty| { - alt ty::resolved_mode(self.tcx(), arg_ty.mode) { + match ty::resolved_mode(self.tcx(), arg_ty.mode) { ast::by_mutbl_ref => { let arg_cmt = self.bccx.cat_expr(arg); self.guarantee_valid(arg_cmt, m_mutbl, scope_r); @@ -151,7 +151,7 @@ fn req_loans_in_expr(ex: @ast::expr, // immutable (whereas something like {f:int} would be // fine). // - alt opt_deref_kind(arg_ty.ty) { + match opt_deref_kind(arg_ty.ty) { some(deref_ptr(region_ptr(_))) | some(deref_ptr(unsafe_ptr)) => { /* region pointers are (by induction) guaranteed */ @@ -265,7 +265,7 @@ impl methods for gather_loan_ctxt { region_to_str(self.tcx(), scope_r)}; let _i = indenter(); - alt cmt.lp { + match cmt.lp { // If this expression is a loanable path, we MUST take out a // loan. This is somewhat non-obvious. You might think, // for example, that if we have an immutable local variable @@ -277,11 +277,11 @@ impl methods for gather_loan_ctxt { // it within that scope, the loan will be detected and an // error will be reported. some(_) => { - alt self.bccx.loan(cmt, scope_r, req_mutbl) { + match self.bccx.loan(cmt, scope_r, req_mutbl) { err(e) => { self.bccx.report(e); } ok(loans) if loans.len() == 0 => {} ok(loans) => { - alt scope_r { + match scope_r { ty::re_scope(scope_id) => { self.add_loans(scope_id, loans); @@ -325,7 +325,7 @@ impl methods for gather_loan_ctxt { } }; - alt result { + match result { ok(pc_ok) => { // we were able guarantee the validity of the ptr, // perhaps by rooting or because it is immutably @@ -335,7 +335,7 @@ impl methods for gather_loan_ctxt { ok(pc_if_pure(e)) => { // we are only able to guarantee the validity if // the scope is pure - alt scope_r { + match scope_r { ty::re_scope(pure_id) => { // if the scope is some block/expr in the fn, // then just require that this scope be pure @@ -374,7 +374,7 @@ impl methods for gather_loan_ctxt { // mutable memory. fn check_mutbl(req_mutbl: ast::mutability, cmt: cmt) -> bckres<preserve_condition> { - alt (req_mutbl, cmt.mutbl) { + match (req_mutbl, cmt.mutbl) { (m_const, _) | (m_imm, m_imm) | (m_mutbl, m_mutbl) => { @@ -397,7 +397,7 @@ impl methods for gather_loan_ctxt { } fn add_loans(scope_id: ast::node_id, loans: @dvec<loan>) { - alt self.req_maps.req_loan_map.find(scope_id) { + match self.req_maps.req_loan_map.find(scope_id) { some(l) => { (*l).push(loans); } @@ -432,7 +432,7 @@ impl methods for gather_loan_ctxt { // To see what I mean about ids etc, consider: // // let x = @@3; - // alt x { + // match x { // @@y { ... } // } // @@ -450,7 +450,7 @@ impl methods for gather_loan_ctxt { let _i = indenter(); let tcx = self.tcx(); - alt pat.node { + match pat.node { ast::pat_wild => { // _ } @@ -460,7 +460,7 @@ impl methods for gather_loan_ctxt { } ast::pat_enum(_, some(subpats)) => { // variant(x, y, z) - let enum_did = alt self.bccx.tcx.def_map + let enum_did = match self.bccx.tcx.def_map .find(pat.id) { some(ast::def_variant(enum_did, _)) => enum_did, e => tcx.sess.span_bug(pat.span, @@ -523,7 +523,7 @@ impl methods for gather_loan_ctxt { ast::pat_box(subpat) | ast::pat_uniq(subpat) => { // @p1, ~p1 - alt self.bccx.cat_deref(subpat, cmt, 0u, true) { + match self.bccx.cat_deref(subpat, cmt, 0u, true) { some(subcmt) => { self.gather_pat(subcmt, subpat, arm_id, alt_id); } diff --git a/src/rustc/middle/borrowck/loan.rs b/src/rustc/middle/borrowck/loan.rs index 5479afd10b7..59e3cd183fc 100644 --- a/src/rustc/middle/borrowck/loan.rs +++ b/src/rustc/middle/borrowck/loan.rs @@ -12,7 +12,7 @@ impl public_methods for borrowck_ctxt { let lc = loan_ctxt_(@{bccx: self, scope_region: scope_region, loans: @dvec()}); - alt lc.loan(cmt, mutbl) { + match lc.loan(cmt, mutbl) { ok(()) => {ok(lc.loans)} err(e) => {err(e)} } @@ -70,7 +70,7 @@ impl loan_methods for loan_ctxt { ~"loan() called with non-lendable value"); } - alt cmt.cat { + match cmt.cat { cat_binding(_) | cat_rvalue | cat_special(_) => { // should never be loanable self.bccx.tcx.sess.span_bug( @@ -131,7 +131,7 @@ impl loan_methods for loan_ctxt { fn loan_stable_comp(cmt: cmt, cmt_base: cmt, req_mutbl: ast::mutability) -> bckres<()> { - let base_mutbl = alt req_mutbl { + let base_mutbl = match req_mutbl { m_imm => m_imm, m_const | m_mutbl => m_const }; diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index 568030c85b5..a586aca24f3 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -14,7 +14,7 @@ impl public_methods for preserve_condition { // combines two preservation conditions such that if either of // them requires purity, the result requires purity fn combine(pc: preserve_condition) -> preserve_condition { - alt self { + match self { pc_ok => {pc} pc_if_pure(e) => {self} } @@ -63,7 +63,7 @@ impl private_methods for &preserve_ctxt { self.root_managed_data}; let _i = indenter(); - alt cmt.cat { + match cmt.cat { cat_special(sk_self) | cat_special(sk_heap_upvar) => { self.compare_scope(cmt, ty::re_scope(self.item_ub)) } @@ -160,7 +160,7 @@ impl private_methods for &preserve_ctxt { if base.mutbl == m_imm { let non_rooting_ctxt = preserve_ctxt({root_managed_data: false with **self}); - alt (&non_rooting_ctxt).preserve(base) { + match (&non_rooting_ctxt).preserve(base) { ok(pc_ok) => { ok(pc_ok) } @@ -191,7 +191,7 @@ impl private_methods for &preserve_ctxt { // As an example, consider this scenario: // // let mut x = @some(3); - // alt *x { some(y) {...} none {...} } + // match *x { some(y) {...} none {...} } // // Technically, the value `x` need only be rooted // in the `some` arm. However, we evaluate `x` in trans @@ -201,7 +201,7 @@ impl private_methods for &preserve_ctxt { // As a second example, consider *this* scenario: // // let x = @mut @some(3); - // alt x { @@some(y) {...} @@none {...} } + // match x { @@some(y) {...} @@none {...} } // // Here again, `x` need only be rooted in the `some` arm. // In this case, the value which needs to be rooted is @@ -220,7 +220,7 @@ impl private_methods for &preserve_ctxt { // also yielded suboptimal results for patterns like: // // let x = @mut @...; - // alt x { @@some_variant(y) | @@some_other_variant(y) {...} } + // match x { @@some_variant(y) | @@some_other_variant(y) => // // The reason is that we would root the value once for // each pattern and not once per arm. This is also easily @@ -234,7 +234,7 @@ impl private_methods for &preserve_ctxt { // current scope must be the arm, which is always a child of alt: assert { - alt check self.scope_region { + match check self.scope_region { ty::re_scope(arm_id) => { self.tcx().region_map.get(arm_id) == alt_id } @@ -259,11 +259,11 @@ impl private_methods for &preserve_ctxt { code: bckerr_code) -> bckres<preserve_condition> { // Variant contents and unique pointers: must be immutably // rooted to a preserved address. - alt self.preserve(cmt_base) { + match self.preserve(cmt_base) { // the base is preserved, but if we are not mutable then // purity is required ok(pc_ok) => { - alt cmt_base.mutbl { + match cmt_base.mutbl { m_mutbl | m_const => { ok(pc_if_pure({cmt:cmt, code:code})) } @@ -322,7 +322,7 @@ impl private_methods for &preserve_ctxt { } let root_region = ty::re_scope(self.root_ub); - alt self.scope_region { + match self.scope_region { // we can only root values if the desired region is some concrete // scope within the fn body ty::re_scope(scope_id) => { diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index 1af377e1ba2..266c31b2805 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -101,14 +101,14 @@ fn compute_capture_vars(tcx: ty::ctxt, // now go through anything that is referenced but was not explicitly // named and add that - let implicit_mode = alt fn_proto { + let implicit_mode = match fn_proto { ast::proto_block => cap_ref, ast::proto_bare | ast::proto_box | ast::proto_uniq => cap_copy }; do vec::iter(*freevars) |fvar| { let fvar_def_id = ast_util::def_id_of_def(fvar.def).node; - alt cap_map.find(fvar_def_id) { + match cap_map.find(fvar_def_id) { option::some(_) => { /* was explicitly named, do nothing */ } option::none => { cap_map.insert(fvar_def_id, {def:fvar.def, diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 28fbfacb78c..7ccccbbcc07 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -22,7 +22,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) { visit::visit_expr(ex, s, v); - alt ex.node { + match ex.node { expr_alt(scrut, arms, mode) => { check_arms(tcx, arms); /* Check for exhaustiveness */ @@ -33,7 +33,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) { // Vacuously exhaustive return; } - alt ty::get(pat_ty).struct { + match ty::get(pat_ty).struct { ty_enum(did, _) => { if (*enum_variants(tcx, did)).is_empty() && arms.is_empty() { @@ -58,7 +58,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { for arms.each |arm| { for arm.pats.each |pat| { let v = ~[pat]; - alt is_useful(tcx, seen, v) { + match is_useful(tcx, seen, v) { not_useful => { tcx.sess.span_err(pat.span, ~"unreachable pattern"); } @@ -70,7 +70,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { } fn raw_pat(p: @pat) -> @pat { - alt p.node { + match p.node { pat_ident(_, _, some(s)) => { raw_pat(s) } _ => { p } } @@ -78,20 +78,20 @@ fn raw_pat(p: @pat) -> @pat { fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { assert(pats.is_not_empty()); - let ext = alt is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) { + let ext = match is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) { not_useful => return, // This is good, wildcard pattern isn't reachable useful_ => none, useful(ty, ctor) => { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_bool => { - alt check ctor { + match check ctor { val(const_int(1i64)) => some(@~"true"), val(const_int(0i64)) => some(@~"false") } } ty::ty_enum(id, _) => { - let vid = alt check ctor { variant(id) => id }; - alt check vec::find(*ty::enum_variants(tcx, id), + let vid = match check ctor { variant(id) => id }; + match check vec::find(*ty::enum_variants(tcx, id), |v| v.id == vid) { some(v) => some(v.name) } @@ -100,7 +100,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { } } }; - let msg = ~"non-exhaustive patterns" + alt ext { + let msg = ~"non-exhaustive patterns" + match ext { some(s) => ~": " + *s + ~" not covered", none => ~"" }; @@ -134,19 +134,19 @@ enum ctor { fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { if m.len() == 0u { return useful_; } if m[0].len() == 0u { return not_useful; } - let real_pat = alt vec::find(m, |r| r[0].id != 0) { + let real_pat = match vec::find(m, |r| r[0].id != 0) { some(r) => r[0], none => v[0] }; let left_ty = if real_pat.id == 0 { ty::mk_nil(tcx) } else { ty::node_id_to_type(tcx, real_pat.id) }; - alt pat_ctor_id(tcx, v[0]) { + match pat_ctor_id(tcx, v[0]) { none => { - alt missing_ctor(tcx, m, left_ty) { + match missing_ctor(tcx, m, left_ty) { none => { - alt ty::get(left_ty).struct { + match ty::get(left_ty).struct { ty::ty_bool => { - alt is_useful_specialized(tcx, m, v, val(const_int(1i64)), + match is_useful_specialized(tcx, m, v, val(const_int(1i64)), 0u, left_ty){ not_useful => { is_useful_specialized(tcx, m, v, val(const_int(0i64)), @@ -157,7 +157,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { } ty::ty_enum(eid, _) => { for (*ty::enum_variants(tcx, eid)).each |va| { - alt is_useful_specialized(tcx, m, v, variant(va.id), + match is_useful_specialized(tcx, m, v, variant(va.id), va.args.len(), left_ty) { not_useful => (), u => return u @@ -172,7 +172,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { } } some(ctor) => { - alt is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ), + match is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ), vec::tail(v)) { useful_ => useful(left_ty, ctor), u => u @@ -190,7 +190,9 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor, arity: uint, lty: ty::t) -> useful { let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) ); - alt is_useful(tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))){ + let could_be_useful = is_useful( + tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))); + match could_be_useful { useful_ => useful(lty, ctor), u => u } @@ -198,10 +200,10 @@ fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor, fn pat_ctor_id(tcx: ty::ctxt, p: @pat) -> option<ctor> { let pat = raw_pat(p); - alt pat.node { + match pat.node { pat_wild => { none } pat_ident(_, _, _) | pat_enum(_, _) => { - alt tcx.def_map.find(pat.id) { + match tcx.def_map.find(pat.id) { some(def_variant(_, id)) => some(variant(id)), _ => none } @@ -218,10 +220,10 @@ fn pat_ctor_id(tcx: ty::ctxt, p: @pat) -> option<ctor> { fn is_wild(tcx: ty::ctxt, p: @pat) -> bool { let pat = raw_pat(p); - alt pat.node { + match pat.node { pat_wild => { true } pat_ident(_, _, _) => { - alt tcx.def_map.find(pat.id) { + match tcx.def_map.find(pat.id) { some(def_variant(_, _)) => { false } _ => { true } } @@ -231,7 +233,7 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool { } fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { - alt ty::get(left_ty).struct { + match ty::get(left_ty).struct { ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_tup(_) | ty::ty_rec(_) => { for m.each |r| { if !is_wild(tcx, r[0]) { return none; } @@ -259,7 +261,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { ty::ty_bool => { let mut true_found = false, false_found = false; for m.each |r| { - alt check pat_ctor_id(tcx, r[0]) { + match check pat_ctor_id(tcx, r[0]) { none => (), some(val(const_int(1i64))) => true_found = true, some(val(const_int(0i64))) => false_found = true @@ -274,13 +276,13 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { } fn ctor_arity(tcx: ty::ctxt, ctor: ctor, ty: ty::t) -> uint { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_tup(fs) => fs.len(), ty::ty_rec(fs) => fs.len(), ty::ty_box(_) | ty::ty_uniq(_) => 1u, ty::ty_enum(eid, _) => { - let id = alt check ctor { variant(id) => id }; - alt check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) { + let id = match check ctor { variant(id) => id }; + match check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) { some(v) => v.args.len() } } @@ -295,11 +297,11 @@ fn wild() -> @pat { fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, left_ty: ty::t) -> option<~[@pat]> { let r0 = raw_pat(r[0]); - alt r0.node { + match r0.node { pat_wild => some(vec::append(vec::from_elem(arity, wild()), vec::tail(r))), pat_ident(_, _, _) => { - alt tcx.def_map.find(r0.id) { + match tcx.def_map.find(r0.id) { some(def_variant(_, id)) => { if variant(id) == ctor_id { some(vec::tail(r)) } else { none } @@ -308,9 +310,9 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, } } pat_enum(_, args) => { - alt check tcx.def_map.get(r0.id) { + match check tcx.def_map.get(r0.id) { def_variant(_, id) if variant(id) == ctor_id => { - let args = alt args { + let args = match args { some(args) => args, none => vec::from_elem(arity, wild()) }; @@ -320,11 +322,11 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, } } pat_rec(flds, _) => { - let ty_flds = alt check ty::get(left_ty).struct { + let ty_flds = match check ty::get(left_ty).struct { ty::ty_rec(flds) => flds }; let args = vec::map(ty_flds, |ty_f| { - alt vec::find(flds, |f| f.ident == ty_f.ident ) { + match vec::find(flds, |f| f.ident == ty_f.ident ) { some(f) => f.pat, _ => wild() } }); @@ -334,7 +336,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, pat_box(a) | pat_uniq(a) => some(vec::append(~[a], vec::tail(r))), pat_lit(expr) => { let e_v = eval_const_expr(tcx, expr); - let match_ = alt check ctor_id { + let match_ = match check ctor_id { val(v) => compare_const_vals(e_v, v) == 0, range(c_lo, c_hi) => { compare_const_vals(c_lo, e_v) >= 0 && @@ -345,7 +347,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, if match_ { some(vec::tail(r)) } else { none } } pat_range(lo, hi) => { - let (c_lo, c_hi) = alt check ctor_id { + let (c_lo, c_hi) = match check ctor_id { val(v) => (v, v), range(lo, hi) => (lo, hi), single => return some(vec::tail(r)), @@ -373,14 +375,14 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) { } fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool { - alt tcx.def_map.find(pat.id) { + match tcx.def_map.find(pat.id) { some(def_variant(enum_id, var_id)) => { if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { return true; } } _ => () } - alt pat.node { + match pat.node { pat_box(sub) | pat_uniq(sub) | pat_ident(_, _, some(sub)) => { is_refutable(tcx, sub) } diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 4d2ffa4b3e9..36b0908f435 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -20,7 +20,7 @@ fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map, fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve3::DefMap, it: @item, &&_is_const: bool, v: visit::vt<bool>) { - alt it.node { + match it.node { item_const(_, ex) => { v.visit_expr(ex, true, v); check_item_recursion(sess, ast_map, def_map, it); @@ -38,13 +38,13 @@ fn check_item(sess: session, ast_map: ast_map::map, fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) { fn is_str(e: @expr) -> bool { - alt e.node { + match e.node { expr_vstore(@{node: expr_lit(@{node: lit_str(_), _}), _}, vstore_uniq) => true, _ => false } } - alt p.node { + match p.node { // Let through plain ~-string literals here pat_lit(a) => if !is_str(a) { v.visit_expr(a, true, v); } pat_range(a, b) => { @@ -59,7 +59,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, method_map: typeck::method_map, tcx: ty::ctxt, e: @expr, &&is_const: bool, v: visit::vt<bool>) { if is_const { - alt e.node { + match e.node { expr_unary(box(_), _) | expr_unary(uniq(_), _) | expr_unary(deref, _) => { sess.span_err(e.span, @@ -83,7 +83,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, } } expr_path(_) => { - alt def_map.find(e.id) { + match def_map.find(e.id) { some(def_const(def_id)) => { if !ast_util::is_local(def_id) { sess.span_err( @@ -117,7 +117,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, } } } - alt e.node { + match e.node { expr_lit(@{node: lit_int(v, t), _}) => { if t != ty_char { if (v as u64) > ast_util::int_ty_max( @@ -175,11 +175,11 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map, } fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) { - alt e.node { + match e.node { expr_path(path) => { - alt env.def_map.find(e.id) { + match env.def_map.find(e.id) { some(def_const(def_id)) => { - alt check env.ast_map.get(def_id.node) { + match check env.ast_map.get(def_id.node) { ast_map::node_item(it, _) => { v.visit_item(it, env, v); } diff --git a/src/rustc/middle/check_loop.rs b/src/rustc/middle/check_loop.rs index 0ac3caa633b..8f3de8c8aa2 100644 --- a/src/rustc/middle/check_loop.rs +++ b/src/rustc/middle/check_loop.rs @@ -10,7 +10,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { visit::visit_item(i, {in_loop: false, can_ret: true}, v); }, visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| { - alt e.node { + match e.node { expr_while(e, b) => { v.visit_expr(e, cx, v); v.visit_block(b, {in_loop: true with cx}, v); diff --git a/src/rustc/middle/const_eval.rs b/src/rustc/middle/const_eval.rs index 66c19a14e6f..e15ef586042 100644 --- a/src/rustc/middle/const_eval.rs +++ b/src/rustc/middle/const_eval.rs @@ -41,7 +41,7 @@ enum constness { } fn join(a: constness, b: constness) -> constness { - alt (a,b) { + match (a,b) { (integral_const, integral_const) => integral_const, (integral_const, general_const) | (general_const, integral_const) @@ -58,13 +58,13 @@ fn classify(e: @expr, def_map: resolve3::DefMap, tcx: ty::ctxt) -> constness { let did = ast_util::local_def(e.id); - alt tcx.ccache.find(did) { + match tcx.ccache.find(did) { some(x) => x, none => { let cn = - alt e.node { + match e.node { ast::expr_lit(lit) => { - alt lit.node { + match lit.node { ast::lit_str(*) | ast::lit_float(*) => general_const, _ => integral_const @@ -87,7 +87,7 @@ fn classify(e: @expr, } ast::expr_vstore(e, vstore) => { - alt vstore { + match vstore { ast::vstore_fixed(_) | ast::vstore_slice(_) => classify(e, def_map, tcx), ast::vstore_uniq | @@ -134,7 +134,7 @@ fn classify(e: @expr, // FIXME: #1272, we can probably do something CCI-ish // surrounding nonlocal constants. But we don't yet. ast::expr_path(_) => { - alt def_map.find(e.id) { + match def_map.find(e.id) { some(ast::def_const(def_id)) => { if ast_util::is_local(def_id) { let ty = ty::expr_ty(tcx, e); @@ -191,24 +191,24 @@ enum const_val { fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { import middle::ty; fn fromb(b: bool) -> const_val { const_int(b as i64) } - alt check e.node { + match check e.node { expr_unary(neg, inner) => { - alt check eval_const_expr(tcx, inner) { + match check eval_const_expr(tcx, inner) { const_float(f) => const_float(-f), const_int(i) => const_int(-i), const_uint(i) => const_uint(-i) } } expr_unary(not, inner) => { - alt check eval_const_expr(tcx, inner) { + match check eval_const_expr(tcx, inner) { const_int(i) => const_int(!i), const_uint(i) => const_uint(!i) } } expr_binary(op, a, b) => { - alt check (eval_const_expr(tcx, a), eval_const_expr(tcx, b)) { + match check (eval_const_expr(tcx, a), eval_const_expr(tcx, b)) { (const_float(a), const_float(b)) => { - alt check op { + match check op { add => const_float(a + b), subtract => const_float(a - b), mul => const_float(a * b), @@ -223,7 +223,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } } (const_int(a), const_int(b)) => { - alt check op { + match check op { add => const_int(a + b), subtract => const_int(a - b), mul => const_int(a * b), @@ -243,7 +243,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } } (const_uint(a), const_uint(b)) => { - alt check op { + match check op { add => const_uint(a + b), subtract => const_uint(a - b), mul => const_uint(a * b), @@ -264,13 +264,13 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } // shifts can have any integral type as their rhs (const_int(a), const_uint(b)) => { - alt check op { + match check op { shl => const_int(a << b), shr => const_int(a >> b) } } (const_uint(a), const_int(b)) => { - alt check op { + match check op { shl => const_uint(a << b), shr => const_uint(a >> b) } @@ -280,23 +280,23 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { expr_cast(base, _) => { let ety = ty::expr_ty(tcx, e); let base = eval_const_expr(tcx, base); - alt check ty::get(ety).struct { + match check ty::get(ety).struct { ty::ty_float(_) => { - alt check base { + match check base { const_uint(u) => const_float(u as f64), const_int(i) => const_float(i as f64), const_float(_) => base } } ty::ty_uint(_) => { - alt check base { + match check base { const_uint(_) => base, const_int(i) => const_uint(i as u64), const_float(f) => const_uint(f as u64) } } ty::ty_int(_) | ty::ty_bool => { - alt check base { + match check base { const_uint(u) => const_int(u as i64), const_int(_) => base, const_float(f) => const_int(f as i64) @@ -311,7 +311,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } fn lit_to_const(lit: @lit) -> const_val { - alt lit.node { + match lit.node { lit_str(s) => const_str(*s), lit_int(n, _) => const_int(n), lit_uint(n, _) => const_uint(n), @@ -323,7 +323,7 @@ fn lit_to_const(lit: @lit) -> const_val { } fn compare_const_vals(a: const_val, b: const_val) -> int { - alt (a, b) { + match (a, b) { (const_int(a), const_int(b)) => { if a == b { 0 diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index 7c8e807a085..4c81ec30392 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -38,7 +38,7 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk) fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { } let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) { - alt expr.node { + match expr.node { ast::expr_fn(proto, decl, _, _) => { if proto != ast::proto_bare { visit::visit_expr(expr, depth + 1, v); @@ -49,12 +49,12 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk) } ast::expr_path(path) => { let mut i = 0; - alt def_map.find(expr.id) { + match def_map.find(expr.id) { none => fail (~"Not found: " + path_to_str(path)), some(df) => { let mut def = df; while i < depth { - alt copy def { + match copy def { ast::def_upvar(_, inner, _) => { def = *inner; } _ => break } @@ -104,7 +104,7 @@ fn annotate_freevars(def_map: resolve3::DefMap, crate: @ast::crate) -> } fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { - alt tcx.freevars.find(fid) { + match tcx.freevars.find(fid) { none => fail ~"get_freevars: " + int::str(fid) + ~" has no freevars", some(d) => return d } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e855e23b12b..408b0ef6916 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -144,7 +144,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { } let fty = ty::node_id_to_type(cx.tcx, id); - alt ty::ty_fn_proto(fty) { + match ty::ty_fn_proto(fty) { proto_uniq => b(check_for_uniq), proto_box => b(check_for_box), proto_bare => b(check_for_bare), @@ -166,7 +166,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, // errors and produce a list of the def id's for all capture // variables. This list is used below to avoid checking and reporting // on a given variable twice. - let cap_clause = alt fk { + let cap_clause = match fk { visit::fk_anon(_, cc) | visit::fk_fn_block(cc) => cc, visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_ctor(*) | visit::fk_dtor(*) => @~[] @@ -190,7 +190,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, // if this is the last use of the variable, then it will be // a move and not a copy let is_move = { - alt check cx.last_use_map.find(fn_id) { + match check cx.last_use_map.find(fn_id) { some(vars) => (*vars).contains(id), none => false } @@ -205,7 +205,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, } fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { - alt b.node.expr { + match b.node.expr { some(ex) => maybe_copy(cx, ex), _ => () } @@ -214,7 +214,7 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { debug!{"kind::check_expr(%s)", expr_to_str(e)}; - alt e.node { + match e.node { expr_assign(_, ex) | expr_unary(box(_), ex) | expr_unary(uniq(_), ex) | expr_ret(some(ex)) => { @@ -233,11 +233,11 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { } expr_rec(fields, def) => { for fields.each |field| { maybe_copy(cx, field.node.expr); } - alt def { + match def { some(ex) => { // All noncopyable fields must be overridden let t = ty::expr_ty(cx.tcx, ex); - let ty_fields = alt ty::get(t).struct { + let ty_fields = match ty::get(t).struct { ty::ty_rec(f) => f, _ => cx.tcx.sess.span_bug(ex.span, ~"bad expr type in record") }; @@ -258,7 +258,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { expr_call(f, args, _) => { let mut i = 0u; for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| { - alt ty::arg_mode(cx.tcx, arg_t) { + match ty::arg_mode(cx.tcx, arg_t) { by_copy => maybe_copy(cx, args[i]), by_ref | by_val | by_mutbl_ref | by_move => () } @@ -267,13 +267,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { } expr_path(_) | expr_field(_, _, _) => { do option::iter(cx.tcx.node_type_substs.find(e.id)) |ts| { - let bounds = alt check e.node { + let bounds = match check e.node { expr_path(_) => { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id)); ty::lookup_item_type(cx.tcx, did).bounds } expr_field(base, _, _) => { - alt cx.method_map.get(e.id).origin { + match cx.method_map.get(e.id).origin { typeck::method_static(did) => { // n.b.: When we encode class/impl methods, the bounds // that we encode include both the class/impl bounds @@ -312,10 +312,10 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { } fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) { - alt stmt.node { + match stmt.node { stmt_decl(@{node: decl_local(locals), _}, _) => { for locals.each |local| { - alt local.node.init { + match local.node.init { some({op: init_assign, expr}) => maybe_copy(cx, expr), _ => {} } @@ -327,7 +327,7 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) { } fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) { - alt aty.node { + match aty.node { ty_path(_, id) => { do option::iter(cx.tcx.node_type_substs.find(id)) |ts| { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id)); @@ -373,9 +373,9 @@ fn maybe_copy(cx: ctx, ex: @expr) { } fn is_nullary_variant(cx: ctx, ex: @expr) -> bool { - alt ex.node { + match ex.node { expr_path(_) => { - alt cx.tcx.def_map.get(ex.id) { + match cx.tcx.def_map.get(ex.id) { def_variant(edid, vdid) => { vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u } @@ -398,14 +398,14 @@ fn check_copy_ex(cx: ctx, ex: @expr, implicit_copy: bool) { fn check_imm_free_var(cx: ctx, def: def, sp: span) { let msg = ~"mutable variables cannot be implicitly captured; \ use a capture clause"; - alt def { + match def { def_local(_, is_mutbl) => { if is_mutbl { cx.tcx.sess.span_err(sp, msg); } } def_arg(_, mode) => { - alt ty::resolved_mode(cx.tcx, mode) { + match ty::resolved_mode(cx.tcx, mode) { by_ref | by_val | by_move | by_copy => { /* ok */ } by_mutbl_ref => { cx.tcx.sess.span_err(sp, msg); @@ -449,7 +449,7 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool { // note: also used from middle::typeck::regionck! fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { if !ty::kind_is_owned(ty::type_kind(tcx, ty)) { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_param(*) => { tcx.sess.span_err(sp, ~"value may contain borrowed \ pointers; use `owned` bound"); @@ -496,7 +496,7 @@ fn check_cast_for_escaping_regions( // Determine what type we are casting to; if it is not an trait, then no // worries. let target_ty = ty::expr_ty(cx.tcx, target); - let target_substs = alt ty::get(target_ty).struct { + let target_substs = match ty::get(target_ty).struct { ty::ty_trait(_, substs) => {substs} _ => { return; /* not a cast to a trait */ } }; @@ -504,7 +504,7 @@ fn check_cast_for_escaping_regions( // Check, based on the region associated with the trait, whether it can // possibly escape the enclosing fn item (note that all type parameters // must have been declared on the enclosing fn item): - alt target_substs.self_r { + match target_substs.self_r { some(ty::re_scope(*)) => { return; /* case (1) */ } none | some(ty::re_static) | some(ty::re_free(*)) => {} some(ty::re_bound(*)) | some(ty::re_var(*)) => { @@ -519,7 +519,7 @@ fn check_cast_for_escaping_regions( let target_params = ty::param_tys_in_type(target_ty); let source_ty = ty::expr_ty(cx.tcx, source); do ty::walk_ty(source_ty) |ty| { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_param(source_param) => { if target_params.contains(source_param) { /* case (2) */ diff --git a/src/rustc/middle/lang_items.rs b/src/rustc/middle/lang_items.rs index 5abc64a3b0d..877dfd5f90c 100644 --- a/src/rustc/middle/lang_items.rs +++ b/src/rustc/middle/lang_items.rs @@ -98,9 +98,9 @@ class LanguageItemCollector { fn match_and_collect_meta_item(item_def_id: def_id, meta_item: meta_item) { - alt meta_item.node { + match meta_item.node { meta_name_value(key, literal) => { - alt literal.node { + match literal.node { lit_str(value) => { self.match_and_collect_item(item_def_id, *key, @@ -122,13 +122,13 @@ class LanguageItemCollector { return; // Didn't match. } - alt self.item_refs.find(value) { + match self.item_refs.find(value) { none => { // Didn't match. } some(item_ref) => { // Check for duplicates. - alt copy *item_ref { + match copy *item_ref { some(original_def_id) if original_def_id != item_def_id => { @@ -168,7 +168,7 @@ class LanguageItemCollector { do iter_crate_data(crate_store) |crate_number, _crate_metadata| { for each_path(crate_store, crate_number) |path_entry| { let def_id; - alt path_entry.def_like { + match path_entry.def_like { dl_def(def_ty(did)) => { def_id = did; } @@ -189,7 +189,7 @@ class LanguageItemCollector { fn check_completeness() { for self.item_refs.each |key, item_ref| { - alt copy *item_ref { + match copy *item_ref { none => { self.session.err(fmt!{"no item found for `%s`", key}); } diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 61299171eae..4de9bf8e17d 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -55,7 +55,7 @@ enum lint { // This is pretty unfortunate. We really want some sort of "deriving Enum" // type of thing. fn int_to_lint(i: int) -> lint { - alt check i { + match check i { 0 => ctypes, 1 => unused_imports, 2 => while_true, @@ -70,7 +70,7 @@ fn int_to_lint(i: int) -> lint { } fn level_to_str(lv: level) -> ~str { - alt lv { + match lv { allow => ~"allow", warn => ~"warn", deny => ~"deny", @@ -166,7 +166,7 @@ fn mk_lint_settings() -> lint_settings { } fn get_lint_level(modes: lint_modes, lint: lint) -> level { - alt modes.find(lint as uint) { + match modes.find(lint as uint) { some(c) => c, none => allow } @@ -176,7 +176,7 @@ fn get_lint_settings_level(settings: lint_settings, lint_mode: lint, _expr_id: ast::node_id, item_id: ast::node_id) -> level { - alt settings.settings_map.find(item_id) { + match settings.settings_map.find(item_id) { some(modes) => get_lint_level(modes, lint_mode), none => get_lint_level(settings.default_settings, lint_mode) } @@ -230,10 +230,10 @@ impl methods for ctxt { attr::attr_metas(attr::find_attrs_by_name(attrs, level_name)); for metas.each |meta| { - alt meta.node { + match meta.node { ast::meta_list(_, metas) => { for metas.each |meta| { - alt meta.node { + match meta.node { ast::meta_word(lintname) => { vec::push(triples, (meta, level, lintname)); } @@ -255,7 +255,7 @@ impl methods for ctxt { for triples.each |pair| { let (meta, level, lintname) = pair; - alt self.dict.find(*lintname) { + match self.dict.find(*lintname) { none => { self.span_lint( new_ctxt.get_level(unrecognized_lint), @@ -354,9 +354,9 @@ fn item_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> { fn check_item_while_true(cx: ty::ctxt, it: @ast::item) { let visit = item_stopping_visitor(visit::mk_simple_visitor(@{ visit_expr: fn@(e: @ast::expr) { - alt e.node { + match e.node { ast::expr_while(cond, _) => { - alt cond.node { + match cond.node { ast::expr_lit(@{node: ast::lit_bool(true),_}) => { cx.sess.span_lint( while_true, e.id, it.id, @@ -380,9 +380,9 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { decl: ast::fn_decl) { let tys = vec::map(decl.inputs, |a| a.ty ); for vec::each(vec::append_one(tys, decl.output)) |ty| { - alt ty.node { + match ty.node { ast::ty_path(_, id) => { - alt cx.def_map.get(id) { + match cx.def_map.get(id) { ast::def_prim_ty(ast::ty_int(ast::ty_i)) => { cx.sess.span_lint( ctypes, id, fn_id, @@ -405,11 +405,11 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { } } - alt it.node { + match it.node { ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) != either::right(ast::foreign_abi_rust_intrinsic) => { for nmod.items.each |ni| { - alt ni.node { + match ni.node { ast::foreign_item_fn(decl, tps) => { check_foreign_fn(cx, it.id, decl); } @@ -423,7 +423,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { let visit = item_stopping_visitor(visit::mk_simple_visitor(@{ visit_stmt: fn@(s: @ast::stmt) { - alt s.node { + match s.node { ast::stmt_semi(@{id: id, callee_id: _, node: ast::expr_path(@path), @@ -458,7 +458,7 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) { } } - alt it.node { + match it.node { ast::item_ty(*) | ast::item_class(*) | ast::item_trait(*) | ast::item_impl(*) => { check_case(cx, it.ident, it.id, it.id, it.span) @@ -480,13 +480,13 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, // don't complain about blocks, since they tend to get their modes // specified from the outside - alt fk { + match fk { visit::fk_fn_block(*) => { return; } _ => {} } let fn_ty = ty::node_id_to_type(tcx, id); - alt check ty::get(fn_ty).struct { + match check ty::get(fn_ty).struct { ty::ty_fn(fn_ty) => { let mut counter = 0; do vec::iter2(fn_ty.inputs, decl.inputs) |arg_ty, arg_ast| { @@ -495,7 +495,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, counter, ty_to_str(tcx, arg_ty.ty), mode_to_str(arg_ast.mode)}; - alt arg_ast.mode { + match arg_ast.mode { ast::expl(ast::by_copy) => { /* always allow by-copy */ } diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 38942b40750..6cad5e19e96 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -201,7 +201,7 @@ enum var_kind { } fn relevant_def(def: def) -> option<relevant_def> { - alt def { + match def { def_self(_) => some(rdef_self), def_arg(nid, _) | def_local(nid, _) => some(rdef_var(nid)), _ => none @@ -260,7 +260,7 @@ class ir_maps { vec::push(self.var_kinds, vk); self.num_vars += 1u; - alt vk { + match vk { vk_local(node_id, _) | vk_arg(node_id, _, _) => { self.variable_map.insert(node_id, v); } @@ -277,7 +277,7 @@ class ir_maps { } fn variable(node_id: node_id, span: span) -> variable { - alt self.variable_map.find(node_id) { + match self.variable_map.find(node_id) { some(var) => var, none => { self.tcx.sess.span_bug( @@ -287,7 +287,7 @@ class ir_maps { } fn variable_name(var: variable) -> ident { - alt self.var_kinds[*var] { + match self.var_kinds[*var] { vk_local(_, name) | vk_arg(_, name, _) => name, vk_field(name) => @(~"self." + *name), vk_self => @~"self", @@ -300,7 +300,7 @@ class ir_maps { } fn captures(expr: @expr) -> @~[capture_info] { - alt self.capture_map.find(expr.id) { + match self.capture_map.find(expr.id) { some(caps) => caps, none => { self.tcx.sess.span_bug(expr.span, ~"no registered caps"); @@ -315,11 +315,11 @@ class ir_maps { fn add_last_use(expr_id: node_id, var: variable) { let vk = self.var_kinds[*var]; debug!{"Node %d is a last use of variable %?", expr_id, vk}; - alt vk { + match vk { vk_arg(id, name, by_move) | vk_arg(id, name, by_copy) | vk_local(id, name) => { - let v = alt self.last_use_map.find(expr_id) { + let v = match self.last_use_map.find(expr_id) { some(v) => v, none => { let v = @dvec(); @@ -359,7 +359,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, // and so forth: visit::visit_fn(fk, decl, body, sp, id, fn_maps, v); - alt fk { + match fk { visit::fk_ctor(_, _, _, _, class_did) => { add_class_fields(fn_maps, class_did); } @@ -414,7 +414,7 @@ fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) { } fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { - alt expr.node { + match expr.node { // live nodes required for uses or definitions of variables: expr_path(_) => { let def = self.tcx.def_map.get(expr.id); @@ -435,10 +435,10 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { proto, cap_clause); let mut call_caps = ~[]; for cvs.each |cv| { - alt relevant_def(cv.def) { + match relevant_def(cv.def) { some(rv) => { let cv_ln = (*self).add_live_node(lnk_freevar(cv.span)); - let is_move = alt cv.mode { + let is_move = match cv.mode { cap_move | cap_drop => true, // var must be dead afterwards cap_copy | cap_ref => false // var can still be used }; @@ -533,7 +533,7 @@ class liveness { // _______________________________________________________________________ fn live_node(node_id: node_id, span: span) -> live_node { - alt self.ir.live_node_map.find(node_id) { + match self.ir.live_node_map.find(node_id) { some(ln) => ln, none => { // This must be a mismatch between the ir_map construction @@ -548,14 +548,14 @@ class liveness { } fn variable_from_rdef(rv: relevant_def, span: span) -> variable { - alt rv { + match rv { rdef_self => self.s.self_var, rdef_var(nid) => self.variable(nid, span) } } fn variable_from_path(expr: @expr) -> option<variable> { - alt expr.node { + match expr.node { expr_path(_) => { let def = self.tcx.def_map.get(expr.id); relevant_def(def).map( @@ -572,7 +572,7 @@ class liveness { fn variable_from_def_map(node_id: node_id, span: span) -> option<variable> { - alt self.tcx.def_map.find(node_id) { + match self.tcx.def_map.find(node_id) { some(def) => { relevant_def(def).map( |rdef| self.variable_from_rdef(rdef, span) @@ -794,7 +794,7 @@ class liveness { fn propagate_through_fn_block(decl: fn_decl, blk: blk) -> live_node { // inputs passed by & mode should be considered live on exit: for decl.inputs.each |arg| { - alt ty::resolved_mode(self.tcx, arg.mode) { + match ty::resolved_mode(self.tcx, arg.mode) { by_mutbl_ref | by_ref | by_val => { // These are "non-owned" modes, so register a read at // the end. This will prevent us from moving out of @@ -836,7 +836,7 @@ class liveness { } fn propagate_through_stmt(stmt: @stmt, succ: live_node) -> live_node { - alt stmt.node { + match stmt.node { stmt_decl(decl, _) => { return self.propagate_through_decl(decl, succ); } @@ -848,7 +848,7 @@ class liveness { } fn propagate_through_decl(decl: @decl, succ: live_node) -> live_node { - alt decl.node { + match decl.node { decl_local(locals) => { do locals.foldr(succ) |local, succ| { self.propagate_through_local(local, succ) @@ -900,7 +900,7 @@ class liveness { } fn propagate_through_expr(expr: @expr, succ: live_node) -> live_node { - alt expr.node { + match expr.node { // Interesting cases with control flow or which gen/kill expr_path(_) => { @@ -912,7 +912,7 @@ class liveness { // then we treat it as a read of that variable. // Otherwise, we ignore it and just propagate down to // process `e`. - alt self.as_self_field(e, nm) { + match self.as_self_field(e, nm) { some((ln, var)) => { self.init_from_succ(ln, succ); self.acc(ln, var, ACC_READ | ACC_USE); @@ -1185,9 +1185,9 @@ class liveness { // these errors are detected in the later pass borrowck. We // just ignore such cases and treat them as reads. - alt expr.node { + match expr.node { expr_path(_) => succ, - expr_field(e, nm, _) => alt self.as_self_field(e, nm) { + expr_field(e, nm, _) => match self.as_self_field(e, nm) { some(_) => succ, none => self.propagate_through_expr(e, succ) } @@ -1199,9 +1199,9 @@ class liveness { fn write_lvalue(expr: @expr, succ: live_node, acc: uint) -> live_node { - alt expr.node { + match expr.node { expr_path(_) => self.access_path(expr, succ, acc), - expr_field(e, nm, _) => alt self.as_self_field(e, nm) { + expr_field(e, nm, _) => match self.as_self_field(e, nm) { some((ln, var)) => { self.init_from_succ(ln, succ); self.acc(ln, var, acc); @@ -1220,7 +1220,7 @@ class liveness { fn access_path(expr: @expr, succ: live_node, acc: uint) -> live_node { let def = self.tcx.def_map.get(expr.id); - alt relevant_def(def) { + match relevant_def(def) { some(rdef_self) => { // Accessing `self` is like accessing every field of // the current object. This allows something like @@ -1259,10 +1259,10 @@ class liveness { // If we checking a constructor, then we treat self.f as a // variable. we use the live_node id that will be assigned to // the reference to self but the variable id for `f`. - alt expr.node { + match expr.node { expr_path(_) => { let def = self.tcx.def_map.get(expr.id); - alt def { + match def { def_self(_) => { // Note: the field_map is empty unless we are in a ctor return self.ir.field_map.find(fld).map(|var| { @@ -1345,12 +1345,12 @@ class liveness { // Checking for error conditions fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { - alt local.node.init { + match local.node.init { some({op: op, expr: expr}) => { // Initializer: - alt op { + match op { init_move => self.check_move_from_expr(expr, vt), init_assign => () } @@ -1367,7 +1367,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { debug!{"check_local() with no initializer"}; do (*self).pat_bindings(local.node.pat) |ln, var, sp| { if !self.warn_about_unused(sp, ln, var) { - alt (*self).live_on_exit(ln, var) { + match (*self).live_on_exit(ln, var) { none => { /* not live: good */ } some(lnk) => { self.report_illegal_read( @@ -1384,7 +1384,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { } fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) { - alt expr.node { + match expr.node { expr_path(_) => { for (*self).variable_from_def_map(expr.id, expr.span).each |var| { let ln = (*self).live_node(expr.id, expr.span); @@ -1437,7 +1437,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) { let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f)); vt.visit_expr(f, self, vt); do vec::iter2(args, targs) |arg_expr, arg_ty| { - alt ty::resolved_mode(self.tcx, arg_ty.mode) { + match ty::resolved_mode(self.tcx, arg_ty.mode) { by_val | by_copy | by_ref | by_mutbl_ref => { vt.visit_expr(arg_expr, self, vt); } @@ -1480,7 +1480,7 @@ enum read_kind { impl check_methods for @liveness { fn check_fields(sp: span, entry_ln: live_node) { for self.ir.field_map.each |nm, var| { - alt (*self).live_on_entry(entry_ln, var) { + match (*self).live_on_entry(entry_ln, var) { none => { /* ok */ } some(lnk_exit) => { self.tcx.sess.span_err( @@ -1508,7 +1508,7 @@ impl check_methods for @liveness { self.tcx.sess.span_err( sp, ~"some control paths may return"); } else { - alt fk { + match fk { visit::fk_ctor(*) => { // ctors are written as though they are unit. } @@ -1525,14 +1525,14 @@ impl check_methods for @liveness { debug!{"check_move_from_var(%s, %s)", ln.to_str(), var.to_str()}; - alt (*self).live_on_exit(ln, var) { + match (*self).live_on_exit(ln, var) { none => {} some(lnk) => self.report_illegal_move(span, lnk, var) } } fn consider_last_use(expr: @expr, ln: live_node, var: variable) { - alt (*self).live_on_exit(ln, var) { + match (*self).live_on_exit(ln, var) { some(_) => {} none => (*self.ir).add_last_use(expr.id, var) } @@ -1547,9 +1547,9 @@ impl check_methods for @liveness { return vt.visit_expr(expr, self, vt); } - alt expr.node { + match expr.node { expr_path(_) => { - alt (*self).variable_from_path(expr) { + match (*self).variable_from_path(expr) { some(var) => { let ln = (*self).live_node(expr.id, expr.span); self.check_move_from_var(expr.span, ln, var); @@ -1582,9 +1582,9 @@ impl check_methods for @liveness { } fn check_lvalue(expr: @expr, vt: vt<@liveness>) { - alt expr.node { + match expr.node { expr_path(_) => { - alt self.tcx.def_map.get(expr.id) { + match self.tcx.def_map.get(expr.id) { def_local(nid, false) => { // Assignment to an immutable variable or argument: // only legal if there is no later assignment. @@ -1594,7 +1594,7 @@ impl check_methods for @liveness { self.warn_about_dead_assign(expr.span, ln, var); } def => { - alt relevant_def(def) { + match relevant_def(def) { some(rdef_var(nid)) => { let ln = (*self).live_node(expr.id, expr.span); let var = (*self).variable(nid, expr.span); @@ -1623,7 +1623,7 @@ impl check_methods for @liveness { fn check_for_reassignment(ln: live_node, var: variable, orig_span: span) { - alt (*self).assigned_on_exit(ln, var) { + match (*self).assigned_on_exit(ln, var) { some(lnk_expr(span)) => { self.tcx.sess.span_err( span, @@ -1651,7 +1651,7 @@ impl check_methods for @liveness { // we give a slightly different error message in those cases. if lnk == lnk_exit { let vk = self.ir.var_kinds[*var]; - alt vk { + match vk { vk_arg(_, name, _) => { self.tcx.sess.span_err( move_span, @@ -1691,7 +1691,7 @@ impl check_methods for @liveness { lnk: live_node_kind, var: variable, rk: read_kind) { - let msg = alt rk { + let msg = match rk { possibly_uninitialized_variable => { ~"possibly uninitialized variable" } @@ -1699,7 +1699,7 @@ impl check_methods for @liveness { moved_variable => ~"moved variable" }; let name = (*self.ir).variable_name(var); - alt lnk { + match lnk { lnk_freevar(span) => { self.tcx.sess.span_err( span, @@ -1727,13 +1727,13 @@ impl check_methods for @liveness { fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) { for decl.inputs.each |arg| { let var = (*self).variable(arg.id, arg.ty.span); - alt ty::resolved_mode(self.tcx, arg.mode) { + match ty::resolved_mode(self.tcx, arg.mode) { by_mutbl_ref => { // for mutable reference arguments, something like // x = 1; // is not worth warning about, as it has visible // side effects outside the fn. - alt (*self).assigned_on_entry(entry_ln, var) { + match (*self).assigned_on_entry(entry_ln, var) { some(_) => { /*ok*/ } none => { // but if it is not written, it ought to be used diff --git a/src/rustc/middle/pat_util.rs b/src/rustc/middle/pat_util.rs index 405afe20a1c..f1f33e74e53 100644 --- a/src/rustc/middle/pat_util.rs +++ b/src/rustc/middle/pat_util.rs @@ -22,9 +22,9 @@ fn pat_id_map(dm: resolve3::DefMap, pat: @pat) -> pat_id_map { } fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool { - alt pat.node { + match pat.node { pat_enum(_, _) => true, - pat_ident(_, _, none) => alt dm.find(pat.id) { + pat_ident(_, _, none) => match dm.find(pat.id) { some(def_variant(_, _)) => true, _ => false } @@ -35,7 +35,7 @@ fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool { fn pat_bindings(dm: resolve3::DefMap, pat: @pat, it: fn(node_id, span, @path)) { do walk_pat(pat) |p| { - alt p.node { + match p.node { pat_ident(_, pth, _) if !pat_is_variant(dm, p) => { it(p.id, p.span, pth); } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 9cece96b892..362c4be7abe 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -88,7 +88,7 @@ fn scope_contains(region_map: region_map, superscope: ast::node_id, subscope: ast::node_id) -> bool { let mut subscope = subscope; while superscope != subscope { - alt region_map.find(subscope) { + match region_map.find(subscope) { none => return false, some(scope) => subscope = scope } @@ -103,7 +103,7 @@ fn subregion(region_map: region_map, super_region: ty::region, sub_region: ty::region) -> bool { super_region == sub_region || - alt (super_region, sub_region) { + match (super_region, sub_region) { (ty::re_static, _) => {true} (ty::re_scope(super_scope), ty::re_scope(sub_scope)) | @@ -128,7 +128,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, let mut result = ~[scope]; let mut scope = scope; loop { - alt region_map.find(scope) { + match region_map.find(scope) { none => return result, some(superscope) => { vec::push(result, superscope); @@ -172,7 +172,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, /// Extracts that current parent from cx, failing if there is none. fn parent_id(cx: ctxt, span: span) -> ast::node_id { - alt cx.parent { + match cx.parent { none => { cx.sess.span_bug(span, ~"crate should not be parent here"); } @@ -184,7 +184,7 @@ fn parent_id(cx: ctxt, span: span) -> ast::node_id { /// Records the current parent (if any) as the parent of `child_id`. fn record_parent(cx: ctxt, child_id: ast::node_id) { - alt cx.parent { + match cx.parent { none => { /* no-op */ } some(parent_id) => { debug!{"parent of node %d is node %d", child_id, parent_id}; @@ -207,10 +207,10 @@ fn resolve_arm(arm: ast::arm, cx: ctxt, visitor: visit::vt<ctxt>) { } fn resolve_pat(pat: @ast::pat, cx: ctxt, visitor: visit::vt<ctxt>) { - alt pat.node { + match pat.node { ast::pat_ident(_, path, _) => { let defn_opt = cx.def_map.find(pat.id); - alt defn_opt { + match defn_opt { some(ast::def_variant(_,_)) => { /* Nothing to do; this names a variant. */ } @@ -230,7 +230,7 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) { record_parent(cx, expr.id); let mut new_cx = cx; - alt expr.node { + match expr.node { ast::expr_call(*) => { debug!{"node %d: %s", expr.id, pprust::expr_to_str(expr)}; new_cx.parent = some(expr.id); @@ -276,7 +276,7 @@ fn resolve_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, sp: span, id: ast::node_id, cx: ctxt, visitor: visit::vt<ctxt>) { - let fn_cx = alt fk { + let fn_cx = match fk { visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_ctor(*) | visit::fk_dtor(*) => { // Top-level functions are a root scope. @@ -380,7 +380,7 @@ impl methods for determine_rp_ctxt { from, to, ast_map::node_id_to_str(self.ast_map, from), ast_map::node_id_to_str(self.ast_map, to)}; - let vec = alt self.dep_map.find(from) { + let vec = match self.dep_map.find(from) { some(vec) => {vec} none => { let vec = @dvec(); @@ -424,7 +424,7 @@ impl methods for determine_rp_ctxt { // (anon_implies_rp) to true when we enter an item and setting // that flag to false when we enter a method. fn region_is_relevant(r: @ast::region) -> bool { - alt r.node { + match r.node { ast::re_anon => self.anon_implies_rp, ast::re_named(@~"self") => true, ast::re_named(_) => false @@ -485,7 +485,7 @@ fn determine_rp_in_ty(ty: @ast::ty, // if this type directly references a region, either via a // region pointer like &r.ty or a region-parameterized path // like path/r, add to the worklist/set - alt ty.node { + match ty.node { ast::ty_rptr(r, _) | ast::ty_path(@{rp: some(r), _}, _) => { debug!{"referenced type with regions %s", pprust::ty_to_str(ty)}; @@ -501,9 +501,9 @@ fn determine_rp_in_ty(ty: @ast::ty, // to the dep_map. If the type is not defined in this crate, // then check whether it is region-parameterized and consider // that as a direct dependency. - alt ty.node { + match ty.node { ast::ty_path(_, id) => { - alt cx.def_map.get(id) { + match cx.def_map.get(id) { ast::def_ty(did) | ast::def_class(did, _) => { if did.crate == ast::local_crate { cx.add_dep(did.node, cx.item_id); @@ -522,7 +522,7 @@ fn determine_rp_in_ty(ty: @ast::ty, _ => {} } - alt ty.node { + match ty.node { ast::ty_fn(*) => { do cx.with(cx.item_id, false) { visit::visit_ty(ty, cx, visitor); @@ -561,7 +561,7 @@ fn determine_rp_in_crate(sess: session, while cx.worklist.len() != 0 { let id = cx.worklist.pop(); debug!{"popped %d from worklist", id}; - alt cx.dep_map.find(id) { + match cx.dep_map.find(id) { none => {} some(vec) => { for vec.each |to_id| { diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index 9f17e38ba54..11f329669c0 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -247,7 +247,7 @@ class AtomTable { } fn intern(string: @~str) -> Atom { - alt self.atoms.find(string) { + match self.atoms.find(string) { none => { /* fall through */ } some(atom) => return atom } @@ -367,7 +367,7 @@ class ImportResolution { } fn target_for_namespace(namespace: Namespace) -> option<Target> { - alt namespace { + match namespace { ModuleNS => return copy self.module_target, TypeNS => return copy self.type_target, ValueNS => return copy self.value_target, @@ -461,7 +461,7 @@ class Module { // requiring a T:copy. pure fn is_none<T>(x: option<T>) -> bool { - alt x { + match x { none => return true, some(_) => return false } @@ -517,7 +517,7 @@ class NameBindings { /// Returns the module node if applicable. fn get_module_if_available() -> option<@Module> { - alt self.module_def { + match self.module_def { NoModuleDef => return none, ModuleDef(module_) => return some(module_) } @@ -528,7 +528,7 @@ class NameBindings { * definition. */ fn get_module() -> @Module { - alt self.module_def { + match self.module_def { NoModuleDef => { fail ~"get_module called on a node with no module definition!"; @@ -540,7 +540,7 @@ class NameBindings { } fn defined_in_namespace(namespace: Namespace) -> bool { - alt namespace { + match namespace { ModuleNS => return self.module_def != NoModuleDef, TypeNS => return self.type_def != none, ValueNS => return self.value_def != none, @@ -549,12 +549,12 @@ class NameBindings { } fn def_for_namespace(namespace: Namespace) -> option<def> { - alt namespace { + match namespace { TypeNS => return self.type_def, ValueNS => return self.value_def, - ModuleNS => alt self.module_def { + ModuleNS => match self.module_def { NoModuleDef => return none, - ModuleDef(module_) => alt module_.def_id { + ModuleDef(module_) => match module_.def_id { none => return none, some(def_id) => return some(def_mod(def_id)) } @@ -750,7 +750,7 @@ class Resolver { /// Returns the current module tracked by the reduced graph parent. fn get_module_from_parent(reduced_graph_parent: ReducedGraphParent) -> @Module { - alt reduced_graph_parent { + match reduced_graph_parent { ModuleReducedGraphParent(module_) => { return module_; } @@ -776,7 +776,7 @@ class Resolver { // module and add the child to that. let mut module_; - alt reduced_graph_parent { + match reduced_graph_parent { ModuleReducedGraphParent(parent_module) => { module_ = parent_module; } @@ -784,7 +784,7 @@ class Resolver { // Add or reuse the child. let new_parent = ModuleReducedGraphParent(module_); - alt module_.children.find(name) { + match module_.children.find(name) { none => { let child = @NameBindings(); module_.children.insert(name, child); @@ -804,9 +804,9 @@ class Resolver { // Check each statement. for block.node.stmts.each |statement| { - alt statement.node { + match statement.node { stmt_decl(declaration, _) => { - alt declaration.node { + match declaration.node { decl_item(_) => { return true; } @@ -828,7 +828,7 @@ class Resolver { } fn get_parent_link(parent: ReducedGraphParent, name: Atom) -> ParentLink { - alt parent { + match parent { ModuleReducedGraphParent(module_) => { return ModuleParentLink(module_, name); } @@ -843,7 +843,7 @@ class Resolver { let atom = (*self.atom_table).intern(item.ident); let (name_bindings, new_parent) = self.add_child(atom, parent); - alt item.node { + match item.node { item_mod(module_) => { let parent_link = self.get_parent_link(new_parent, atom); let def_id = { crate: 0, node: item.id }; @@ -894,7 +894,7 @@ class Resolver { item_class(_, _, class_members, optional_ctor, _) => { (*name_bindings).define_type(def_ty(local_def(item.id))); - alt optional_ctor { + match optional_ctor { none => { // Nothing to do. } @@ -913,7 +913,7 @@ class Resolver { let mut method_infos = ~[]; for class_members.each |class_member| { - alt class_member.node { + match class_member.node { class_method(method) => { // XXX: Combine with impl method code below. method_infos += ~[ @@ -979,7 +979,7 @@ class Resolver { let method_names = @atom_hashmap(); for methods.each |method| { let atom; - alt method { + match method { required(required_method) => { atom = (*self.atom_table).intern (required_method.ident); @@ -1028,7 +1028,7 @@ class Resolver { fn build_reduced_graph_for_view_item(view_item: @view_item, parent: ReducedGraphParent, &&_visitor: vt<ReducedGraphParent>) { - alt view_item.node { + match view_item.node { view_item_import(view_paths) => { for view_paths.each |view_path| { // Extract and intern the module part of the path. For @@ -1036,7 +1036,7 @@ class Resolver { // for simple paths we have to munge the path a little. let module_path = @dvec(); - alt view_path.node { + match view_path.node { view_path_simple(_, full_path, _) => { let path_len = full_path.idents.len(); assert path_len != 0u; @@ -1061,7 +1061,7 @@ class Resolver { // Build up the import directives. let module_ = self.get_module_from_parent(parent); - alt view_path.node { + match view_path.node { view_path_simple(binding, full_path, _) => { let target_atom = (*self.atom_table).intern(binding); @@ -1099,7 +1099,7 @@ class Resolver { view_item_export(view_paths) => { let module_ = self.get_module_from_parent(parent); for view_paths.each |view_path| { - alt view_path.node { + match view_path.node { view_path_simple(ident, full_path, ident_id) => { let last_ident = full_path.idents.last(); if last_ident != ident { @@ -1157,7 +1157,7 @@ class Resolver { } view_item_use(name, _, node_id) => { - alt find_use_stmt_cnum(self.session.cstore, node_id) { + match find_use_stmt_cnum(self.session.cstore, node_id) { some(crate_id) => { let atom = (*self.atom_table).intern(name); let (child_name_bindings, new_parent) = @@ -1189,7 +1189,7 @@ class Resolver { let name = (*self.atom_table).intern(foreign_item.ident); let (name_bindings, new_parent) = self.add_child(name, parent); - alt foreign_item.node { + match foreign_item.node { foreign_item_fn(fn_decl, type_parameters) => { let def = def_fn(local_def(foreign_item.id), fn_decl.purity); (*name_bindings).define_value(def); @@ -1262,7 +1262,7 @@ class Resolver { ModuleReducedGraphParent(current_module)); // Define or reuse the module node. - alt child_name_bindings.module_def { + match child_name_bindings.module_def { NoModuleDef => { debug!{"(building reduced graph for external crate) \ autovivifying %s", ident}; @@ -1283,11 +1283,11 @@ class Resolver { self.add_child(atom, ModuleReducedGraphParent(current_module)); - alt path_entry.def_like { + match path_entry.def_like { dl_def(def) => { - alt def { + match def { def_mod(def_id) | def_foreign_mod(def_id) => { - alt copy child_name_bindings.module_def { + match copy child_name_bindings.module_def { NoModuleDef => { debug!{"(building reduced graph for \ external crate) building module \ @@ -1296,7 +1296,7 @@ class Resolver { self.get_parent_link(new_parent, atom); - alt modules.find(def_id) { + match modules.find(def_id) { none => { (*child_name_bindings). define_module(parent_link, @@ -1315,7 +1315,9 @@ class Resolver { resolution. outstanding_references = 0; - alt existing_module.parent_link { + match existing_module + .parent_link { + NoParentLink | BlockParentLink(*) => { fail ~"can't happen"; @@ -1368,8 +1370,9 @@ class Resolver { // If this is a trait, add all the method names // to the trait info. - alt get_method_names_if_trait(self.session.cstore, - def_id) { + match get_method_names_if_trait( + self.session.cstore, def_id) { + none => { // Nothing to do. } @@ -1437,7 +1440,7 @@ class Resolver { self.build_reduced_graph_for_impls_in_external_module(module_); for module_.children.each |_name, child_node| { - alt (*child_node).get_module_if_available() { + match (*child_node).get_module_if_available() { none => { // Nothing to do. } @@ -1464,7 +1467,7 @@ class Resolver { self.module_to_str(module_), copy module_.def_id}; - alt module_.def_id { + match module_.def_id { none => { debug!{"(building reduced graph for impls in external \ module) no def ID for `%s`, skipping", @@ -1516,9 +1519,9 @@ class Resolver { // Bump the reference count on the name. Or, if this is a glob, set // the appropriate flag. - alt *subclass { + match *subclass { SingleImport(target, _) => { - alt module_.import_resolutions.find(target) { + match module_.import_resolutions.find(target) { some(resolution) => { resolution.outstanding_references += 1u; } @@ -1588,7 +1591,7 @@ class Resolver { self.resolve_imports_for_module(module_); for module_.children.each |_name, child_node| { - alt (*child_node).get_module_if_available() { + match (*child_node).get_module_if_available() { none => { // Nothing to do. } @@ -1616,7 +1619,7 @@ class Resolver { while module_.resolved_import_count < import_count { let import_index = module_.resolved_import_count; let import_directive = module_.imports.get_elt(import_index); - alt self.resolve_import_for_module(module_, import_directive) { + match self.resolve_import_for_module(module_, import_directive) { Failed => { // We presumably emitted an error. Continue. self.session.span_err(import_directive.span, @@ -1663,7 +1666,7 @@ class Resolver { import_directive); } else { // First, resolve the module path for the directive, if necessary. - alt self.resolve_module_path_for_import(module_, + match self.resolve_module_path_for_import(module_, module_path, NoXray, import_directive.span) { @@ -1678,7 +1681,7 @@ class Resolver { // We found the module that the target is contained // within. Attempt to resolve the import within it. - alt *import_directive.subclass { + match *import_directive.subclass { SingleImport(target, source) => { resolution_result = self.resolve_single_import(module_, @@ -1699,7 +1702,7 @@ class Resolver { } // Decrement the count of unresolved imports. - alt resolution_result { + match resolution_result { Success(()) => { assert self.unresolved_imports >= 1u; self.unresolved_imports -= 1u; @@ -1715,7 +1718,7 @@ class Resolver { // resolve_imports_for_module.) if resolution_result != Indeterminate { - alt *import_directive.subclass { + match *import_directive.subclass { GlobImport => { assert module_.glob_count >= 1u; module_.glob_count -= 1u; @@ -1757,7 +1760,7 @@ class Resolver { let mut impl_result = UnknownImplResult; // Search for direct children of the containing module. - alt containing_module.children.find(source) { + match containing_module.children.find(source) { none => { // Continue. } @@ -1786,7 +1789,7 @@ class Resolver { // Unless we managed to find a result in all four namespaces // (exceedingly unlikely), search imports as well. - alt (module_result, value_result, type_result, impl_result) { + match (module_result, value_result, type_result, impl_result) { (BoundResult(*), BoundResult(*), BoundResult(*), BoundImplResult(*)) => { // Continue. @@ -1805,7 +1808,7 @@ class Resolver { // Now search the exported imports within the containing // module. - alt containing_module.import_resolutions.find(source) { + match containing_module.import_resolutions.find(source) { none => { // The containing module definitely doesn't have an // exported import with the name in question. We can @@ -1833,7 +1836,7 @@ class Resolver { namespace: Namespace) -> NamespaceResult { - alt (*import_resolution). + match (*import_resolution). target_for_namespace(namespace) { none => { return UnboundResult; @@ -1892,7 +1895,7 @@ class Resolver { assert module_.import_resolutions.contains_key(target); let import_resolution = module_.import_resolutions.get(target); - alt module_result { + match module_result { BoundResult(target_module, name_bindings) => { debug!{"(resolving single import) found module binding"}; import_resolution.module_target = @@ -1906,7 +1909,7 @@ class Resolver { fail ~"module result should be known at this point"; } } - alt value_result { + match value_result { BoundResult(target_module, name_bindings) => { import_resolution.value_target = some(Target(target_module, name_bindings)); @@ -1916,7 +1919,7 @@ class Resolver { fail ~"value result should be known at this point"; } } - alt type_result { + match type_result { BoundResult(target_module, name_bindings) => { import_resolution.type_target = some(Target(target_module, name_bindings)); @@ -1926,7 +1929,7 @@ class Resolver { fail ~"type result should be known at this point"; } } - alt impl_result { + match impl_result { BoundImplResult(targets) => { for (*targets).each |target| { (*import_resolution.impl_target).push(target); @@ -1939,7 +1942,8 @@ class Resolver { } let i = import_resolution; - alt (i.module_target, i.value_target, i.type_target, i.impl_target) { + match (i.module_target, i.value_target, + i.type_target, i.impl_target) { /* If this name wasn't found in any of the four namespaces, it's definitely unresolved @@ -1996,7 +2000,7 @@ class Resolver { self.module_to_str(module_)}; // Here we merge two import resolutions. - alt module_.import_resolutions.find(atom) { + match module_.import_resolutions.find(atom) { none => { // Simple: just copy the old import resolution. let new_import_resolution = @@ -2017,7 +2021,7 @@ class Resolver { // Merge the two import resolutions at a finer-grained // level. - alt copy target_import_resolution.module_target { + match copy target_import_resolution.module_target { none => { // Continue. } @@ -2026,7 +2030,7 @@ class Resolver { some(copy module_target); } } - alt copy target_import_resolution.value_target { + match copy target_import_resolution.value_target { none => { // Continue. } @@ -2035,7 +2039,7 @@ class Resolver { some(copy value_target); } } - alt copy target_import_resolution.type_target { + match copy target_import_resolution.type_target { none => { // Continue. } @@ -2068,7 +2072,7 @@ class Resolver { } let mut dest_import_resolution; - alt module_.import_resolutions.find(atom) { + match module_.import_resolutions.find(atom) { none => { // Create a new import resolution from this child. dest_import_resolution = @ImportResolution(span); @@ -2131,7 +2135,7 @@ class Resolver { while index < module_path_len { let name = (*module_path).get_elt(index); - alt self.resolve_name_in_module(search_module, name, ModuleNS, + match self.resolve_name_in_module(search_module, name, ModuleNS, xray) { Failed => { @@ -2145,7 +2149,7 @@ class Resolver { return Indeterminate; } Success(target) => { - alt target.bindings.module_def { + match target.bindings.module_def { NoModuleDef => { // Not a module. self.session.span_err(span, @@ -2190,7 +2194,7 @@ class Resolver { let first_element = (*module_path).get_elt(0u); let mut search_module; - alt self.resolve_module_in_lexical_scope(module_, first_element) { + match self.resolve_module_in_lexical_scope(module_, first_element) { Failed => { self.session.span_err(span, ~"unresolved name"); return Failed; @@ -2226,7 +2230,7 @@ class Resolver { // The current module node is handled specially. First, check for // its immediate children. - alt module_.children.find(name) { + match module_.children.find(name) { some(name_bindings) if (*name_bindings).defined_in_namespace(namespace) => { @@ -2240,12 +2244,12 @@ class Resolver { // adjacent import statements are processed as though they mutated the // current scope. - alt module_.import_resolutions.find(name) { + match module_.import_resolutions.find(name) { none => { // Not found; continue. } some(import_resolution) => { - alt (*import_resolution).target_for_namespace(namespace) { + match (*import_resolution).target_for_namespace(namespace) { none => { // Not found; continue. debug!{"(resolving item in lexical scope) found \ @@ -2264,7 +2268,7 @@ class Resolver { let mut search_module = module_; loop { // Go to the next parent. - alt search_module.parent_link { + match search_module.parent_link { NoParentLink => { // No more parents. This module was unresolved. debug!{"(resolving item in lexical scope) unresolved \ @@ -2278,7 +2282,7 @@ class Resolver { } // Resolve the name in the parent module. - alt self.resolve_name_in_module(search_module, name, namespace, + match self.resolve_name_in_module(search_module, name, namespace, Xray) { Failed => { // Continue up the search chain. @@ -2302,9 +2306,9 @@ class Resolver { fn resolve_module_in_lexical_scope(module_: @Module, name: Atom) -> ResolveResult<@Module> { - alt self.resolve_item_in_lexical_scope(module_, name, ModuleNS) { + match self.resolve_item_in_lexical_scope(module_, name, ModuleNS) { Success(target) => { - alt target.bindings.module_def { + match target.bindings.module_def { NoModuleDef => { error!{"!!! (resolving module in lexical scope) module wasn't actually a module!"}; @@ -2355,7 +2359,7 @@ class Resolver { } // First, check the direct children of the module. - alt module_.children.find(name) { + match module_.children.find(name) { some(name_bindings) if (*name_bindings).defined_in_namespace(namespace) => { @@ -2376,7 +2380,7 @@ class Resolver { } // Otherwise, we check the list of resolved imports. - alt module_.import_resolutions.find(name) { + match module_.import_resolutions.find(name) { some(import_resolution) => { if import_resolution.outstanding_references != 0u { debug!{"(resolving name in module) import unresolved; \ @@ -2384,7 +2388,7 @@ class Resolver { return Indeterminate; } - alt (*import_resolution).target_for_namespace(namespace) { + match (*import_resolution).target_for_namespace(namespace) { none => { debug!{"(resolving name in module) name found, but \ not in namespace %?", @@ -2420,7 +2424,7 @@ class Resolver { let mut target_name; let mut source_name; - alt *import_directive.subclass { + match *import_directive.subclass { SingleImport(target, source) => { target_name = target; source_name = source; @@ -2442,7 +2446,7 @@ class Resolver { let mut module_result; debug!{"(resolving one-level naming result) searching for module"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, ModuleNS) { @@ -2465,7 +2469,7 @@ class Resolver { let mut value_result; debug!{"(resolving one-level naming result) searching for value"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, ValueNS) { @@ -2488,7 +2492,7 @@ class Resolver { let mut type_result; debug!{"(resolving one-level naming result) searching for type"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, TypeNS) { @@ -2528,7 +2532,7 @@ class Resolver { let mut impl_result; debug!{"(resolving one-level naming result) searching for impl"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, ImplNS) { @@ -2559,7 +2563,7 @@ class Resolver { } // Otherwise, proceed and write in the bindings. - alt module_.import_resolutions.find(target_name) { + match module_.import_resolutions.find(target_name) { none => { fail ~"(resolving one-level renaming import) reduced graph \ construction or glob importing should have created the \ @@ -2576,7 +2580,7 @@ class Resolver { import_resolution.value_target = value_result; import_resolution.type_target = type_result; - alt impl_result { + match impl_result { none => { // Nothing to do. } @@ -2604,7 +2608,7 @@ class Resolver { // Descend into children and anonymous children. for module_.children.each |_name, child_node| { - alt (*child_node).get_module_if_available() { + match (*child_node).get_module_if_available() { none => { // Continue. } @@ -2637,7 +2641,7 @@ class Resolver { // If this isn't a local crate, then bail out. We don't need to record // exports for local crates. - alt module_.def_id { + match module_.def_id { some(def_id) if def_id.crate == local_crate => { // OK. Continue. } @@ -2656,7 +2660,7 @@ class Resolver { self.record_exports_for_module(module_); for module_.children.each |_atom, child_name_bindings| { - alt (*child_name_bindings).get_module_if_available() { + match (*child_name_bindings).get_module_if_available() { none => { // Nothing to do. } @@ -2682,7 +2686,7 @@ class Resolver { again; } - alt self.resolve_definition_of_name_in_module(module_, + match self.resolve_definition_of_name_in_module(module_, name, namespace, Xray) { @@ -2723,7 +2727,7 @@ class Resolver { // If this isn't a local crate, then bail out. We don't need to // resolve implementations for external crates. - alt module_.def_id { + match module_.def_id { some(def_id) if def_id.crate == local_crate => { // OK. Continue. } @@ -2742,7 +2746,7 @@ class Resolver { self.build_impl_scope_for_module(module_); for module_.children.each |_atom, child_name_bindings| { - alt (*child_name_bindings).get_module_if_available() { + match (*child_name_bindings).get_module_if_available() { none => { // Nothing to do. } @@ -2788,7 +2792,7 @@ class Resolver { // Determine the parent's implementation scope. let mut parent_impl_scopes; - alt module_.parent_link { + match module_.parent_link { NoParentLink => { parent_impl_scopes = @nil; } @@ -2830,19 +2834,19 @@ class Resolver { let orig_module = self.current_module; // Move down in the graph. - alt name { + match name { none => { // Nothing to do. } some(name) => { - alt orig_module.children.find(name) { + match orig_module.children.find(name) { none => { debug!{"!!! (with scope) didn't find `%s` in `%s`", *(*self.atom_table).atom_to_str(name), self.module_to_str(orig_module)}; } some(name_bindings) => { - alt (*name_bindings).get_module_if_available() { + match (*name_bindings).get_module_if_available() { none => { debug!{"!!! (with scope) didn't find module \ for `%s` in `%s`", @@ -2873,7 +2877,7 @@ class Resolver { let mut def; let mut is_ty_param; - alt def_like { + match def_like { dl_def(d @ def_local(*)) | dl_def(d @ def_upvar(*)) | dl_def(d @ def_arg(*)) | dl_def(d @ def_binding(*)) => { def = d; @@ -2896,7 +2900,7 @@ class Resolver { let mut rib_index = rib_index + 1u; while rib_index < (*ribs).len() { let rib = (*ribs).get_elt(rib_index); - alt rib.kind { + match rib.kind { NormalRibKind => { // Nothing to do. Continue. } @@ -2910,7 +2914,7 @@ class Resolver { MethodRibKind(item_id, method_id) => { // If the def is a ty param, and came from the parent // item, it's ok - alt def { + match def { def_ty_param(did, _) if self.def_map.find(copy(did.node)) == some(def_typaram_binder(item_id)) => { // ok @@ -2976,7 +2980,7 @@ class Resolver { while i != 0u { i -= 1u; let rib = (*ribs).get_elt(i); - alt rib.bindings.find(name) { + match rib.bindings.find(name) { some(def_like) => { return self.upvarify(ribs, i, def_like, span, allow_capturing_self); @@ -3028,7 +3032,7 @@ class Resolver { self.xray_context = Xray; } - alt item.node { + match item.node { item_enum(_, type_parameters) | item_ty(_, type_parameters) => { do self.with_type_parameter_rib @@ -3090,7 +3094,7 @@ class Resolver { // // XXX: Do we need a node ID here? - alt method { + match method { required(ty_m) => { do self.with_type_parameter_rib (HasTypeParameters(&ty_m.tps, @@ -3148,7 +3152,7 @@ class Resolver { let atom = (*self.atom_table).intern(item.ident); do self.with_scope(some(atom)) { for foreign_module.items.each |foreign_item| { - alt foreign_item.node { + match foreign_item.node { foreign_item_fn(_, type_parameters) => { do self.with_type_parameter_rib (HasTypeParameters(&type_parameters, @@ -3206,7 +3210,7 @@ class Resolver { } fn with_type_parameter_rib(type_parameters: TypeParameters, f: fn()) { - alt type_parameters { + match type_parameters { HasTypeParameters(type_parameters, node_id, initial_index, rib_kind) => { @@ -3236,7 +3240,7 @@ class Resolver { f(); - alt type_parameters { + match type_parameters { HasTypeParameters(type_parameters, _, _, _) => { (*self.type_ribs).pop(); } @@ -3256,14 +3260,14 @@ class Resolver { visitor: ResolveVisitor) { // Check each element of the capture clause. - alt capture_clause { + match capture_clause { NoCaptureClause => { // Nothing to do. } HasCaptureClause(capture_clause) => { // Resolve each captured item. for (*capture_clause).each |capture_item| { - alt self.resolve_identifier(capture_item.name, + match self.resolve_identifier(capture_item.name, ValueNS, true, capture_item.span) { @@ -3287,7 +3291,7 @@ class Resolver { // If this function has type parameters, add them now. do self.with_type_parameter_rib(type_parameters) { // Resolve the type parameters. - alt type_parameters { + match type_parameters { NoTypeParameters => { // Continue. } @@ -3297,7 +3301,7 @@ class Resolver { } // Add self to the rib, if necessary. - alt self_binding { + match self_binding { NoSelfBinding => { // Nothing to do. } @@ -3309,7 +3313,7 @@ class Resolver { } // Add each argument to the rib. - alt optional_declaration { + match optional_declaration { none => { // Nothing to do. } @@ -3344,7 +3348,7 @@ class Resolver { for type_parameters.each |type_parameter| { for (*type_parameter.bounds).each |bound| { - alt bound { + match bound { bound_copy | bound_send | bound_const | bound_owned => { // Nothing to do. } @@ -3379,7 +3383,7 @@ class Resolver { // Resolve implemented traits. for traits.each |trt| { - alt self.resolve_path(trt.path, TypeNS, true, visitor) { + match self.resolve_path(trt.path, TypeNS, true, visitor) { none => { self.session.span_err(trt.path.span, ~"attempt to implement a \ @@ -3404,7 +3408,7 @@ class Resolver { // Resolve methods. for class_members.each |class_member| { - alt class_member.node { + match class_member.node { class_method(method) => { self.resolve_method(MethodRibKind(id, Provided(method.id)), @@ -3419,7 +3423,7 @@ class Resolver { } // Resolve the constructor, if applicable. - alt optional_constructor { + match optional_constructor { none => { // Nothing to do. } @@ -3436,7 +3440,7 @@ class Resolver { } // Resolve the destructor, if applicable. - alt optional_destructor { + match optional_destructor { none => { // Nothing to do. } @@ -3498,8 +3502,8 @@ class Resolver { if trait_references.len() >= 1 { let mut new_trait_refs = @dvec(); for trait_references.each |trait_reference| { - alt self.resolve_path(trait_reference.path, TypeNS, true, - visitor) { + match self.resolve_path( + trait_reference.path, TypeNS, true, visitor) { none => { self.session.span_err(span, ~"attempt to implement an \ @@ -3566,7 +3570,7 @@ class Resolver { self.resolve_type(local.node.ty, visitor); // Resolve the initializer, if necessary. - alt local.node.init { + match local.node.init { none => { // Nothing to do. } @@ -3639,7 +3643,7 @@ class Resolver { // Move down in the graph, if there's an anonymous module rooted here. let orig_module = self.current_module; - alt self.current_module.anonymous_children.find(block.node.id) { + match self.current_module.anonymous_children.find(block.node.id) { none => { /* Nothing to do. */ } some(anonymous_module) => { debug!{"(resolving block) found anonymous module, moving \ @@ -3659,7 +3663,7 @@ class Resolver { } fn resolve_type(ty: @ty, visitor: ResolveVisitor) { - alt ty.node { + match ty.node { // Like path expressions, the interpretation of path types depends // on whether the path has multiple elements in it or not. @@ -3668,7 +3672,7 @@ class Resolver { // scopes looking for it. let mut result_def; - alt self.resolve_path(path, TypeNS, true, visitor) { + match self.resolve_path(path, TypeNS, true, visitor) { some(def) => { debug!{"(resolving type) resolved `%s` to type", *path.idents.last()}; @@ -3679,7 +3683,7 @@ class Resolver { } } - alt result_def { + match result_def { some(_) => { // Continue. } @@ -3689,7 +3693,7 @@ class Resolver { let name = (*self.atom_table).intern(path.idents.last()); - alt self.primitive_type_table + match self.primitive_type_table .primitive_types .find(name) { @@ -3705,7 +3709,7 @@ class Resolver { } } - alt copy result_def { + match copy result_def { some(def) => { // Write the result into the def map. debug!{"(resolving type) writing resolution for `%s` \ @@ -3740,7 +3744,7 @@ class Resolver { let pat_id = pattern.id; do walk_pat(pattern) |pattern| { - alt pattern.node { + match pattern.node { pat_ident(binding_mode, path, _) if !path.global && path.idents.len() == 1u => { @@ -3754,7 +3758,7 @@ class Resolver { let atom = (*self.atom_table).intern(path.idents[0]); - alt self.resolve_enum_variant_or_const(atom) { + match self.resolve_enum_variant_or_const(atom) { FoundEnumVariant(def) if mode == RefutableMode => { debug!{"(resolving pattern) resolving `%s` to \ enum variant", @@ -3783,7 +3787,7 @@ class Resolver { let is_mutable = mutability == Mutable; - let def = alt mode { + let def = match mode { RefutableMode => { // For pattern arms, we must use // `def_binding` definitions. @@ -3808,7 +3812,7 @@ class Resolver { // because that breaks the assumptions later // passes make about or-patterns.) - alt bindings_list { + match bindings_list { some(bindings_list) if !bindings_list.contains_key(atom) => { let last_rib = (*self.value_ribs).last(); @@ -3845,7 +3849,7 @@ class Resolver { pat_ident(_, path, _) | pat_enum(path, _) => { // These two must be enum variants. - alt self.resolve_path(path, ValueNS, false, visitor) { + match self.resolve_path(path, ValueNS, false, visitor) { some(def @ def_variant(*)) => { self.record_def(pattern.id, def); } @@ -3886,12 +3890,12 @@ class Resolver { fn resolve_enum_variant_or_const(name: Atom) -> EnumVariantOrConstResolution { - alt self.resolve_item_in_lexical_scope(self.current_module, + match self.resolve_item_in_lexical_scope(self.current_module, name, ValueNS) { Success(target) => { - alt target.bindings.value_def { + match target.bindings.value_def { none => { fail ~"resolved name in the value namespace to a set \ of name bindings with no def?!"; @@ -3956,7 +3960,7 @@ class Resolver { -> option<def> { if check_ribs { - alt self.resolve_identifier_in_local_ribs(identifier, + match self.resolve_identifier_in_local_ribs(identifier, namespace, span) { some(def) => { @@ -3987,9 +3991,9 @@ class Resolver { } // First, search children. - alt containing_module.children.find(name) { + match containing_module.children.find(name) { some(child_name_bindings) => { - alt (*child_name_bindings).def_for_namespace(namespace) { + match (*child_name_bindings).def_for_namespace(namespace) { some(def) => { // Found it. Stop the search here. return ChildNameDefinition(def); @@ -4005,11 +4009,12 @@ class Resolver { } // Next, search import resolutions. - alt containing_module.import_resolutions.find(name) { + match containing_module.import_resolutions.find(name) { some(import_resolution) => { - alt (*import_resolution).target_for_namespace(namespace) { + match (*import_resolution).target_for_namespace(namespace) { some(target) => { - alt (*target.bindings).def_for_namespace(namespace) { + match (*target.bindings) + .def_for_namespace(namespace) { some(def) => { // Found it. import_resolution.used = true; @@ -4055,7 +4060,7 @@ class Resolver { let module_path_atoms = self.intern_module_part_of_path(path); let mut containing_module; - alt self.resolve_module_path_for_import(self.current_module, + match self.resolve_module_path_for_import(self.current_module, module_path_atoms, xray, path.span) { @@ -4078,7 +4083,7 @@ class Resolver { } let name = (*self.atom_table).intern(path.idents.last()); - alt self.resolve_definition_of_name_in_module(containing_module, + match self.resolve_definition_of_name_in_module(containing_module, name, namespace, xray) { @@ -4108,7 +4113,7 @@ class Resolver { let root_module = (*self.graph_root).get_module(); let mut containing_module; - alt self.resolve_module_path_from_root(root_module, + match self.resolve_module_path_from_root(root_module, module_path_atoms, 0u, xray, @@ -4132,7 +4137,7 @@ class Resolver { } let name = (*self.atom_table).intern(path.idents.last()); - alt self.resolve_definition_of_name_in_module(containing_module, + match self.resolve_definition_of_name_in_module(containing_module, name, namespace, xray) { @@ -4161,7 +4166,7 @@ class Resolver { // Check the local set of ribs. let mut search_result; - alt namespace { + match namespace { ValueNS => { search_result = self.search_ribs(self.value_ribs, name, span, DontAllowCapturingSelf); @@ -4175,7 +4180,7 @@ class Resolver { } } - alt copy search_result { + match copy search_result { some(dl_def(def)) => { debug!{"(resolving path in local ribs) resolved `%s` to \ local: %?", @@ -4196,12 +4201,12 @@ class Resolver { let name = (*self.atom_table).intern(ident); // Check the items. - alt self.resolve_item_in_lexical_scope(self.current_module, + match self.resolve_item_in_lexical_scope(self.current_module, name, namespace) { Success(target) => { - alt (*target.bindings).def_for_namespace(namespace) { + match (*target.bindings).def_for_namespace(namespace) { none => { fail ~"resolved name in a namespace to a set of name \ bindings with no def for that namespace?!"; @@ -4235,7 +4240,7 @@ class Resolver { self.record_candidate_traits_for_expr_if_necessary(expr); // Next, resolve the node. - alt expr.node { + match expr.node { // The interpretation of paths depends on whether the path has // multiple elements in it or not. @@ -4243,7 +4248,7 @@ class Resolver { // This is a local path in the value namespace. Walk through // scopes looking for it. - alt self.resolve_path(path, ValueNS, true, visitor) { + match self.resolve_path(path, ValueNS, true, visitor) { some(def) => { // Write the result into the def map. debug!{"(resolving expr) resolved `%s`", @@ -4288,7 +4293,7 @@ class Resolver { // type Bar<A> = Foo<A>; // let bar = Bar { ... } // no type parameters - alt self.resolve_path(path, TypeNS, false, visitor) { + match self.resolve_path(path, TypeNS, false, visitor) { some(definition @ def_ty(class_id)) if self.structs.contains_key(class_id) => { @@ -4316,7 +4321,7 @@ class Resolver { } fn record_impls_for_expr_if_necessary(expr: @expr) { - alt expr.node { + match expr.node { expr_field(*) | expr_path(*) | expr_cast(*) | expr_binary(*) | expr_unary(*) | expr_assign_op(*) | expr_index(*) => { self.impl_map.insert(expr.id, @@ -4329,7 +4334,7 @@ class Resolver { } fn record_candidate_traits_for_expr_if_necessary(expr: @expr) { - alt expr.node { + match expr.node { expr_field(_, ident, _) => { let atom = (*self.atom_table).intern(ident); let traits = self.search_for_traits_containing_method(atom); @@ -4394,7 +4399,7 @@ class Resolver { let mut search_module = self.current_module; loop { // Look for the current trait. - alt copy self.current_trait_refs { + match copy self.current_trait_refs { some(trait_def_ids) => { for trait_def_ids.each |trait_def_id| { self.add_trait_info_if_containing_method @@ -4408,7 +4413,7 @@ class Resolver { // Look for trait children. for search_module.children.each |_name, child_name_bindings| { - alt child_name_bindings.def_for_namespace(TypeNS) { + match child_name_bindings.def_for_namespace(TypeNS) { some(def_ty(trait_def_id)) => { self.add_trait_info_if_containing_method(found_traits, trait_def_id, @@ -4424,12 +4429,12 @@ class Resolver { for search_module.import_resolutions.each |_atom, import_resolution| { - alt import_resolution.target_for_namespace(TypeNS) { + match import_resolution.target_for_namespace(TypeNS) { none => { // Continue. } some(target) => { - alt target.bindings.def_for_namespace(TypeNS) { + match target.bindings.def_for_namespace(TypeNS) { some(def_ty(trait_def_id)) => { self.add_trait_info_if_containing_method (found_traits, trait_def_id, name); @@ -4443,7 +4448,7 @@ class Resolver { } // Move to the next parent. - alt search_module.parent_link { + match search_module.parent_link { NoParentLink => { // Done. break; @@ -4462,7 +4467,7 @@ class Resolver { trait_def_id: def_id, name: Atom) { - alt self.trait_info.find(trait_def_id) { + match self.trait_info.find(trait_def_id) { some(trait_info) if trait_info.contains_key(name) => { debug!{"(adding trait info if containing method) found trait \ %d:%d for method '%s'", @@ -4508,7 +4513,7 @@ class Resolver { // If this isn't a local crate, then bail out. We don't need to check // for unused imports in external crates. - alt module_.def_id { + match module_.def_id { some(def_id) if def_id.crate == local_crate => { // OK. Continue. } @@ -4527,7 +4532,7 @@ class Resolver { self.check_for_unused_imports_in_module(module_); for module_.children.each |_atom, child_name_bindings| { - alt (*child_name_bindings).get_module_if_available() { + match (*child_name_bindings).get_module_if_available() { none => { // Nothing to do. } @@ -4546,7 +4551,7 @@ class Resolver { fn check_for_unused_imports_in_module(module_: @Module) { for module_.import_resolutions.each |_impl_name, import_resolution| { if !import_resolution.used { - alt self.unused_import_lint_level { + match self.unused_import_lint_level { warn => { self.session.span_warn(import_resolution.span, ~"unused import"); @@ -4577,7 +4582,7 @@ class Resolver { let atoms = dvec(); let mut current_module = module_; loop { - alt current_module.parent_link { + match current_module.parent_link { NoParentLink => { break; } @@ -4624,7 +4629,7 @@ class Resolver { debug!{"Import resolutions:"}; for module_.import_resolutions.each |name, import_resolution| { let mut module_repr; - alt (*import_resolution).target_for_namespace(ModuleNS) { + match (*import_resolution).target_for_namespace(ModuleNS) { none => { module_repr = ~""; } some(target) => { module_repr = ~" module:?"; @@ -4633,7 +4638,7 @@ class Resolver { } let mut value_repr; - alt (*import_resolution).target_for_namespace(ValueNS) { + match (*import_resolution).target_for_namespace(ValueNS) { none => { value_repr = ~""; } some(target) => { value_repr = ~" value:?"; @@ -4642,7 +4647,7 @@ class Resolver { } let mut type_repr; - alt (*import_resolution).target_for_namespace(TypeNS) { + match (*import_resolution).target_for_namespace(TypeNS) { none => { type_repr = ~""; } some(target) => { type_repr = ~" type:?"; @@ -4651,7 +4656,7 @@ class Resolver { } let mut impl_repr; - alt (*import_resolution).target_for_namespace(ImplNS) { + match (*import_resolution).target_for_namespace(ImplNS) { none => { impl_repr = ~""; } some(target) => { impl_repr = ~" impl:?"; @@ -4671,7 +4676,7 @@ class Resolver { let mut i = 0u; let mut impl_scopes = impl_scopes; loop { - alt *impl_scopes { + match *impl_scopes { cons(impl_scope, rest_impl_scopes) => { debug!{"Impl scope %u:", i}; diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index e3103cfefc6..783a856fd9d 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -25,7 +25,7 @@ enum opt { range(@ast::expr, @ast::expr) } fn opt_eq(tcx: ty::ctxt, a: opt, b: opt) -> bool { - alt (a, b) { + match (a, b) { (lit(a), lit(b)) => const_eval::compare_lit_exprs(tcx, a, b) == 0, (range(a1, a2), range(b1, b2)) => { const_eval::compare_lit_exprs(tcx, a1, b1) == 0 && @@ -44,9 +44,9 @@ fn trans_opt(bcx: block, o: opt) -> opt_result { let _icx = bcx.insn_ctxt(~"alt::trans_opt"); let ccx = bcx.ccx(); let mut bcx = bcx; - alt o { + match o { lit(l) => { - alt l.node { + match l.node { ast::expr_vstore(@{node: ast::expr_lit( @{node: ast::lit_str(s), _}), _}, ast::vstore_uniq) => { @@ -112,7 +112,7 @@ type match_ = ~[match_branch]; fn has_nested_bindings(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_ident(_, _, some(_)) => return true, _ => () } @@ -125,7 +125,7 @@ fn expand_nested_bindings(bcx: block, m: match_, col: uint, val: ValueRef) let mut result = ~[]; for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_ident(mode, name, some(inner)) => { let pats = vec::append( vec::slice(br.pats, 0u, col), @@ -155,13 +155,13 @@ fn enter_match(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef, e: enter_pat) -> match_ { let mut result = ~[]; for vec::each(m) |br| { - alt e(br.pats[col]) { + match e(br.pats[col]) { some(sub) => { let pats = vec::append( vec::append(sub, vec::view(br.pats, 0u, col)), vec::view(br.pats, col + 1u, br.pats.len())); let self = br.pats[col]; - let bound = alt self.node { + let bound = match self.node { ast::pat_ident(mode, name, none) if !pat_is_variant(dm, self) => { vec::append(br.bound, @@ -186,7 +186,7 @@ fn enter_default(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) -> match_ { do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) => some(~[]), ast::pat_ident(_, _, none) if !pat_is_variant(dm, p) => some(~[]), _ => none @@ -199,7 +199,7 @@ fn enter_opt(bcx: block, m: match_, opt: opt, col: uint, let tcx = bcx.tcx(); let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, tcx.def_map, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_enum(_, subpats) => { if opt_eq(tcx, variant_opt(tcx, p.id), opt) { some(option::get_default(subpats, @@ -225,7 +225,7 @@ fn enter_rec(bcx: block, dm: DefMap, m: match_, col: uint, fields: ~[ast::ident], val: ValueRef) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_rec(fpats, _) => { let mut pats = ~[]; for vec::each(fields) |fname| { @@ -246,7 +246,7 @@ fn enter_tup(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef, n_elts: uint) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_tup(elts) => some(elts), _ => some(vec::from_elem(n_elts, dummy)) } @@ -257,7 +257,7 @@ fn enter_box(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_box(sub) => some(~[sub]), _ => some(~[dummy]) } @@ -268,7 +268,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_uniq(sub) => some(~[sub]), _ => some(~[dummy]) } @@ -287,7 +287,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] { if pat_is_variant(ccx.tcx.def_map, cur) { add_to_set(ccx.tcx, found, variant_opt(ccx.tcx, br.pats[col].id)); } else { - alt cur.node { + match cur.node { ast::pat_lit(l) => add_to_set(ccx.tcx, found, lit(l)), ast::pat_range(l1, l2) => { add_to_set(ccx.tcx, found, range(l1, l2)); @@ -304,7 +304,9 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, {vals: ~[ValueRef], bcx: block} { let _icx = bcx.insn_ctxt(~"alt::extract_variant_args"); let ccx = bcx.fcx.ccx; - let enum_ty_substs = alt check ty::get(node_id_type(bcx, pat_id)).struct { + let enum_ty_substs = match check ty::get(node_id_type(bcx, pat_id)) + .struct { + ty::ty_enum(id, substs) => { assert id == vdefs.enm; substs.tps } }; let mut blobptr = val; @@ -328,7 +330,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] { let mut fields: ~[ast::ident] = ~[]; for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_rec(fs, _) => { for vec::each(fs) |f| { if !vec::any(fields, |x| str::eq(f.ident, x)) { @@ -346,7 +348,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) { for vec::each(m) |br| { let pat_id = br.pats[col].id; - alt bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) { + match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) { none => (), some(scope_id) => { // Note: the scope_id will always be the id of the alt. See the @@ -364,7 +366,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) { fn any_box_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_box(_) => return true, _ => () } @@ -374,7 +376,7 @@ fn any_box_pat(m: match_, col: uint) -> bool { fn any_uniq_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_uniq(_) => return true, _ => () } @@ -384,7 +386,7 @@ fn any_uniq_pat(m: match_, col: uint) -> bool { fn any_tup_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_tup(_) => return true, _ => () } @@ -397,7 +399,7 @@ type mk_fail = fn@() -> BasicBlockRef; fn pick_col(m: match_) -> uint { fn score(p: @ast::pat) -> uint { - alt p.node { + match p.node { ast::pat_lit(_) | ast::pat_enum(_, _) | ast::pat_range(_, _) => 1u, ast::pat_ident(_, _, some(p)) => score(p), _ => 0u @@ -435,7 +437,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], if m.len() == 0u { Br(bcx, option::get(chk)()); return; } if m[0].pats.len() == 0u { let data = m[0].data; - alt data.guard { + match data.guard { some(e) => { // Temporarily set bindings. They'll be rewritten to PHI nodes // for the actual arm block. @@ -512,7 +514,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], if any_tup_pat(m, col) { let tup_ty = node_id_type(bcx, pat_id); - let n_tup_elts = alt ty::get(tup_ty).struct { + let n_tup_elts = match ty::get(tup_ty).struct { ty::ty_tup(elts) => elts.len(), _ => ccx.sess.bug(~"non-tuple type in tuple pattern") }; @@ -553,7 +555,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let mut kind = no_branch; let mut test_val = val; if opts.len() > 0u { - alt opts[0] { + match opts[0] { var(_, vdef) => { if (*ty::enum_variants(tcx, vdef.enm)).len() == 1u { kind = single; @@ -578,12 +580,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], } } for vec::each(opts) |o| { - alt o { + match o { range(_, _) => { kind = compare; break } _ => () } } - let else_cx = alt kind { + let else_cx = match kind { no_branch | single => bcx, _ => sub_block(bcx, ~"match_else") }; @@ -601,10 +603,10 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let mut opt_cx = else_cx; if !exhaustive || i < len { opt_cx = sub_block(bcx, ~"match_case"); - alt kind { + match kind { single => Br(bcx, opt_cx.llbb), switch => { - alt check trans_opt(bcx, opt) { + match check trans_opt(bcx, opt) { single_result(r) => { llvm::LLVMAddCase(sw, r.val, opt_cx.llbb); bcx = r.bcx; @@ -615,7 +617,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let t = node_id_type(bcx, pat_id); let {bcx: after_cx, val: matches} = { do with_scope_result(bcx, none, ~"compare_scope") |bcx| { - alt trans_opt(bcx, opt) { + match trans_opt(bcx, opt) { single_result({bcx, val}) => { trans_compare(bcx, ast::eq, test_val, t, val, t) } @@ -638,7 +640,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], } else if kind == compare { Br(bcx, else_cx.llbb); } let mut size = 0u; let mut unpacked = ~[]; - alt opt { + match opt { var(_, vdef) => { let args = extract_variant_args(opt_cx, pat_id, vdef, val); size = args.vals.len(); @@ -671,7 +673,7 @@ fn make_phi_bindings(bcx: block, map: ~[exit_node], let mut vals = ~[]; for vec::each(map) |ex| { if ex.to as uint == our_block { - alt assoc(name, ex.bound) { + match assoc(name, ex.bound) { some(binding) => { vec::push(llbbs, ex.from); vec::push(vals, binding.val); @@ -774,14 +776,14 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], fn mk_fail(bcx: block, sp: span, msg: ~str, done: @mut option<BasicBlockRef>) -> BasicBlockRef { - alt *done { some(bb) => return bb, _ => () } + match *done { some(bb) => return bb, _ => () } let fail_cx = sub_block(bcx, ~"case_fallthrough"); trans_fail(fail_cx, some(sp), msg); *done = some(fail_cx.llbb); return fail_cx.llbb; } let t = node_id_type(bcx, expr.id); - let mk_fail = alt mode { + let mk_fail = match mode { ast::alt_check => { let fail_cx = @mut none; // Cached fail-on-fallthrough block @@ -829,7 +831,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, let mut bcx = bcx; // Necessary since bind_irrefutable_pat is called outside trans_alt - alt pat.node { + match pat.node { ast::pat_ident(_, _,inner) => { if pat_is_variant(bcx.tcx().def_map, pat) { return bcx; } if make_copy { @@ -841,7 +843,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, bcx.fcx.lllocals.insert(pat.id, local_mem(alloc)); add_clean(bcx, alloc, ty); } else { bcx.fcx.lllocals.insert(pat.id, local_mem(val)); } - alt inner { + match inner { some(pat) => { bcx = bind_irrefutable_pat(bcx, pat, val, true); } _ => () } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 6fecdead048..6e882d71c00 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -66,7 +66,7 @@ enum dest { } fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str { - alt d { + match d { by_val(v) => fmt!{"by_val(%s)", val_str(ccx.tn, *v)}, save_in(v) => fmt!{"save_in(%s)", val_str(ccx.tn, v)}, ignore => ~"ignore" @@ -78,7 +78,7 @@ fn empty_dest_cell() -> @mut ValueRef { } fn dup_for_join(dest: dest) -> dest { - alt dest { + match dest { by_val(_) => by_val(empty_dest_cell()), _ => dest } @@ -128,7 +128,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], if !cx.unreachable { Br(cx, out.llbb); reachable = true; - alt in_ds[i] { + match in_ds[i] { by_val(cell) => { if option::is_none(phi) { phi = some(EmptyPhi(out, val_ty(*cell))); @@ -143,7 +143,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], if !reachable { Unreachable(out); } else { - alt out_dest { + match out_dest { by_val(cell) => *cell = option::get(phi), _ => () } @@ -153,7 +153,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], // Used to put an immediate value in a dest. fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { - alt dest { + match dest { ignore => (), by_val(cell) => *cell = val, save_in(addr) => Store(bcx, val, addr) @@ -162,7 +162,7 @@ fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { } fn get_dest_addr(dest: dest) -> ValueRef { - alt dest { + match dest { save_in(a) => a, _ => fail ~"get_dest_addr: not a save_in" } @@ -359,7 +359,7 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, let _icx = bcx.insn_ctxt(~"malloc_raw"); let ccx = bcx.ccx(); - let (mk_fn, rtcall) = alt heap { + let (mk_fn, rtcall) = match heap { heap_shared => (ty::mk_imm_box, ~"malloc"), heap_exchange => (ty::mk_imm_uniq, ~"exchange_malloc") }; @@ -419,7 +419,7 @@ fn get_tydesc_simple(ccx: @crate_ctxt, t: ty::t) -> ValueRef { } fn get_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { - alt ccx.tydescs.find(t) { + match ccx.tydescs.find(t) { some(inf) => inf, _ => { ccx.stats.n_static_tydescs += 1u; @@ -454,7 +454,7 @@ fn set_inline_hint(f: ValueRef) { fn set_inline_hint_if_appr(attrs: ~[ast::attribute], llfn: ValueRef) { - alt attr::find_inline_attr(attrs) { + match attr::find_inline_attr(attrs) { attr::ia_hint => set_inline_hint(llfn), attr::ia_always => set_always_inline(llfn), attr::ia_never => set_no_inline(llfn), @@ -577,22 +577,22 @@ fn emit_tydescs(ccx: @crate_ctxt) { let glue_fn_ty = T_ptr(T_glue_fn(ccx)); let ti = val; let take_glue = - alt copy ti.take_glue { + match copy ti.take_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; let drop_glue = - alt copy ti.drop_glue { + match copy ti.drop_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; let free_glue = - alt copy ti.free_glue { + match copy ti.free_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; let visit_glue = - alt copy ti.visit_glue { + match copy ti.visit_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; @@ -623,7 +623,7 @@ fn emit_tydescs(ccx: @crate_ctxt) { fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt(~"make_take_glue"); // NB: v is a *pointer* to type t here, not a direct value. - let bcx = alt ty::get(t).struct { + let bcx = match ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) => { incr_refcnt_of_boxed(bcx, Load(bcx, v)); bcx @@ -689,7 +689,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { // everything to a pointer to the type that the glue acts on). let _icx = bcx.insn_ctxt(~"make_free_glue"); let ccx = bcx.ccx(); - let bcx = alt ty::get(t).struct { + let bcx = match ty::get(t).struct { ty::ty_box(body_mt) => { let v = PointerCast(bcx, v, type_of(ccx, t)); let body = GEPi(bcx, v, ~[0u, abi::box_field_body]); @@ -770,7 +770,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { // NB: v0 is an *alias* of type t here, not a direct value. let _icx = bcx.insn_ctxt(~"make_drop_glue"); let ccx = bcx.ccx(); - let bcx = alt ty::get(t).struct { + let bcx = match ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_estr(ty::vstore_box) | ty::ty_evec(_, ty::vstore_box) => { decr_refcnt_maybe_free(bcx, Load(bcx, v0), t) @@ -784,7 +784,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { } ty::ty_class(did, substs) => { let tcx = bcx.tcx(); - alt ty::ty_dtor(tcx, did) { + match ty::ty_dtor(tcx, did) { some(dtor) => { trans_class_drop(bcx, v0, dtor, did, substs) } @@ -880,7 +880,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, op: ast::binop) -> result { let f = |a| compare_scalar_values(cx, lhs, rhs, a, op); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_nil => return rslt(cx, f(nil_type)), ty::ty_bool | ty::ty_ptr(_) => return rslt(cx, f(unsigned_int)), ty::ty_int(_) => return rslt(cx, f(signed_int)), @@ -909,11 +909,11 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, comparison operator"); } let die = fn@() -> ! { die_(cx) }; - alt nt { + match nt { nil_type => { // We don't need to do actual comparisons for nil. // () == () holds but () < () does not. - alt op { + match op { ast::eq | ast::le | ast::ge => return C_bool(true), ast::ne | ast::lt | ast::gt => return C_bool(false), // refinements would be nice @@ -921,7 +921,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, } } floating_point => { - let cmp = alt op { + let cmp = match op { ast::eq => lib::llvm::RealOEQ, ast::ne => lib::llvm::RealUNE, ast::lt => lib::llvm::RealOLT, @@ -933,7 +933,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, return FCmp(cx, cmp, lhs, rhs); } signed_int => { - let cmp = alt op { + let cmp = match op { ast::eq => lib::llvm::IntEQ, ast::ne => lib::llvm::IntNE, ast::lt => lib::llvm::IntSLT, @@ -945,7 +945,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, return ICmp(cx, cmp, lhs, rhs); } unsigned_int => { - let cmp = alt op { + let cmp = match op { ast::eq => lib::llvm::IntEQ, ast::ne => lib::llvm::IntNE, ast::lt => lib::llvm::IntULT, @@ -985,7 +985,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let fn_ty = variant.ctor_ty; let ccx = cx.ccx(); let mut cx = cx; - alt ty::get(fn_ty).struct { + match ty::get(fn_ty).struct { ty::ty_fn({inputs: args, _}) => { let mut j = 0u; let v_id = variant.id; @@ -1005,7 +1005,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, Typestate constraint that shows the unimpl case doesn't happen? */ let mut cx = cx; - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_rec(fields) => { for vec::eachi(fields) |i, fld| { let llfld_a = GEPi(cx, av, ~[0u, i]); @@ -1090,7 +1090,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, ti: @tydesc_info) { let _icx = ccx.insn_ctxt(~"lazily_emit_tydesc_glue"); if field == abi::tydesc_field_take_glue { - alt ti.take_glue { + match ti.take_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue TAKE %s", @@ -1105,7 +1105,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, } } } else if field == abi::tydesc_field_drop_glue { - alt ti.drop_glue { + match ti.drop_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue DROP %s", @@ -1120,7 +1120,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, } } } else if field == abi::tydesc_field_free_glue { - alt ti.free_glue { + match ti.free_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue FREE %s", @@ -1135,7 +1135,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, } } } else if field == abi::tydesc_field_visit_glue { - alt ti.visit_glue { + match ti.visit_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue VISIT %s", @@ -1159,7 +1159,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, if cx.unreachable { return; } let mut static_glue_fn = none; - alt static_ti { + match static_ti { none => {/* no-op */ } some(sti) => { lazily_emit_tydesc_glue(cx.ccx(), field, sti); @@ -1178,7 +1178,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, let llrawptr = PointerCast(cx, v, T_ptr(T_i8())); let llfn = { - alt static_glue_fn { + match static_glue_fn { none => { // Select out the glue function to call from the tydesc let llfnptr = GEPi(cx, tydesc, ~[0u, field]); @@ -1240,7 +1240,7 @@ fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { let _icx = bcx.insn_ctxt(~"drop_ty_immediate"); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) => { @@ -1257,7 +1257,7 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { let _icx = bcx.insn_ctxt(~"take_ty_immediate"); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) => { @@ -1291,7 +1291,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, // constant element of a tydesc works). let _icx = cx.insn_ctxt(~"call_memmove"); let ccx = cx.ccx(); - let key = alt ccx.sess.targ_cfg.arch { + let key = match ccx.sess.targ_cfg.arch { session::arch_x86 | session::arch_arm => ~"llvm.memmove.p0i8.p0i8.i32", session::arch_x86_64 => ~"llvm.memmove.p0i8.p0i8.i64" }; @@ -1320,7 +1320,7 @@ enum copy_action { INIT, DROP_EXISTING, } // These are the types that are passed by pointer. fn type_is_structural_or_param(t: ty::t) -> bool { if ty::type_is_structural(t) { return true; } - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_param(*) => return true, _ => return false } @@ -1446,7 +1446,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, un_expr: @ast::expr, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"trans_unary"); // Check for user-defined method call - alt bcx.ccx().maps.method_map.find(un_expr.id) { + match bcx.ccx().maps.method_map.find(un_expr.id) { some(mentry) => { let fty = node_id_type(bcx, un_expr.callee_id); return trans_call_inner( @@ -1461,7 +1461,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, if dest == ignore { return trans_expr(bcx, e, ignore); } let e_ty = expr_ty(bcx, e); - alt op { + match op { ast::not => { let {bcx, val} = trans_temp_expr(bcx, e); store_in_dest(bcx, Not(bcx, val), dest) @@ -1508,7 +1508,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, // Determine the operation we need. let llop = { - alt op { + match op { ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq), ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt), ast::le | ast::gt => C_u8(abi::cmp_glue_op_le), @@ -1519,7 +1519,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, let cmpval = call_cmp_glue(cx, lhs, rhs, rhs_t, llop); // Invert the result if necessary. - alt op { + match op { ast::eq | ast::lt | ast::le => rslt(cx, cmpval), ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)), _ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op") @@ -1571,7 +1571,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop, } else { ~"modulo zero" }; - let is_zero = alt ty::get(rhs_t).struct { + let is_zero = match ty::get(rhs_t).struct { ty::ty_int(t) => { let zero = C_integral(T_int_ty(cx.ccx(), t), 0u64, False); ICmp(cx, lib::llvm::IntEQ, rhs, zero) @@ -1607,7 +1607,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, let rhs = cast_shift_expr_rhs(cx, op, lhs, rhs); let mut cx = cx; - let val = alt op { + let val = match op { ast::add => { if is_float { FAdd(cx, lhs, rhs) } else { Add(cx, lhs, rhs) } @@ -1673,7 +1673,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, assert (lhs_res.kind == lv_owned); // A user-defined operator method - alt bcx.ccx().maps.method_map.find(ex.id) { + match bcx.ccx().maps.method_map.find(ex.id) { some(origin) => { let bcx = lhs_res.bcx; debug!{"user-defined method callee_id: %s", @@ -1738,14 +1738,14 @@ fn autoderef(cx: block, e_id: ast::node_id, // root the autoderef'd value, if necessary: derefs += 1u; - alt ccx.maps.root_map.find({id:e_id, derefs:derefs}) { + match ccx.maps.root_map.find({id:e_id, derefs:derefs}) { none => (), some(scope_id) => { root_value(cx, v1, t1, scope_id); } } - alt ty::get(t1).struct { + match ty::get(t1).struct { ty::ty_box(mt) => { let body = GEPi(cx, v1, ~[0u, abi::box_field_body]); t1 = mt.ty; @@ -1800,7 +1800,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, if past_lhs.unreachable { return past_lhs; } let join = sub_block(bcx, ~"join"), before_rhs = sub_block(bcx, ~"rhs"); - alt op { + match op { lazy_and => CondBr(past_lhs, lhs, before_rhs.llbb, join.llbb), lazy_or => CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb) } @@ -1821,7 +1821,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr, dest: dest, ex: @ast::expr) -> block { let _icx = bcx.insn_ctxt(~"trans_binary"); // User-defined operators - alt bcx.ccx().maps.method_map.find(ex.id) { + match bcx.ccx().maps.method_map.find(ex.id) { some(origin) => { let fty = node_id_type(bcx, ex.callee_id); return trans_call_inner( @@ -1836,7 +1836,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, } // First couple cases are lazy: - alt op { + match op { ast::and => { return trans_lazy_binop(bcx, lazy_and, lhs, rhs, dest); } @@ -1872,9 +1872,9 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, // because trans_expr will create another scope block // context for the block, but we've already got the // 'else' context - let else_bcx = alt els { + let else_bcx = match els { some(elexpr) => { - alt elexpr.node { + match elexpr.node { ast::expr_if(_, _, _) => { let elseif_blk = ast_util::block_from_expr(elexpr); trans_block(else_cx, elseif_blk, else_dest) @@ -1960,7 +1960,7 @@ fn lval_no_env(bcx: block, val: ValueRef, kind: lval_kind) fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) -> ValueRef { let name = csearch::get_symbol(ccx.sess.cstore, did); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_fn(_) => { let llty = type_of_fn_from_ty(ccx, t); return get_extern_fn(ccx.externs, ccx.llmod, name, @@ -1975,7 +1975,7 @@ fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { // FIXME[mono] could do this recursively. is that worthwhile? (#2529) - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_box(mt) => { some(ty::mk_opaque_box(tcx)) } @@ -2001,14 +2001,14 @@ fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], vtables: option<typeck::vtable_res>, param_uses: option<~[type_use::type_uses]>) -> mono_id { - let precise_param_ids = alt vtables { + let precise_param_ids = match vtables { some(vts) => { let bounds = ty::lookup_item_type(ccx.tcx, item).bounds; let mut i = 0u; vec::map2(*bounds, substs, |bounds, subst| { let mut v = ~[]; for vec::each(*bounds) |bound| { - alt bound { + match bound { ty::bound_trait(_) => { vec::push(v, impl::vtable_id(ccx, vts[i])); i += 1u; @@ -2023,10 +2023,10 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], vec::map(substs, |subst| mono_precise(subst, none)) } }; - let param_ids = alt param_uses { + let param_ids = match param_uses { some(uses) => { vec::map2(precise_param_ids, uses, |id, uses| { - alt check id { + match check id { mono_precise(_, some(_)) => id, mono_precise(subst, none) => { if uses == 0u { mono_any } @@ -2058,7 +2058,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let _icx = ccx.insn_ctxt(~"monomorphic_fn"); let mut must_cast = false; let substs = vec::map(real_substs, |t| { - alt normalize_for_monomorphization(ccx.tcx, t) { + match normalize_for_monomorphization(ccx.tcx, t) { some(t) => { must_cast = true; t } none => t } @@ -2069,7 +2069,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len()); let hash_id = make_mono_id(ccx, fn_id, substs, vtables, some(param_uses)); if vec::any(hash_id.params, - |p| alt p { mono_precise(_, _) => false, _ => true }) { + |p| match p { mono_precise(_, _) => false, _ => true }) { must_cast = true; } @@ -2079,7 +2079,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs.map(|s| ty_to_str(ccx.tcx, s)), substs.map(|s| ty_to_str(ccx.tcx, s)), hash_id]; - alt ccx.monomorphized.find(hash_id) { + match ccx.monomorphized.find(hash_id) { some(val) => { debug!{"leaving monomorphic fn %s", ty::item_path_str(ccx.tcx, fn_id)}; @@ -2096,7 +2096,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, (may have attempted to monomorphize an item defined in a different \ crate?)", fn_id}); // Get the path so that we can create a symbol - let (pt, name, span) = alt map_node { + let (pt, name, span) = match map_node { ast_map::node_item(i, pt) => (pt, i.ident, i.span), ast_map::node_variant(v, enm, pt) => (pt, v.node.name, enm.span), ast_map::node_method(m, _, pt) => (pt, m.ident, m.span), @@ -2149,7 +2149,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, }; let psubsts = some({tys: substs, vtables: vtables, bounds: tpt.bounds}); - let lldecl = alt map_node { + let lldecl = match map_node { ast_map::node_item(i@@{node: ast::item_fn(decl, _, body), _}, _) => { let d = mk_lldecl(); set_inline_hint_if_appr(i.attrs, d); @@ -2195,7 +2195,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, d } ast_map::node_dtor(_, dtor, _, pt) => { - let parent_id = alt ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, + let parent_id = match ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, dtor.node.self_id)) { some(did) => did, none => ccx.sess.span_bug(dtor.span, ~"Bad self ty in \ @@ -2231,7 +2231,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) -> ast::def_id { let _icx = ccx.insn_ctxt(~"maybe_instantiate_inline"); - alt ccx.external.find(fn_id) { + match ccx.external.find(fn_id) { some(some(node_id)) => { // Already inline debug!{"maybe_instantiate_inline(%s): already inline as node id %d", @@ -2240,7 +2240,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) } some(none) => fn_id, // Not inlinable none => { // Not seen yet - alt csearch::maybe_get_item_ast( + match csearch::maybe_get_item_ast( ccx.tcx, fn_id, |a,b,c,d| { astencode::decode_inlined_item(a, b, ccx.maps, c, d) @@ -2266,7 +2266,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) csearch::found_parent(parent_id, ast::ii_item(item)) => { ccx.external.insert(parent_id, some(item.id)); let mut my_id = 0; - alt check item.node { + match check item.node { ast::item_enum(_, _) => { let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id)); let vs_there = ty::enum_variants(ccx.tcx, parent_id); @@ -2350,9 +2350,9 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, ccx, node_id_type(bcx, id)))); } - alt ty::get(tpt.ty).struct { + match ty::get(tpt.ty).struct { ty::ty_fn(fn_ty) => { - alt fn_ty.purity { + match fn_ty.purity { ast::extern_fn => { // Extern functions are just opaque pointers let val = PointerCast(bcx, val, T_ptr(T_i8())); @@ -2369,7 +2369,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { let _icx = ccx.insn_ctxt(~"lookup_discriminant"); - alt ccx.discrims.find(vid) { + match ccx.discrims.find(vid) { none => { // It's an external discriminant that we haven't seen yet. assert (vid.crate != ast::local_crate); @@ -2394,13 +2394,13 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { let _icx = cx.insn_ctxt(~"trans_local_var"); fn take_local(table: hashmap<ast::node_id, local_val>, id: ast::node_id) -> local_var_result { - alt table.find(id) { + match table.find(id) { some(local_mem(v)) => {val: v, kind: lv_owned}, some(local_imm(v)) => {val: v, kind: lv_owned_imm}, r => fail(~"take_local: internal error") } } - alt def { + match def { ast::def_upvar(nid, _, _) => { assert (cx.fcx.llupvars.contains_key(nid)); return { val: cx.fcx.llupvars.get(nid), kind: lv_owned }; @@ -2414,7 +2414,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { return take_local(cx.fcx.lllocals, nid); } ast::def_self(sid) => { - let slf = alt copy cx.fcx.llself { + let slf = match copy cx.fcx.llself { some(s) => cast_self(cx, s), none => cx.sess().bug(~"trans_local_var: reference to self \ out of context") @@ -2431,7 +2431,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { fn trans_path(cx: block, id: ast::node_id) -> lval_maybe_callee { let _icx = cx.insn_ctxt(~"trans_path"); - alt cx.tcx().def_map.find(id) { + match cx.tcx().def_map.find(id) { none => cx.sess().bug(~"trans_path: unbound node ID"), some(df) => { return trans_var(cx, df, id); @@ -2442,7 +2442,7 @@ fn trans_path(cx: block, id: ast::node_id) fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { let _icx = cx.insn_ctxt(~"trans_var"); let ccx = cx.ccx(); - alt def { + match def { ast::def_fn(did, _) => { return lval_static_fn(cx, did, id); } @@ -2491,7 +2491,7 @@ fn trans_rec_field(bcx: block, base: @ast::expr, fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, field: ast::ident, sp: span) -> lval_result { let mut llderef = false; - let fields = alt ty::get(ty).struct { + let fields = match ty::get(ty).struct { ty::ty_rec(fs) => fs, ty::ty_class(did, substs) => { if option::is_some(ty::ty_dtor(bcx.tcx(), did)) { @@ -2583,12 +2583,12 @@ fn expr_is_lval(bcx: block, e: @ast::expr) -> bool { fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { let _icx = bcx.insn_ctxt(~"trans_callee"); - alt e.node { + match e.node { ast::expr_path(path) => return trans_path(bcx, e.id), ast::expr_field(base, _, _) => { // Lval means this is a record field, so not a method if !expr_is_lval(bcx, e) { - alt bcx.ccx().maps.method_map.find(e.id) { + match bcx.ccx().maps.method_map.find(e.id) { some(origin) => { // An impl method return impl::trans_method_callee(bcx, e.id, base, origin); } @@ -2609,7 +2609,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { // represented as an alloca or heap, hence needs a 'load' to be used as an // immediate). fn trans_lval(cx: block, e: @ast::expr) -> lval_result { - return alt cx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { + return match cx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { // No need to root this lvalue. none => unrooted(cx, e), @@ -2634,7 +2634,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { fn unrooted(cx: block, e: @ast::expr) -> lval_result { let _icx = cx.insn_ctxt(~"trans_lval"); - alt e.node { + match e.node { ast::expr_path(_) => { let v = trans_path(cx, e.id); return lval_maybe_callee_to_lval(v, e.span); @@ -2649,7 +2649,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { let ccx = cx.ccx(); let sub = trans_temp_expr(cx, base); let t = expr_ty(cx, base); - let val = alt check ty::get(t).struct { + let val = match check ty::get(t).struct { ty::ty_box(_) => { let non_gc_val = non_gc_box_cast(sub.bcx, sub.val); GEPi(sub.bcx, non_gc_val, ~[0u, abi::box_field_body]) @@ -2689,7 +2689,7 @@ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { } fn lval_maybe_callee_to_lval(c: lval_maybe_callee, sp: span) -> lval_result { - alt c.env { + match c.env { self_env(*) => { c.bcx.sess().span_bug(sp, ~"implicitly binding method call"); } @@ -2732,7 +2732,7 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, enum cast_kind { cast_pointer, cast_integral, cast_float, cast_enum, cast_other, } fn cast_type_kind(t: ty::t) -> cast_kind { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_float(*) => cast_float, ty::ty_ptr(*) => cast_pointer, ty::ty_rptr(*) => cast_pointer, @@ -2750,7 +2750,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let _icx = cx.insn_ctxt(~"trans_cast"); let ccx = cx.ccx(); let t_out = node_id_type(cx, id); - alt ty::get(t_out).struct { + match ty::get(t_out).struct { ty::ty_trait(_, _) => return impl::trans_cast(cx, e, id, dest), _ => () } @@ -2764,7 +2764,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let s_in = k_in == cast_integral && ty::type_is_signed(t_in); let newval = - alt {in: k_in, out: k_out} { + match {in: k_in, out: k_out} { {in: cast_integral, out: cast_integral} => { int_cast(e_res.bcx, ll_t_out, ll_t_in, e_res.val, s_in) } @@ -2797,7 +2797,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let av_enum = PointerCast(cx, e_res.val, llenumty); let lldiscrim_a_ptr = GEPi(cx, av_enum, ~[0u, 0u]); let lldiscrim_a = Load(cx, lldiscrim_a_ptr); - alt k_out { + match k_out { cast_integral => int_cast(e_res.bcx, ll_t_out, val_ty(lldiscrim_a), lldiscrim_a, true), @@ -2812,12 +2812,12 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, fn trans_loop_body(bcx: block, e: @ast::expr, ret_flag: option<ValueRef>, dest: dest) -> block { - alt check e.node { + match check e.node { ast::expr_loop_body(b@@{ node: ast::expr_fn_block(decl, body, cap), _ }) => { - alt check ty::get(expr_ty(bcx, e)).struct { + match check ty::get(expr_ty(bcx, e)).struct { ty::ty_fn({proto, _}) => { closure::trans_expr_fn(bcx, proto, decl, body, b.id, cap, some(ret_flag), @@ -2841,9 +2841,9 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, let is_bot = ty::type_is_bot(e_ty); // translate the arg expr as an lvalue - let lv = alt ret_flag { + let lv = match ret_flag { // If there is a ret_flag, this *must* be a loop body - some(ptr) => alt check e.node { + some(ptr) => match check e.node { ast::expr_loop_body(blk) => { let scratch = alloc_ty(cx, expr_ty(cx, blk)); let bcx = trans_loop_body(cx, e, ret_flag, save_in(scratch)); @@ -2884,7 +2884,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, // to have type lldestty (the callee's expected type). val = llvm::LLVMGetUndef(lldestty); } else { - alt arg_mode { + match arg_mode { ast::by_ref | ast::by_mutbl_ref => { // Ensure that the value is spilled into memory: if lv.kind != lv_owned && ty::type_is_immediate(e_ty) { @@ -2949,7 +2949,7 @@ fn adapt_borrowed_value(lv: lval_result, return {lv:lv, ty:e_ty}; } - alt ty::get(e_ty).struct { + match ty::get(e_ty).struct { ty::ty_uniq(mt) | ty::ty_box(mt) => { let box_ptr = load_value_from_lval_result(lv, e_ty); let body_ptr = GEPi(bcx, box_ptr, ~[0u, abi::box_field_body]); @@ -2959,7 +2959,7 @@ fn adapt_borrowed_value(lv: lval_result, ty::ty_estr(_) | ty::ty_evec(_, _) => { let ccx = bcx.ccx(); - let val = alt lv.kind { + let val = match lv.kind { lv_temporary => lv.val, lv_owned => load_if_immediate(bcx, lv.val, e_ty), lv_owned_imm => lv.val @@ -3019,7 +3019,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, let retty = ty::ty_fn_ret(fn_ty); // Arg 0: Output pointer. - let llretslot = alt dest { + let llretslot = match dest { ignore => { if ty::type_is_nil(retty) { llvm::LLVMGetUndef(T_ptr(T_nil())) @@ -3039,7 +3039,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, // First we figure out the caller's view of the types of the arguments. // This will be needed if this is a generic call, because the callee has // to cast her view of the arguments to the caller's view. - alt args { + match args { arg_exprs(es) => { let llarg_tys = type_of_explicit_args(ccx, arg_tys); let last = es.len() - 1u; @@ -3083,7 +3083,7 @@ fn body_contains_ret(body: ast::blk) -> bool { visit_item: |_i, _cx, _v| { }, visit_expr: |e: @ast::expr, cx: {mut found: bool}, v| { if !cx.found { - alt e.node { + match e.node { ast::expr_ret(_) => cx.found = true, _ => visit::visit_expr(e, cx, v), } @@ -3104,9 +3104,9 @@ fn trans_call_inner( dest: dest) -> block { do with_scope(in_cx, call_info, ~"call") |cx| { - let ret_in_loop = alt args { + let ret_in_loop = match args { arg_exprs(args) => { - args.len() > 0u && alt vec::last(args).node { + args.len() > 0u && match vec::last(args).node { ast::expr_loop_body(@{ node: ast::expr_fn_block(_, body, _), _ @@ -3127,7 +3127,7 @@ fn trans_call_inner( } else { none }; let mut faddr = f_res.val; - let llenv = alt f_res.env { + let llenv = match f_res.env { null_env => { llvm::LLVMGetUndef(T_opaque_box_ptr(ccx)) } @@ -3160,7 +3160,7 @@ fn trans_call_inner( type _|_. Since that means it diverges, the code for the call itself is unreachable. */ bcx = invoke(bcx, faddr, llargs); - alt dest { + match dest { ignore => { if llvm::LLVMIsUndef(llretslot) != lib::llvm::True { bcx = drop_ty(bcx, llretslot, ret_ty); @@ -3220,10 +3220,10 @@ fn need_invoke(bcx: block) -> bool { // Walk the scopes to look for cleanups let mut cur = bcx; loop { - alt cur.kind { + match cur.kind { block_scope(inf) => { for vec::each(inf.cleanups) |cleanup| { - alt cleanup { + match cleanup { clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => { if cleanup_type == normal_exit_and_unwind { return true; @@ -3234,7 +3234,7 @@ fn need_invoke(bcx: block) -> bool { } _ => () } - cur = alt cur.parent { + cur = match cur.parent { some(next) => next, none => return false } @@ -3244,7 +3244,7 @@ fn need_invoke(bcx: block) -> bool { fn have_cached_lpad(bcx: block) -> bool { let mut res = false; do in_lpad_scope_cx(bcx) |inf| { - alt inf.landing_pad { + match inf.landing_pad { some(_) => res = true, none => res = false } @@ -3255,7 +3255,7 @@ fn have_cached_lpad(bcx: block) -> bool { fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) { let mut bcx = bcx; loop { - alt bcx.kind { + match bcx.kind { block_scope(inf) => { if inf.cleanups.len() > 0u || is_none(bcx.parent) { f(inf); return; @@ -3273,7 +3273,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below do in_lpad_scope_cx(bcx) |inf| { // If there is a valid landing pad still around, use it - alt copy inf.landing_pad { + match copy inf.landing_pad { some(target) => cached = some(target), none => { pad_bcx = lpad_block(bcx, ~"unwind"); @@ -3282,7 +3282,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { } } // Can't return from block above - alt cached { some(b) => return b, none => () } + match cached { some(b) => return b, none => () } // The landing pad return type (the type being propagated). Not sure what // this represents but it's determined by the personality function and // this is what the EH proposal example uses. @@ -3303,7 +3303,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { // We store the retval in a function-central alloca, so that calls to // Resume can find it. - alt copy bcx.fcx.personality { + match copy bcx.fcx.personality { some(addr) => Store(pad_bcx, llretval, addr), none => { let addr = alloca(pad_bcx, val_ty(llretval)); @@ -3320,7 +3320,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { let _icx = bcx.insn_ctxt(~"trans_tup"); let mut bcx = bcx; - let addr = alt dest { + let addr = match dest { ignore => { for vec::each(elts) |ex| { bcx = trans_expr(bcx, ex, ignore); } return bcx; @@ -3346,7 +3346,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], let _icx = bcx.insn_ctxt(~"trans_rec"); let t = node_id_type(bcx, id); let mut bcx = bcx; - let addr = alt check dest { + let addr = match check dest { ignore => { for vec::each(fields) |fld| { bcx = trans_expr(bcx, fld.node.expr, ignore); @@ -3356,7 +3356,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], save_in(pos) => pos }; - let ty_fields = alt check ty::get(t).struct { ty::ty_rec(f) => f }; + let ty_fields = match check ty::get(t).struct { ty::ty_rec(f) => f }; let mut temp_cleanups = ~[]; for fields.each |fld| { @@ -3368,7 +3368,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], add_clean_temp_mem(bcx, dst, ty_fields[ix].mt.ty); vec::push(temp_cleanups, dst); } - alt base { + match base { some(bexp) => { let {bcx: cx, val: base_val} = trans_temp_expr(bcx, bexp); bcx = cx; @@ -3404,7 +3404,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], // Get the address to store the structure into. If there is no address, // just translate each field and be done with it. let dest_address; - alt dest { + match dest { ignore => { for fields.each |field| { block_context = trans_expr(block_context, @@ -3423,7 +3423,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], // Get the class ID and its fields. let class_fields, class_id, substitutions; - alt ty::get(struct_type).struct { + match ty::get(struct_type).struct { ty::ty_class(existing_class_id, existing_substitutions) => { class_id = existing_class_id; substitutions = existing_substitutions; @@ -3458,7 +3458,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], } let index, field_id; - alt found { + match found { some((found_index, found_field_id)) => { index = found_index; field_id = found_field_id; @@ -3571,7 +3571,7 @@ fn trans_temp_expr(bcx: block, e: @ast::expr) -> result { } fn load_value_from_lval_result(lv: lval_result, ty: ty::t) -> ValueRef { - alt lv.kind { + match lv.kind { lv_temporary => lv.val, lv_owned => load_if_immediate(lv.bcx, lv.val, ty), lv_owned_imm => lv.val @@ -3606,12 +3606,12 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id, fn find_bcx_for_scope(bcx: block, scope_id: ast::node_id) -> block { let mut bcx_sid = bcx; loop { - bcx_sid = alt bcx_sid.node_info { + bcx_sid = match bcx_sid.node_info { some({id, _}) if id == scope_id => { return bcx_sid } _ => { - alt bcx_sid.parent { + match bcx_sid.parent { none => bcx.tcx().sess.bug( fmt!{"no enclosing scope with id %d", scope_id}), some(bcx_par) => bcx_par @@ -3634,7 +3634,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { return lval_to_dps(bcx, e, dest); } - return alt bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { + return match bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { none => unrooted(bcx, e, dest), some(scope_id) => { debug!{"expression %d found in root map with scope %d", @@ -3658,7 +3658,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block { let tcx = bcx.tcx(); - alt e.node { + match e.node { ast::expr_if(cond, thn, els) => { return trans_if(bcx, cond, thn, els, dest); } @@ -3703,7 +3703,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { cap_clause, none, dest); } ast::expr_fn_block(decl, body, cap_clause) => { - alt check ty::get(expr_ty(bcx, e)).struct { + match check ty::get(expr_ty(bcx, e)).struct { ty::ty_fn({proto, _}) => { debug!{"translating fn_block %s with type %s", expr_to_str(e), @@ -3841,7 +3841,7 @@ fn lval_result_to_dps(lv: lval_result, ty: ty::t, last_use: bool, dest: dest) -> block { let mut {bcx, val, kind} = lv; let ccx = bcx.ccx(); - alt dest { + match dest { by_val(cell) => { if kind == lv_temporary { revoke_clean(bcx, val); @@ -3909,7 +3909,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, let modpath = vec::append( ~[path_mod(ccx.link_meta.name)], vec::filter(bcx.fcx.path, |e| - alt e { path_mod(_) => true, _ => false } + match e { path_mod(_) => true, _ => false } )); let modname = path_str(modpath); @@ -3967,7 +3967,7 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>, fail_expr: option<@ast::expr>) -> block { let _icx = bcx.insn_ctxt(~"trans_fail_expr"); let mut bcx = bcx; - alt fail_expr { + match fail_expr { some(expr) => { let ccx = bcx.ccx(), tcx = ccx.tcx; let expr_res = trans_temp_expr(bcx, expr); @@ -3995,7 +3995,7 @@ fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: ~str) { let _icx = bcx.insn_ctxt(~"trans_trace"); add_comment(bcx, trace_str); let V_trace_str = C_cstr(bcx.ccx(), trace_str); - let {V_filename, V_line} = alt sp_opt { + let {V_filename, V_line} = match sp_opt { some(sp) => { let sess = bcx.sess(); let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo); @@ -4025,7 +4025,7 @@ fn trans_fail_value(bcx: block, sp_opt: option<span>, V_fail_str: ValueRef) -> block { let _icx = bcx.insn_ctxt(~"trans_fail_value"); let ccx = bcx.ccx(); - let {V_filename, V_line} = alt sp_opt { + let {V_filename, V_line} = match sp_opt { some(sp) => { let sess = bcx.sess(); let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo); @@ -4067,7 +4067,7 @@ fn trans_break_cont(bcx: block, to_end: bool) let mut unwind = bcx; let mut target; loop { - alt unwind.kind { + match unwind.kind { block_scope({loop_break: some(brk), _}) => { target = if to_end { brk @@ -4078,7 +4078,7 @@ fn trans_break_cont(bcx: block, to_end: bool) } _ => () } - unwind = alt unwind.parent { + unwind = match unwind.parent { some(cx) => cx, // This is a return from a loop body block none => { @@ -4105,14 +4105,14 @@ fn trans_cont(cx: block) -> block { fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { let _icx = bcx.insn_ctxt(~"trans_ret"); let mut bcx = bcx; - let retptr = alt copy bcx.fcx.loop_ret { + let retptr = match copy bcx.fcx.loop_ret { some({flagptr, retptr}) => { // This is a loop body return. Must set continue flag (our retptr) // to false, return flag to true, and then store the value in the // parent's retptr. Store(bcx, C_bool(true), flagptr); Store(bcx, C_bool(false), bcx.fcx.llretptr); - alt e { + match e { some(x) => PointerCast(bcx, retptr, T_ptr(type_of(bcx.ccx(), expr_ty(bcx, x)))), none => retptr @@ -4120,7 +4120,7 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { } none => bcx.fcx.llretptr }; - alt e { + match e { some(x) => { bcx = trans_expr_save_in(bcx, x, retptr); } @@ -4139,7 +4139,7 @@ fn build_return(bcx: block) { fn init_local(bcx: block, local: @ast::local) -> block { let _icx = bcx.insn_ctxt(~"init_local"); let ty = node_id_type(bcx, local.node.id); - let llptr = alt bcx.fcx.lllocals.find(local.node.id) { + let llptr = match bcx.fcx.lllocals.find(local.node.id) { some(local_mem(v)) => v, _ => { bcx.tcx().sess.span_bug(local.span, ~"init_local: Someone forgot to document why it's\ @@ -4148,7 +4148,7 @@ fn init_local(bcx: block, local: @ast::local) -> block { }; let mut bcx = bcx; - alt local.node.init { + match local.node.init { some(init) => { if init.op == ast::init_assign || !expr_is_lval(bcx, init.expr) { bcx = trans_expr_save_in(bcx, init.expr, llptr); @@ -4175,12 +4175,12 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { let mut bcx = cx; debuginfo::update_source_pos(cx, s.span); - alt s.node { + match s.node { ast::stmt_expr(e, _) | ast::stmt_semi(e, _) => { bcx = trans_expr(cx, e, ignore); } ast::stmt_decl(d, _) => { - alt d.node { + match d.node { ast::decl_local(locals) => { for vec::each(locals) |local| { bcx = init_local(bcx, local); @@ -4275,11 +4275,11 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> let _icx = bcx.insn_ctxt(~"trans_block_cleanups"); if bcx.unreachable { return bcx; } let mut bcx = bcx; - alt check cleanup_cx.kind { + match check cleanup_cx.kind { block_scope({cleanups, _}) => { let cleanups = copy cleanups; do vec::riter(cleanups) |cu| { - alt cu { + match cu { clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => { // Some types don't need to be cleaned up during // landing pads because they can be freed en mass later @@ -4311,7 +4311,7 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, fmt!{"cleanup_and_leave(%s)", cur.to_str()}); } - alt cur.kind { + match cur.kind { block_scope(inf) if inf.cleanups.len() > 0u => { for vec::find(inf.cleanup_paths, |cp| cp.target == leave).each |cp| { @@ -4325,16 +4325,16 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, } _ => () } - alt upto { + match upto { some(bb) => { if cur.llbb == bb { break; } } _ => () } - cur = alt cur.parent { + cur = match cur.parent { some(next) => next, none => { assert is_none(upto); break; } }; } - alt leave { + match leave { some(target) => Br(bcx, target), none => { Resume(bcx, Load(bcx, option::get(bcx.fcx.personality))); } } @@ -4383,9 +4383,9 @@ fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block { fn block_locals(b: ast::blk, it: fn(@ast::local)) { for vec::each(b.node.stmts) |s| { - alt s.node { + match s.node { ast::stmt_decl(d, _) => { - alt d.node { + match d.node { ast::decl_local(locals) => { for vec::each(locals) |local| { it(local); } } @@ -4410,7 +4410,7 @@ fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { fn alloc_local(cx: block, local: @ast::local) -> block { let _icx = cx.insn_ctxt(~"alloc_local"); let t = node_id_type(cx, local.node.id); - let simple_name = alt local.node.pat.node { + let simple_name = match local.node.pat.node { ast::pat_ident(_, pth, none) => some(path_to_ident(pth)), _ => none }; @@ -4435,7 +4435,7 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest) debuginfo::update_source_pos(bcx, b.span); bcx = trans_stmt(bcx, *s); } - alt b.node.expr { + match b.node.expr { some(e) => { let bt = ty::type_is_bot(expr_ty(bcx, e)); debuginfo::update_source_pos(bcx, e.span); @@ -4513,7 +4513,7 @@ fn create_llargs_for_fn_args(cx: fn_ctxt, let _icx = cx.insn_ctxt(~"create_llargs_for_fn_args"); // Skip the implicit arguments 0, and 1. let mut arg_n = first_real_arg; - alt ty_self { + match ty_self { impl_self(tt) => { cx.llself = some({v: cx.llenv, t: tt}); } @@ -4544,11 +4544,11 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], }; for vec::each(arg_tys) |arg| { let id = args[arg_n].id; - let argval = alt fcx.llargs.get(id) { + let argval = match fcx.llargs.get(id) { local_mem(v) => v, _ => epic_fail() }; - alt ty::resolved_mode(tcx, arg.mode) { + match ty::resolved_mode(tcx, arg.mode) { ast::by_mutbl_ref => (), ast::by_move | ast::by_copy => add_clean(bcx, argval, arg.ty), ast::by_val => { @@ -4682,7 +4682,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, param_substs, none); create_llargs_for_fn_args(fcx, no_self, fn_args); - let ty_param_substs = alt param_substs { + let ty_param_substs = match param_substs { some(substs) => substs.tys, none => ~[] }; @@ -4708,7 +4708,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, // If this argument to this function is a enum, it'll have come in to // this function as an opaque blob due to the way that type_of() // works. So we have to cast to the destination's view of the type. - let llarg = alt check fcx.llargs.find(va.id) { + let llarg = match check fcx.llargs.find(va.id) { some(local_mem(x)) => x }; let arg_ty = arg_tys[i].ty; @@ -4824,10 +4824,10 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path, fn trans_item(ccx: @crate_ctxt, item: ast::item) { let _icx = ccx.insn_ctxt(~"trans_item"); - let path = alt check ccx.tcx.items.get(item.id) { + let path = match check ccx.tcx.items.get(item.id) { ast_map::node_item(_, p) => p }; - alt item.node { + match item.node { ast::item_fn(decl, tps, body) => { if decl.purity == ast::extern_fn { let llfndecl = get_item_val(ccx, item.id); @@ -4843,7 +4843,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { decl, body, llfndecl, no_self, none, item.id); } else { for vec::each(body.node.stmts) |stmt| { - alt stmt.node { + match stmt.node { ast::stmt_decl(@{node: ast::decl_item(i), _}, _) => { trans_item(ccx, *i); } @@ -4876,7 +4876,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { } ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id), ast::item_foreign_mod(foreign_mod) => { - let abi = alt attr::foreign_abi(item.attrs) { + let abi = match attr::foreign_abi(item.attrs) { either::right(abi_) => abi_, either::left(msg) => ccx.sess.span_fatal(item.span, msg) }; @@ -4961,7 +4961,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, let main_takes_argv = // invariant! - alt ty::get(main_node_type).struct { + match ty::get(main_node_type).struct { ty::ty_fn({inputs, _}) => inputs.len() != 0u, _ => ccx.sess.span_fatal(sp, ~"main has a non-function type") }; @@ -5050,7 +5050,7 @@ fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef, fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { vec::append( - *alt check ccx.tcx.items.get(i.id) { + *match check ccx.tcx.items.get(i.id) { ast_map::node_item(_, p) => p }, ~[path_name(i.ident)]) @@ -5061,7 +5061,7 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, substs: option<param_substs>) -> ~str { let t = ty::node_id_to_type(ccx.tcx, id); - alt ccx.item_symbols.find(id) { + match ccx.item_symbols.find(id) { some(s) => s, none if is_none(substs) => { let s = mangle_exported_name( @@ -5074,7 +5074,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, none => { // Monomorphizing, so just make a symbol, don't add // this to item_symbols - alt substs { + match substs { some(ss) => { let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, t); mangle_exported_name( @@ -5094,14 +5094,14 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { let tcx = ccx.tcx; - alt ccx.item_vals.find(id) { + match ccx.item_vals.find(id) { some(v) => v, none => { let mut exprt = false; - let val = alt check ccx.tcx.items.get(id) { + let val = match check ccx.tcx.items.get(id) { ast_map::node_item(i, pth) => { let my_path = vec::append(*pth, ~[path_name(i.ident)]); - alt check i.node { + match check i.node { ast::item_const(_, _) => { let typ = ty::node_id_to_type(ccx.tcx, i.id); let s = mangle_exported_name(ccx, my_path, typ); @@ -5167,7 +5167,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { let pth = vec::append(*pth, ~[path_name(enm.ident), path_name(v.node.name)]); - let llfn = alt check enm.node { + let llfn = match check enm.node { ast::item_enum(_, _) => { register_fn(ccx, v.span, pth, id) } @@ -5188,7 +5188,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { // The constant translation pass. fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { let _icx = ccx.insn_ctxt(~"trans_constant"); - alt it.node { + match it.node { ast::item_enum(variants, _) => { let vi = ty::enum_variants(ccx.tcx, {crate: ast::local_crate, node: it.id}); @@ -5294,7 +5294,7 @@ fn declare_dbg_intrinsics(llmod: ModuleRef, fn trap(bcx: block) { let v: ~[ValueRef] = ~[]; - alt bcx.ccx().intrinsics.find(~"llvm.trap") { + match bcx.ccx().intrinsics.find(~"llvm.trap") { some(x) => { Call(bcx, x, v); }, _ => bcx.sess().bug(~"unbound llvm.trap in trap") } @@ -5309,12 +5309,12 @@ fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) { fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{ - visit_item: |item| alt item.node { + visit_item: |item| match item.node { ast::item_fn(decl, _, _) => { let attr_metas = attr::attr_metas( attr::find_attrs_by_name(item.attrs, ~"rt")); do vec::iter(attr_metas) |attr_meta| { - alt attr::get_meta_item_list(attr_meta) { + match attr::get_meta_item_list(attr_meta) { some(list) => { let name = *attr::get_meta_item_name(vec::head(list)); push_rtcall(ccx, name, {crate: ast::local_crate, @@ -5334,9 +5334,9 @@ fn gather_external_rtcalls(ccx: @crate_ctxt) { do cstore::iter_crate_data(ccx.sess.cstore) |_cnum, cmeta| { do decoder::each_path(cmeta) |path| { let pathname = path.path_string; - alt path.def_like { + match path.def_like { decoder::dl_def(d) => { - alt d { + match d { ast::def_fn(did, _) => { // FIXME (#2861): This should really iterate attributes // like gather_local_rtcalls, but we'll need to @@ -5462,7 +5462,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) for cx.exp_map.each |exp_id, defs| { for defs.each |def| { if !def.reexp { again; } - let path = alt check cx.tcx.items.get(exp_id) { + let path = match check cx.tcx.items.get(exp_id) { ast_map::node_export(_, path) => { ast_map::path_to_str(*path) } diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 6e7c41e0fa9..d6083a3c564 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -49,7 +49,7 @@ fn count_insn(cx: block, category: ~str) { s += ~"/"; s += category; - let n = alt h.find(s) { + let n = match h.find(s) { some(n) => n, _ => 0u }; diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 1912c509693..752ce97427c 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -101,7 +101,7 @@ enum environment_value { } fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str { - alt ev { + match ev { env_copy(v, t, lk) => fmt!{"copy(%s,%s)", val_str(ccx.tn, v), ty_to_str(ccx.tcx, t)}, env_move(v, t, lk) => fmt!{"move(%s,%s)", val_str(ccx.tn, v), @@ -124,7 +124,7 @@ fn mk_closure_tys(tcx: ty::ctxt, // Compute the closed over data for vec::each(bound_values) |bv| { - vec::push(bound_tys, alt bv { + vec::push(bound_tys, match bv { env_copy(_, t, _) => t, env_move(_, t, _) => t, env_ref(_, t, _) => t @@ -153,7 +153,7 @@ fn allocate_cbox(bcx: block, } // Allocate and initialize the box: - let {bcx, val} = alt ck { + let {bcx, val} = match ck { ty::ck_box => malloc_raw(bcx, cdata_ty, heap_shared), ty::ck_uniq => malloc_raw(bcx, cdata_ty, heap_exchange), ty::ck_block => { @@ -211,7 +211,7 @@ fn store_environment(bcx: block, let bound_data = GEPi(bcx, llbox, ~[0u, abi::box_field_body, i]); - alt bv { + match bv { env_copy(val, ty, lv_owned) => { let val1 = load_if_immediate(bcx, val, ty); bcx = base::copy_val(bcx, INIT, bound_data, val1, ty); @@ -267,14 +267,14 @@ fn build_closure(bcx0: block, debug!{"Node id is %s", syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)}; let mut ty = node_id_type(bcx, nid); - alt cap_var.mode { + match cap_var.mode { capture::cap_ref => { assert ck == ty::ck_block; ty = ty::mk_mut_ptr(tcx, ty); vec::push(env_vals, env_ref(lv.val, ty, lv.kind)); } capture::cap_copy => { - let mv = alt check ccx.maps.last_use_map.find(id) { + let mv = match check ccx.maps.last_use_map.find(id) { none => false, some(vars) => (*vars).contains(nid) }; @@ -292,7 +292,7 @@ fn build_closure(bcx0: block, } } do option::iter(include_ret_handle) |flagptr| { - let our_ret = alt bcx.fcx.loop_ret { + let our_ret = match bcx.fcx.loop_ret { some({retptr, _}) => retptr, none => bcx.fcx.llretptr }; @@ -323,12 +323,12 @@ fn load_environment(fcx: fn_ctxt, // Populate the upvars from the environment. let mut i = 0u; do vec::iter(cap_vars) |cap_var| { - alt cap_var.mode { + match cap_var.mode { capture::cap_drop => { /* ignore */ } _ => { let mut upvarptr = GEPi(bcx, llcdata, ~[0u, i]); - alt ck { + match ck { ty::ck_block => { upvarptr = Load(bcx, upvarptr); } ty::ck_uniq | ty::ck_box => () } @@ -368,7 +368,7 @@ fn trans_expr_fn(bcx: block, let trans_closure_env = fn@(ck: ty::closure_kind) -> result { let cap_vars = capture::compute_capture_vars( ccx.tcx, id, proto, cap_clause); - let ret_handle = alt is_loop_body { some(x) => x, none => none }; + let ret_handle = match is_loop_body { some(x) => x, none => none }; let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id, ret_handle); trans_closure(ccx, sub_path, decl, body, llfn, no_self, @@ -383,7 +383,7 @@ fn trans_expr_fn(bcx: block, {bcx: bcx, val: llbox} }; - let {bcx: bcx, val: closure} = alt proto { + let {bcx: bcx, val: closure} = match proto { ast::proto_block => trans_closure_env(ty::ck_block), ast::proto_box => trans_closure_env(ty::ck_box), ast::proto_uniq => trans_closure_env(ty::ck_uniq), @@ -417,7 +417,7 @@ fn make_fn_glue( } }; - return alt ty::get(t).struct { + return match ty::get(t).struct { ty::ty_fn({proto: ast::proto_bare, _}) | ty::ty_fn({proto: ast::proto_block, _}) => bcx, ty::ty_fn({proto: ast::proto_uniq, _}) => fn_env(ty::ck_uniq), @@ -433,7 +433,7 @@ fn make_opaque_cbox_take_glue( -> block { // Easy cases: let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue"); - alt ck { + match ck { ty::ck_block => return bcx, ty::ck_box => { incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); @@ -485,7 +485,7 @@ fn make_opaque_cbox_drop_glue( cboxptr: ValueRef) // ptr to the opaque closure -> block { let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_drop_glue"); - alt ck { + match ck { ty::ck_block => bcx, ty::ck_box => { decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr), @@ -504,7 +504,7 @@ fn make_opaque_cbox_free_glue( cbox: ValueRef) // ptr to the opaque closure -> block { let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue"); - alt ck { + match ck { ty::ck_block => return bcx, ty::ck_box | ty::ck_uniq => { /* hard cases: */ } } @@ -524,7 +524,7 @@ fn make_opaque_cbox_free_glue( abi::tydesc_field_drop_glue, none); // Free the ty descr (if necc) and the box itself - alt ck { + match ck { ty::ck_block => fail ~"Impossible", ty::ck_box => trans_free(bcx, cbox), ty::ck_uniq => trans_unique_free(bcx, cbox) diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 99fd0c8b7bc..7e48297f12e 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -292,7 +292,7 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) { } } fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) { - let free_fn = alt heap { + let free_fn = match heap { heap_shared => |a| base::trans_free(a, ptr), heap_exchange => |a| base::trans_unique_free(a, ptr) }; @@ -310,7 +310,7 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) { fn revoke_clean(cx: block, val: ValueRef) { do in_scope_cx(cx) |info| { do option::iter(vec::position(info.cleanups, |cu| { - alt cu { + match cu { clean_temp(v, _, _) if v == val => true, _ => false } @@ -453,7 +453,7 @@ fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { fn in_scope_cx(cx: block, f: fn(scope_info)) { let mut cur = cx; loop { - alt cur.kind { + match cur.kind { block_scope(inf) => { f(inf); return; } _ => () } @@ -462,7 +462,7 @@ fn in_scope_cx(cx: block, f: fn(scope_info)) { } fn block_parent(cx: block) -> block { - alt cx.parent { + match cx.parent { some(b) => b, none => cx.sess().bug(fmt!{"block_parent called on root block %?", cx}) @@ -483,7 +483,7 @@ impl bcx_cxs for block { ty_to_str(self.tcx(), t) } fn to_str() -> ~str { - alt self.node_info { + match self.node_info { some(node_info) => { fmt!{"[block %d]", node_info.id} } @@ -535,7 +535,7 @@ fn T_f64() -> TypeRef { return llvm::LLVMDoubleType(); } fn T_bool() -> TypeRef { return T_i1(); } fn T_int(targ_cfg: @session::config) -> TypeRef { - return alt targ_cfg.arch { + return match targ_cfg.arch { session::arch_x86 => T_i32(), session::arch_x86_64 => T_i64(), session::arch_arm => T_i32() @@ -543,7 +543,7 @@ fn T_int(targ_cfg: @session::config) -> TypeRef { } fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef { - alt t { + match t { ast::ty_i => cx.int_type, ast::ty_char => T_char(), ast::ty_i8 => T_i8(), @@ -554,7 +554,7 @@ fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef { } fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef { - alt t { + match t { ast::ty_u => cx.int_type, ast::ty_u8 => T_i8(), ast::ty_u16 => T_i16(), @@ -564,7 +564,7 @@ fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef { } fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef { - alt t { + match t { ast::ty_f => cx.float_type, ast::ty_f32 => T_f32(), ast::ty_f64 => T_f64() @@ -572,7 +572,7 @@ fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef { } fn T_float(targ_cfg: @session::config) -> TypeRef { - return alt targ_cfg.arch { + return match targ_cfg.arch { session::arch_x86 => T_f64(), session::arch_x86_64 => T_f64(), session::arch_arm => T_f64() @@ -657,7 +657,7 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { let s = ~"glue_fn"; - alt name_has_type(cx.tn, s) { + match name_has_type(cx.tn, s) { some(t) => return t, _ => () } @@ -764,7 +764,7 @@ fn T_taskptr(cx: @crate_ctxt) -> TypeRef { return T_ptr(cx.task_type); } // This type must never be used directly; it must always be cast away. fn T_typaram(tn: type_names) -> TypeRef { let s = ~"typaram"; - alt name_has_type(tn, s) { + match name_has_type(tn, s) { some(t) => return t, _ => () } @@ -787,7 +787,7 @@ fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef { fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef { let s = ~"opaque_enum"; - alt name_has_type(cx.tn, s) { + match name_has_type(cx.tn, s) { some(t) => return t, _ => () } @@ -856,7 +856,7 @@ fn C_u8(i: uint) -> ValueRef { return C_integral(T_i8(), i as u64, False); } // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { - alt cx.const_cstr_cache.find(s) { + match cx.const_cstr_cache.find(s) { some(llval) => return llval, none => () } @@ -942,7 +942,7 @@ type mono_id = @{def: ast::def_id, params: ~[mono_param_id]}; pure fn hash_mono_id(mi: &mono_id) -> uint { let mut h = syntax::ast_util::hash_def(&mi.def); for vec::each(mi.params) |param| { - h = h * alt param { + h = h * match param { mono_precise(ty, vts) => { let mut h = ty::type_id(ty); do option::iter(vts) |vts| { @@ -978,7 +978,7 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef { fn path_str(p: path) -> ~str { let mut r = ~"", first = true; for vec::each(p) |e| { - alt e { ast_map::path_name(s) | ast_map::path_mod(s) => { + match e { ast_map::path_name(s) | ast_map::path_mod(s) => { if first { first = false; } else { r += ~"::"; } r += *s; @@ -990,7 +990,7 @@ fn path_str(p: path) -> ~str { fn node_id_type(bcx: block, id: ast::node_id) -> ty::t { let tcx = bcx.tcx(); let t = ty::node_id_to_type(tcx, id); - alt bcx.fcx.param_substs { + match bcx.fcx.param_substs { some(substs) => ty::subst_tps(tcx, substs.tys, t), _ => { assert !ty::type_has_params(t); t } } @@ -1001,7 +1001,7 @@ fn expr_ty(bcx: block, ex: @ast::expr) -> ty::t { fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { let tcx = bcx.tcx(); let params = ty::node_id_to_type_params(tcx, id); - alt bcx.fcx.param_substs { + match bcx.fcx.param_substs { some(substs) => { vec::map(params, |t| ty::subst_tps(tcx, substs.tys, t)) } @@ -1012,7 +1012,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident, fields: ~[ty::field]) -> uint { - alt ty::field_idx(ident, fields) { + match ty::field_idx(ident, fields) { none => cx.sess.span_bug( sp, fmt!{"base expr doesn't appear to \ have a field named %s", *ident}), diff --git a/src/rustc/middle/trans/consts.rs b/src/rustc/middle/trans/consts.rs index d0a448da5b2..49ea20c6e85 100644 --- a/src/rustc/middle/trans/consts.rs +++ b/src/rustc/middle/trans/consts.rs @@ -5,12 +5,12 @@ import base::get_insn_ctxt; fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) -> ValueRef { let _icx = cx.insn_ctxt(~"trans_lit"); - alt lit.node { + match lit.node { ast::lit_int(i, t) => C_integral(T_int_ty(cx, t), i as u64, True), ast::lit_uint(u, t) => C_integral(T_uint_ty(cx, t), u, False), ast::lit_int_unsuffixed(i) => { let lit_int_ty = ty::node_id_to_type(cx.tcx, e.id); - alt ty::get(lit_int_ty).struct { + match ty::get(lit_int_ty).struct { ty::ty_int(t) => { C_integral(T_int_ty(cx, t), i as u64, True) } @@ -45,7 +45,7 @@ fn const_vec_and_sz(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr]) fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let _icx = cx.insn_ctxt(~"const_expr"); - alt e.node { + match e.node { ast::expr_lit(lit) => consts::const_lit(cx, e, *lit), ast::expr_binary(b, e1, e2) => { let te1 = const_expr(cx, e1); @@ -58,7 +58,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let ty = ty::expr_ty(cx.tcx, e1); let is_float = ty::type_is_fp(ty); let signed = ty::type_is_signed(ty); - return alt b { + return match b { ast::add => { if is_float { llvm::LLVMConstFAdd(te1, te2) } else { llvm::LLVMConstAdd(te1, te2) } @@ -103,7 +103,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let te = const_expr(cx, e); let ty = ty::expr_ty(cx.tcx, e); let is_float = ty::type_is_fp(ty); - return alt u { + return match u { ast::box(_) | ast::uniq(_) | ast::deref => cx.sess.span_bug(e.span, @@ -119,7 +119,9 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let ety = ty::expr_ty(cx.tcx, e), llty = type_of::type_of(cx, ety); let basety = ty::expr_ty(cx.tcx, base); let v = const_expr(cx, base); - alt check (base::cast_type_kind(basety), base::cast_type_kind(ety)) { + match check (base::cast_type_kind(basety), + base::cast_type_kind(ety)) { + (base::cast_integral, base::cast_integral) => { let s = if ty::type_is_signed(basety) { True } else { False }; llvm::LLVMConstIntCast(v, llty, s) @@ -162,9 +164,9 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { const_expr(cx, e) } ast::expr_vstore(sub, ast::vstore_slice(_)) => { - alt sub.node { + match sub.node { ast::expr_lit(lit) => { - alt lit.node { + match lit.node { ast::lit_str(*) => { const_expr(cx, sub) } _ => { cx.sess.span_bug(e.span, ~"bad const-slice lit") } @@ -186,11 +188,11 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { } } ast::expr_path(path) => { - alt cx.tcx.def_map.find(e.id) { + match cx.tcx.def_map.find(e.id) { some(ast::def_const(def_id)) => { // Don't know how to handle external consts assert ast_util::is_local(def_id); - alt cx.tcx.items.get(def_id.node) { + match cx.tcx.items.get(def_id.node) { ast_map::node_item(@{ node: ast::item_const(_, subexpr), _ }, _) => { diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 30300550c31..1a207a5313c 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -134,7 +134,7 @@ fn cast_safely<T: copy, U>(val: T) -> U unsafe { } fn md_from_metadata<T>(val: debug_metadata) -> T unsafe { - alt val { + match val { file_metadata(md) => cast_safely(md), compile_unit_metadata(md) => cast_safely(md), subprogram_metadata(md) => cast_safely(md), @@ -165,7 +165,7 @@ fn create_compile_unit(cx: @crate_ctxt) let cache = get_cache(cx); let crate_name = option::get(cx.dbg_cx).crate_file; let tg = CompileUnitTag; - alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg, + match cached_metadata::<@metadata<compile_unit_md>>(cache, tg, |md| md.data.name == crate_name) { option::some(md) => return md, option::none => () @@ -208,7 +208,7 @@ fn get_file_path_and_dir(work_dir: ~str, full_path: ~str) -> (~str, ~str) { fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> { let cache = get_cache(cx);; let tg = FileDescriptorTag; - alt cached_metadata::<@metadata<file_md>>( + match cached_metadata::<@metadata<file_md>>( cache, tg, |md| md.data.path == full_path) { option::some(md) => return md, option::none => () @@ -235,7 +235,7 @@ fn create_block(cx: block) -> @metadata<block_md> { let cache = get_cache(cx.ccx()); let mut cx = cx; while option::is_none(cx.node_info) { - alt cx.parent { + match cx.parent { some(b) => cx = b, none => fail } @@ -253,12 +253,12 @@ fn create_block(cx: block) -> @metadata<block_md> { option::none {} }*/ - let parent = alt cx.parent { + let parent = match cx.parent { none => create_function(cx.fcx).node, some(bcx) => create_block(bcx).node }; let file_node = create_file(cx.ccx(), fname); - let unique_id = alt cache.find(LexicalBlockTag) { + let unique_id = match cache.find(LexicalBlockTag) { option::some(v) => vec::len(v) as int, option::none => 0 }; @@ -285,15 +285,15 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) -> @metadata<tydesc_md> { let cache = get_cache(cx); let tg = BasicTypeDescriptorTag; - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, |md| ty::type_id(t) == md.data.hash) { option::some(md) => return md, option::none => () } - let (name, encoding) = alt check ty { + let (name, encoding) = match check ty { ast::ty_bool => (~"bool", DW_ATE_boolean), - ast::ty_int(m) => alt m { + ast::ty_int(m) => match m { ast::ty_char => (~"char", DW_ATE_unsigned), ast::ty_i => (~"int", DW_ATE_signed), ast::ty_i8 => (~"i8", DW_ATE_signed_char), @@ -301,14 +301,14 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) ast::ty_i32 => (~"i32", DW_ATE_signed), ast::ty_i64 => (~"i64", DW_ATE_signed) } - ast::ty_uint(m) => alt m { + ast::ty_uint(m) => match m { ast::ty_u => (~"uint", DW_ATE_unsigned), ast::ty_u8 => (~"u8", DW_ATE_unsigned_char), ast::ty_u16 => (~"u16", DW_ATE_unsigned), ast::ty_u32 => (~"u32", DW_ATE_unsigned), ast::ty_u64 => (~"u64", DW_ATE_unsigned) } - ast::ty_float(m) => alt m { + ast::ty_float(m) => match m { ast::ty_f => (~"float", DW_ATE_float), ast::ty_f32 => (~"f32", DW_ATE_float), ast::ty_f64 => (~"f64", DW_ATE_float) @@ -341,7 +341,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, -> @metadata<tydesc_md> { let tg = PointerTypeTag; /*let cache = cx.llmetadata; - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| ty::hash_ty(t) == ty::hash_ty(md.data.hash)}) { option::some(md) { return md; } option::none {} @@ -434,7 +434,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, -> @metadata<tydesc_md> { //let tg = StructureTypeTag; /*let cache = cx.llmetadata; - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| ty::hash_ty(outer) == ty::hash_ty(md.data.hash)}) { option::some(md) { return md; } option::none {} @@ -516,7 +516,7 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) -> @metadata<tydesc_md> { /*let cache = get_cache(cx); - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| t == md.data.hash}) { option::some(md) { return md; } option::none {} @@ -536,7 +536,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) fail; /* fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty { - let ty = alt ty::get(t).struct { + let ty = match ty::get(t).struct { ty::ty_nil { ast::ty_nil } ty::ty_bot { ast::ty_bot } ty::ty_bool { ast::ty_bool } @@ -566,9 +566,9 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) return @{node: ty, span: span}; } - alt ty.node { + match ty.node { ast::ty_box(mt) { - let inner_t = alt ty::get(t).struct { + let inner_t = match ty::get(t).struct { ty::ty_box(boxed) { boxed.ty } _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); } }; @@ -578,7 +578,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) } ast::ty_uniq(mt) { - let inner_t = alt ty::get(t).struct { + let inner_t = match ty::get(t).struct { ty::ty_uniq(boxed) { boxed.ty } // Hoping we'll have a way to eliminate this check soon. _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); } @@ -604,7 +604,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) } ast::ty_path(_, id) { - alt cx.tcx.def_map.get(id) { + match cx.tcx.def_map.get(id) { ast::def_prim_ty(pty) { return create_basic_type(cx, t, pty, ty.span); } @@ -639,13 +639,13 @@ fn create_local_var(bcx: block, local: @ast::local) let cx = bcx.ccx(); let cache = get_cache(cx); let tg = AutoVariableTag; - alt cached_metadata::<@metadata<local_var_md>>( + match cached_metadata::<@metadata<local_var_md>>( cache, tg, |md| md.data.id == local.node.id) { option::some(md) => return md, option::none => () } - let name = alt local.node.pat.node { + let name = match local.node.pat.node { ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), // FIXME this should be handled (#2533) _ => fail ~"no single variable name for local" @@ -655,7 +655,7 @@ fn create_local_var(bcx: block, local: @ast::local) let ty = node_id_type(bcx, local.node.id); let tymd = create_ty(cx, ty, local.node.ty); let filemd = create_file(cx, loc.file.name); - let context = alt bcx.parent { + let context = match bcx.parent { none => create_function(bcx.fcx).node, some(_) => create_block(bcx).node }; @@ -664,14 +664,14 @@ fn create_local_var(bcx: block, local: @ast::local) let mdval = @{node: mdnode, data: {id: local.node.id}}; update_cache(cache, AutoVariableTag, local_var_metadata(mdval)); - let llptr = alt bcx.fcx.lllocals.find(local.node.id) { + let llptr = match bcx.fcx.lllocals.find(local.node.id) { option::some(local_mem(v)) => v, option::some(_) => { bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird"); } option::none => { - alt bcx.fcx.lllocals.get(local.node.pat.id) { + match bcx.fcx.lllocals.get(local.node.pat.id) { local_imm(v) => v, _ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird") @@ -689,7 +689,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let fcx = bcx.fcx, cx = fcx.ccx; let cache = get_cache(cx); let tg = ArgVariableTag; - alt cached_metadata::<@metadata<argument_md>>( + match cached_metadata::<@metadata<argument_md>>( cache, ArgVariableTag, |md| md.data.id == arg.id) { option::some(md) => return md, option::none => () @@ -706,7 +706,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let mdval = @{node: mdnode, data: {id: arg.id}}; update_cache(cache, tg, argument_metadata(mdval)); - let llptr = alt fcx.llargs.get(arg.id) { + let llptr = match fcx.llargs.get(arg.id) { local_mem(v) | local_imm(v) => v, }; let declargs = ~[llmdnode(~[llptr]), mdnode]; @@ -740,9 +740,9 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { let sp = option::get(fcx.span); log(debug, codemap::span_to_str(sp, cx.sess.codemap)); - let (ident, ret_ty, id) = alt cx.tcx.items.get(fcx.id) { + let (ident, ret_ty, id) = match cx.tcx.items.get(fcx.id) { ast_map::node_item(item, _) => { - alt item.node { + match item.node { ast::item_fn(decl, _, _) => { (item.ident, decl.output, item.id) } @@ -758,7 +758,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { (nm, ctor.node.dec.output, ctor.node.id) } ast_map::node_expr(expr) => { - alt expr.node { + match expr.node { ast::expr_fn(_, decl, _, _) => { (@dbg_cx.names(~"fn"), decl.output, expr.id) } @@ -778,7 +778,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { log(debug, id); let cache = get_cache(cx); - alt cached_metadata::<@metadata<subprogram_md>>( + match cached_metadata::<@metadata<subprogram_md>>( cache, SubprogramTag, |md| md.data.id == id) { option::some(md) => return md, option::none => () @@ -788,7 +788,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { sp.lo); let file_node = create_file(cx, loc.file.name).node; let ty_node = if cx.sess.opts.extra_debuginfo { - alt ret_ty.node { + match ret_ty.node { ast::ty_nil => llnull(), _ => create_ty(cx, ty::node_id_to_type(cx.tcx, id), ret_ty).node } diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 56f8892ff37..1555f2df89a 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -38,7 +38,7 @@ enum x86_64_reg_class { } fn is_sse(++c: x86_64_reg_class) -> bool { - return alt c { + return match c { sse_fs_class | sse_fv_class | sse_ds_class | sse_dv_class => true, _ => false @@ -73,7 +73,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_align(ty: TypeRef) -> uint { - return alt llvm::LLVMGetTypeKind(ty) as int { + return match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ => { ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u } @@ -94,7 +94,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_size(ty: TypeRef) -> uint { - return alt llvm::LLVMGetTypeKind(ty) as int { + return match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ => { ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u } @@ -179,7 +179,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { return; } - alt llvm::LLVMGetTypeKind(ty) as int { + match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ | 12 /* pointer */ => { unify(cls, ix + off / 8u, integer_class); @@ -285,7 +285,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { let mut i = 0u; let e = vec::len(cls); while i < e { - alt cls[i] { + match cls[i] { integer_class => { vec::push(tys, T_i64()); } @@ -326,7 +326,7 @@ fn x86_64_tys(atys: ~[TypeRef], rty: TypeRef, ret_def: bool) -> x86_64_tys { fn is_reg_ty(ty: TypeRef) -> bool { - return alt llvm::LLVMGetTypeKind(ty) as int { + return match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ | 12 /* pointer */ | 2 /* float */ | @@ -401,7 +401,7 @@ fn decl_x86_64_fn(tys: x86_64_tys, let llfn = decl(fnty); do vec::iteri(tys.attrs) |i, a| { - alt a { + match a { option::some(attr) => { let llarg = get_param(llfn, i); llvm::LLVMAddAttribute(llarg, attr as c_uint); @@ -413,7 +413,7 @@ fn decl_x86_64_fn(tys: x86_64_tys, } fn link_name(i: @ast::foreign_item) -> ~str { - alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { + match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { none => return *i.ident, option::some(ln) => return *ln } @@ -430,7 +430,7 @@ type c_stack_tys = { fn c_arg_and_ret_lltys(ccx: @crate_ctxt, id: ast::node_id) -> (~[TypeRef], TypeRef, ty::t) { - alt ty::get(ty::node_id_to_type(ccx.tcx, id)).struct { + match ty::get(ty::node_id_to_type(ccx.tcx, id)).struct { ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) => { let llargtys = type_of_explicit_args(ccx, arg_tys); let llretty = type_of::type_of(ccx, ret_ty); @@ -587,7 +587,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let mut i = 0u; let n = vec::len(tys.arg_tys); - alt tys.x86_64_tys { + match tys.x86_64_tys { some(x86_64) => { let mut atys = x86_64.arg_tys; let mut attrs = x86_64.attrs; @@ -629,10 +629,10 @@ fn trans_foreign_mod(ccx: @crate_ctxt, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef, llretval: ValueRef) { let _icx = bcx.insn_ctxt(~"foreign::shim::build_ret"); - alt tys.x86_64_tys { + match tys.x86_64_tys { some(x86_64) => { do vec::iteri(x86_64.attrs) |i, a| { - alt a { + match a { some(attr) => { llvm::LLVMAddInstrAttribute( llretval, (i + 1u) as c_uint, @@ -680,7 +680,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, fn base_fn(ccx: @crate_ctxt, lname: ~str, tys: @c_stack_tys, cc: lib::llvm::CallConv) -> ValueRef { // Declare the "prototype" for the base function F: - alt tys.x86_64_tys { + match tys.x86_64_tys { some(x86_64) => { do decl_x86_64_fn(x86_64) |fnty| { decl_fn(ccx.llmod, lname, cc, fnty) @@ -747,14 +747,14 @@ fn trans_foreign_mod(ccx: @crate_ctxt, build_args, build_ret); } - let mut cc = alt abi { + let mut cc = match abi { ast::foreign_abi_rust_intrinsic | ast::foreign_abi_cdecl => lib::llvm::CCallConv, ast::foreign_abi_stdcall => lib::llvm::X86StdcallCallConv }; for vec::each(foreign_mod.items) |foreign_item| { - alt foreign_item.node { + match foreign_item.node { ast::foreign_item_fn(fn_decl, typarams) => { let id = foreign_item.id; if abi != ast::foreign_abi_rust_intrinsic { @@ -772,7 +772,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, // monomorphic_fn, but ones without are emitted here if typarams.is_empty() { let llwrapfn = get_item_val(ccx, id); - let path = alt ccx.tcx.items.find(id) { + let path = match ccx.tcx.items.find(id) { some(ast_map::node_foreign_item(_, _, pt)) => pt, _ => { ccx.sess.span_bug(foreign_item.span, @@ -799,7 +799,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id, some(substs), some(item.span)); let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb; - alt check *item.ident { + match check *item.ident { ~"atomic_xchng" => { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), @@ -925,7 +925,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let tp_sz = shape::llsize_of_real(ccx, lltp_ty), out_sz = shape::llsize_of_real(ccx, llout_ty); if tp_sz != out_sz { - let sp = alt check ccx.tcx.items.get(option::get(ref_id)) { + let sp = match check ccx.tcx.items.get(option::get(ref_id)) { ast_map::node_expr(e) => e.span }; ccx.sess.span_fatal( @@ -1045,7 +1045,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_args(bcx: block, tys: @c_stack_tys, llwrapfn: ValueRef, llargbundle: ValueRef) { let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_args"); - alt tys.x86_64_tys { + match tys.x86_64_tys { option::some(x86_64) => { let mut atys = x86_64.arg_tys; let mut attrs = x86_64.attrs; @@ -1099,7 +1099,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) { let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_ret"); - alt tys.x86_64_tys { + match tys.x86_64_tys { option::some(x86_64) => { if x86_64.sret || !tys.ret_def { RetVoid(bcx); @@ -1161,11 +1161,11 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span, fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item) -> ast::foreign_abi { - alt attr::first_attr_value_str_by_name(i.attrs, ~"abi") { - none => alt check ccx.tcx.items.get(i.id) { + match attr::first_attr_value_str_by_name(i.attrs, ~"abi") { + none => match check ccx.tcx.items.get(i.id) { ast_map::node_foreign_item(_, abi, _) => abi } - some(_) => alt attr::foreign_abi(i.attrs) { + some(_) => match attr::foreign_abi(i.attrs) { either::right(abi) => abi, either::left(msg) => ccx.sess.span_fatal(i.span, msg) } diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index 434707f3fa8..979bb6e847a 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -52,7 +52,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, self: @ast::expr, mentry: typeck::method_map_entry) -> lval_maybe_callee { let _icx = bcx.insn_ctxt(~"impl::trans_method_callee"); - alt mentry.origin { + match mentry.origin { typeck::method_static(did) => { let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs); {env: self_env(val, node_id_type(bcx, self.id), none) @@ -60,7 +60,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, } typeck::method_param({trait_id:iid, method_num:off, param_num:p, bound_num:b}) => { - alt check bcx.fcx.param_substs { + match check bcx.fcx.param_substs { some(substs) => { trans_monomorphized_callee(bcx, callee_id, self, mentry.derefs, iid, off, p, b, substs) @@ -83,7 +83,7 @@ fn method_from_methods(ms: ~[@ast::method], name: ast::ident) fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, name: ast::ident) -> ast::def_id { if impl_id.crate == ast::local_crate { - alt check ccx.tcx.items.get(impl_id.node) { + match check ccx.tcx.items.get(impl_id.node) { ast_map::node_item(@{node: ast::item_impl(_, _, _, ms), _}, _) => { method_from_methods(ms, name) } @@ -101,7 +101,7 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, i_id: ast::def_id) -> uint { if m_id.crate == ast::local_crate { - alt check ccx.tcx.items.get(m_id.node) { + match check ccx.tcx.items.get(m_id.node) { ast_map::node_method(m, _, _) => vec::len(m.tps), } } else { @@ -116,7 +116,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, n_param: uint, n_bound: uint, substs: param_substs) -> lval_maybe_callee { let _icx = bcx.insn_ctxt(~"impl::trans_monomorphized_callee"); - alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) { + match find_vtable_in_fn_ctxt(substs, n_param, n_bound) { typeck::vtable_static(impl_did, impl_substs, sub_origins) => { let ccx = bcx.ccx(); let mname = ty::trait_methods(ccx.tcx, trait_id)[n_method].ident; @@ -173,7 +173,7 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint) for vec::each(*ps.bounds) |bounds| { if i >= n_param { break; } for vec::each(*bounds) |bound| { - alt bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } + match bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } } i += 1u; } @@ -189,9 +189,9 @@ fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res) // eliminate any vtable_params. fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) -> typeck::vtable_origin { - alt vt { + match vt { typeck::vtable_static(iid, tys, sub) => { - let tys = alt fcx.param_substs { + let tys = match fcx.param_substs { some(substs) => { vec::map(tys, |t| ty::subst_tps(fcx.ccx.tcx, substs.tys, t)) } @@ -200,7 +200,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) typeck::vtable_static(iid, tys, resolve_vtables_in_fn_ctxt(fcx, sub)) } typeck::vtable_param(n_param, n_bound) => { - alt check fcx.param_substs { + match check fcx.param_substs { some(substs) => { find_vtable_in_fn_ctxt(substs, n_param, n_bound) } @@ -211,7 +211,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) } fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id { - alt check origin { + match check origin { typeck::vtable_static(impl_id, substs, sub_vtables) => { make_mono_id(ccx, impl_id, substs, if (*sub_vtables).len() == 0u { none } @@ -227,9 +227,9 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id { fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> ValueRef { let hash_id = vtable_id(ccx, origin); - alt ccx.vtables.find(hash_id) { + match ccx.vtables.find(hash_id) { some(val) => val, - none => alt check origin { + none => match check origin { typeck::vtable_static(id, substs, sub_vtables) => { make_impl_vtable(ccx, id, substs, sub_vtables) } diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index b149857ffaa..9637b5b7ce5 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -34,11 +34,11 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve3::ExportMap, fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool { let mut found_export = false; for vec::each(vis) |vi| { - alt vi.node { + match vi.node { view_item_export(vps) => { found_export = true; for vec::each(vps) |vp| { - alt vp.node { + match vp.node { view_path_simple(_, _, id) | view_path_glob(_, id) | view_path_list(_, _, id) => { traverse_export(cx, id); @@ -60,11 +60,11 @@ fn traverse_export(cx: ctx, exp_id: node_id) { fn traverse_def_id(cx: ctx, did: def_id) { if did.crate != local_crate { return; } - let n = alt cx.tcx.items.find(did.node) { + let n = match cx.tcx.items.find(did.node) { none => return, // This can happen for self, for example some(n) => n }; - alt n { + match n { ast_map::node_item(item, _) => traverse_public_item(cx, item), ast_map::node_method(_, impl_id, _) => traverse_def_id(cx, impl_id), ast_map::node_foreign_item(item, _, _) => { @@ -89,7 +89,7 @@ fn traverse_public_mod(cx: ctx, m: _mod) { fn traverse_public_item(cx: ctx, item: @item) { if cx.rmap.contains_key(item.id) { return; } cx.rmap.insert(item.id, ()); - alt item.node { + match item.node { item_mod(m) => traverse_public_mod(cx, m), item_foreign_mod(nm) => { if !traverse_exports(cx, nm.view_items) { @@ -127,7 +127,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } } for vec::each(items) |item| { - alt item.node { + match item.node { class_method(m) => { cx.rmap.insert(m.id, ()); if tps.len() > 0u || @@ -156,9 +156,9 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) { if cx.rmap.contains_key(ty.id) { return; } cx.rmap.insert(ty.id, ()); - alt ty.node { + match ty.node { ty_path(p, p_id) => { - alt cx.tcx.def_map.find(p_id) { + match cx.tcx.def_map.find(p_id) { // Kind of a hack to check this here, but I'm not sure what else // to do some(def_prim_ty(_)) => { /* do nothing */ } @@ -173,9 +173,9 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) { fn traverse_inline_body(cx: ctx, body: blk) { fn traverse_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { - alt e.node { + match e.node { expr_path(_) => { - alt cx.tcx.def_map.find(e.id) { + match cx.tcx.def_map.find(e.id) { some(d) => { traverse_def_id(cx, def_id_of_def(d)); } @@ -184,7 +184,7 @@ fn traverse_inline_body(cx: ctx, body: blk) { } } expr_field(_, _, _) => { - alt cx.method_map.find(e.id) { + match cx.method_map.find(e.id) { some({origin: typeck::method_static(did), _}) => { traverse_def_id(cx, did); } @@ -213,7 +213,7 @@ fn traverse_all_resources_and_impls(cx: ctx, crate_mod: _mod) { visit_expr: |_e, _cx, _v| { }, visit_item: |i, cx, v| { visit::visit_item(i, cx, v); - alt i.node { + match i.node { item_class(_, _, _, _, some(_)) => { traverse_public_item(cx, i); } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index c4d4cd6f9b3..fbcb01ff68e 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -91,7 +91,7 @@ impl methods for reflector { fn vstore_name_and_extra(t: ty::t, vstore: ty::vstore, f: fn(~str,~[ValueRef])) { - alt vstore { + match vstore { ty::vstore_fixed(n) => { let extra = vec::append(~[self.c_uint(n)], self.c_size_and_align(t)); @@ -114,7 +114,7 @@ impl methods for reflector { debug!{"reflect::visit_ty %s", ty_to_str(bcx.ccx().tcx, t)}; - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_bot => self.leaf(~"bot"), ty::ty_nil => self.leaf(~"nil"), ty::ty_bool => self.leaf(~"bool"), @@ -178,19 +178,19 @@ impl methods for reflector { // FIXME (#2594): fetch constants out of intrinsic:: for the // numbers. ty::ty_fn(fty) => { - let pureval = alt fty.purity { + let pureval = match fty.purity { ast::pure_fn => 0u, ast::unsafe_fn => 1u, ast::impure_fn => 2u, ast::extern_fn => 3u }; - let protoval = alt fty.proto { + let protoval = match fty.proto { ast::proto_bare => 0u, ast::proto_uniq => 2u, ast::proto_box => 3u, ast::proto_block => 4u }; - let retval = alt fty.ret_style { + let retval = match fty.ret_style { ast::noreturn => 0u, ast::return_val => 1u }; @@ -200,9 +200,9 @@ impl methods for reflector { self.c_uint(retval)]; self.visit(~"enter_fn", extra); for fty.inputs.eachi |i, arg| { - let modeval = alt arg.mode { + let modeval = match arg.mode { ast::infer(_) => 0u, - ast::expl(e) => alt e { + ast::expl(e) => match e { ast::by_ref => 1u, ast::by_val => 2u, ast::by_mutbl_ref => 3u, @@ -274,7 +274,7 @@ impl methods for reflector { ty::ty_type => self.leaf(~"type"), ty::ty_opaque_box => self.leaf(~"opaque_box"), ty::ty_opaque_closure_ptr(ck) => { - let ckval = alt ck { + let ckval = match ck { ty::ck_block => 0u, ty::ck_box => 1u, ty::ck_uniq => 2u diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index d6d5d96e4dc..2d57b71e683 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -149,7 +149,7 @@ fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind { // Returns the code corresponding to the pointer size on this architecture. fn s_int(tcx: ty_ctxt) -> u8 { - return alt tcx.sess.targ_cfg.arch { + return match tcx.sess.targ_cfg.arch { session::arch_x86 => shape_i32, session::arch_x86_64 => shape_i64, session::arch_arm => shape_i32 @@ -157,7 +157,7 @@ fn s_int(tcx: ty_ctxt) -> u8 { } fn s_uint(tcx: ty_ctxt) -> u8 { - return alt tcx.sess.targ_cfg.arch { + return match tcx.sess.targ_cfg.arch { session::arch_x86 => shape_u32, session::arch_x86_64 => shape_u64, session::arch_arm => shape_u32 @@ -165,7 +165,7 @@ fn s_uint(tcx: ty_ctxt) -> u8 { } fn s_float(tcx: ty_ctxt) -> u8 { - return alt tcx.sess.targ_cfg.arch { + return match tcx.sess.targ_cfg.arch { session::arch_x86 => shape_f64, session::arch_x86_64 => shape_f64, session::arch_arm => shape_f64 @@ -213,7 +213,7 @@ fn add_substr(&dest: ~[u8], src: ~[u8]) { } fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_nil | ty::ty_bool | ty::ty_uint(ast::ty_u8) | ty::ty_bot => ~[shape_u8], ty::ty_int(ast::ty_i) => ~[s_int(ccx.tcx)], @@ -233,13 +233,13 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t)) } ty::ty_enum(did, substs) => { - alt enum_kind(ccx, did) { + match enum_kind(ccx, did) { tk_unit => ~[s_variant_enum_t(ccx.tcx)], tk_enum => ~[s_variant_enum_t(ccx.tcx)], tk_newtype | tk_complex => { let mut s = ~[shape_enum], id; let nom_id = mk_nominal_id(ccx.tcx, did, none, substs.tps); - alt ccx.shape_cx.tag_id_to_index.find(nom_id) { + match ccx.shape_cx.tag_id_to_index.find(nom_id) { none => { id = ccx.shape_cx.next_tag_id; ccx.shape_cx.tag_id_to_index.insert(nom_id, id); @@ -678,7 +678,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // Computes the size of the data part of an enum. fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); } - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_enum(tid, substs) => { // Compute max(variant sizes). let mut max_size = 0u; @@ -712,7 +712,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm}) } fn simplifier(tcx: ty::ctxt, typ: ty::t) -> ty::t { - alt ty::get(typ).struct { + match ty::get(typ).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_uniq) | ty::ty_estr(ty::vstore_box) | diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 84d7ca370f9..aa92c96a686 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -19,7 +19,7 @@ import util::ppaux::ty_to_str; fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { let unit_ty = ty::sequence_element_type(tcx, t); let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_estr(ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_uniq) => { ty::mk_imm_uniq(tcx, unboxed_vec_ty) } @@ -156,10 +156,10 @@ fn trans_evec(bcx: block, elements: evec_elements, let unit_sz = llsize_of(ccx, llunitty); let mut {bcx, val, dataptr} = - alt vst { + match vst { ast::vstore_fixed(_) => { // Destination should be pre-allocated for us. - let v = alt dest { + let v = match dest { base::save_in(v) => { PointerCast(bcx, v, T_ptr(llunitty)) } @@ -245,7 +245,7 @@ fn trans_evec(bcx: block, elements: evec_elements, for vec::each(temp_cleanups) |cln| { revoke_clean(bcx, cln); } - alt vst { + match vst { ast::vstore_fixed(_) => { // We wrote into the destination in the fixed case. return bcx; @@ -261,7 +261,7 @@ fn trans_evec(bcx: block, elements: evec_elements, fn trans_vstore(bcx: block, e: @ast::expr, v: ast::vstore, dest: dest) -> block { - alt e.node { + match e.node { ast::expr_lit(@{node: ast::lit_str(s), span: _}) => { return trans_estr(bcx, s, some(v), dest); } @@ -288,12 +288,12 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) let llunitty = type_of::type_of(ccx, unit_ty); let unit_sz = llsize_of(ccx, llunitty); - let vstore = alt ty::get(vec_ty).struct { + let vstore = match ty::get(vec_ty).struct { ty::ty_estr(vst) | ty::ty_evec(_, vst) => vst, _ => ty::vstore_uniq }; - alt vstore { + match vstore { ty::vstore_fixed(n) => { let base = GEPi(cx, v, ~[0u, 0u]); let n = if ty::type_is_str(e_ty) { n + 1u } else { n }; @@ -319,7 +319,7 @@ fn trans_estr(bcx: block, s: @~str, vstore: option<ast::vstore>, if dest == base::ignore { return bcx; } let ccx = bcx.ccx(); - let c = alt vstore { + let c = match vstore { some(ast::vstore_fixed(_)) => { // "hello"/_ => "hello"/5 => ~[i8 x 6] in llvm debug!{"trans_estr: fixed: %s", *s}; diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index 03f7d2b5482..73daa654d28 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -17,7 +17,7 @@ fn type_of_explicit_args(cx: @crate_ctxt, do vec::map(inputs) |arg| { let arg_ty = arg.ty; let llty = type_of(cx, arg_ty); - alt ty::resolved_mode(cx.tcx, arg.mode) { + match ty::resolved_mode(cx.tcx, arg.mode) { ast::by_val => llty, _ => T_ptr(llty) } @@ -51,7 +51,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef { if t != t_norm { type_of_non_gc_box(cx, t_norm) } else { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_box(mt) => { T_ptr(T_box(cx, type_of(cx, mt.ty))) } @@ -83,7 +83,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { llty = type_of(cx, t_norm); cx.lltypes.insert(t, llty); } else { - llty = alt ty::get(t).struct { + llty = match ty::get(t).struct { ty::ty_nil | ty::ty_bot => T_nil(), ty::ty_bool => T_bool(), ty::ty_int(t) => T_int_ty(cx, t), @@ -166,7 +166,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { cx.lltypes.insert(t, llty); // If this was a class, fill in the type now. - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_class(did, ts) => { // Only instance vars are record fields at runtime. let fields = ty::lookup_class_fields(cx.tcx, did); @@ -225,7 +225,7 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) } fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { - let (name, did, tps) = alt check ty::get(t).struct { + let (name, did, tps) = match check ty::get(t).struct { ty::ty_enum(did, substs) => (~"enum", did, substs.tps), ty::ty_class(did, substs) => (~"class", did, substs.tps) }; diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 4026d2b0a24..b7f9fdc459d 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -35,7 +35,7 @@ type ctx = {ccx: @crate_ctxt, fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) -> ~[type_uses] { - alt ccx.type_use_cache.find(fn_id) { + match ccx.type_use_cache.find(fn_id) { some(uses) => return uses, none => () } @@ -45,7 +45,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ccx.type_use_cache.insert(fn_id, vec::from_elem(n_tps, 3u)); let cx = {ccx: ccx, uses: vec::to_mut(vec::from_elem(n_tps, 0u))}; - alt ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct { + match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct { ty::ty_fn({inputs, _}) => { for vec::each(inputs) |arg| { if arg.mode == expl(by_val) { type_needs(cx, use_repr, arg.ty); } @@ -59,12 +59,12 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ccx.type_use_cache.insert(fn_id, uses); return uses; } - let map_node = alt ccx.tcx.items.find(fn_id_loc.node) { + let map_node = match ccx.tcx.items.find(fn_id_loc.node) { some(x) => x, none => ccx.sess.bug(fmt!{"type_uses_for: unbound item ID %?", fn_id_loc}) }; - alt check map_node { + match check map_node { ast_map::node_item(@{node: item_fn(_, _, body), _}, _) | ast_map::node_method(@{body, _}, _, _) => { handle_body(cx, body); @@ -75,7 +75,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ast_map::node_foreign_item(i@@{node: foreign_item_fn(_, _), _}, abi, _) => { if abi == foreign_abi_rust_intrinsic { - let flags = alt check *i.ident { + let flags = match check *i.ident { ~"size_of" | ~"pref_align_of" | ~"min_align_of" | ~"init" | ~"reinterpret_cast" | ~"move_val" | ~"move_val_init" => { @@ -120,7 +120,7 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t, enums_seen: @list<def_id>) { do ty::maybe_walk_ty(ty) |ty| { if ty::type_has_params(ty) { - alt ty::get(ty).struct { + match ty::get(ty).struct { /* This previously included ty_box -- that was wrong because if we cast an @T to an trait (for example) and return @@ -156,7 +156,7 @@ fn node_type_needs(cx: ctx, use: uint, id: node_id) { } fn mark_for_expr(cx: ctx, e: @expr) { - alt e.node { + match e.node { expr_vstore(_, _) | expr_vec(_, _) | expr_rec(_, _) | expr_struct(*) | expr_tup(_) | @@ -168,7 +168,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } expr_cast(base, _) => { let result_t = ty::node_id_to_type(cx.ccx.tcx, e.id); - alt ty::get(result_t).struct { + match ty::get(result_t).struct { ty::ty_trait(*) => { // When we're casting to an trait, we need the // tydesc for the expr that's being cast. @@ -178,7 +178,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } } expr_binary(op, lhs, _) => { - alt op { + match op { eq | lt | le | ne | ge | gt => { node_type_needs(cx, use_tydesc, lhs.id) } @@ -195,7 +195,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } } expr_fn(*) | expr_fn_block(*) => { - alt ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) { + match ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) { proto_bare | proto_uniq => {} proto_box | proto_block => { for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| { @@ -216,7 +216,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty)); do option::iter(cx.ccx.maps.method_map.find(e.id)) |mth| { - alt mth.origin { + match mth.origin { typeck::method_static(did) => { do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) |ts| { do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts) @@ -235,7 +235,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } expr_call(f, _, _) => { vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), |a| { - alt a.mode { + match a.mode { expl(by_move) | expl(by_copy) | expl(by_val) => { type_needs(cx, use_repr, a.ty); } diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index c2bdf280100..e66ae41e5c6 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -19,7 +19,7 @@ fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t) } fn content_ty(t: ty::t) -> ty::t { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_uniq({ty: ct, _}) => ct, _ => core::unreachable() } diff --git a/src/rustc/middle/tstate/ann.rs b/src/rustc/middle/tstate/ann.rs index cbd255341f5..19a2ca15723 100644 --- a/src/rustc/middle/tstate/ann.rs +++ b/src/rustc/middle/tstate/ann.rs @@ -240,7 +240,7 @@ fn implies(a: t, b: t) -> bool { } fn trit_str(t: trit) -> ~str { - alt t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } } + match t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } } } // FIXME (#2538): Would be nice to have unit tests for some of these diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index f4b2e5e6442..379546015cc 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -14,7 +14,7 @@ fn collect_ids_block(b: blk, rs: @mut ~[node_id]) { } fn collect_ids_stmt(s: @stmt, rs: @mut ~[node_id]) { - alt s.node { + match s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { debug!{"node_id %s", int::str(id)}; debug!{"%s", stmt_to_str(*s)}; diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index eb39d4ec561..ce3b65db6ff 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -39,7 +39,7 @@ fn comma_str(args: ~[@constr_arg_use]) -> ~str { let mut comma = false; for args.each |a| { if comma { rslt += ~", "; } else { comma = true; } - alt a.node { + match a.node { carg_base { rslt += ~"*"; } carg_ident(i) { rslt += *i.ident; } carg_lit(l) { rslt += lit_to_str(l); } @@ -59,7 +59,7 @@ fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str { let mut s = ~""; let mut comma = false; for constraints(fcx).each |p| { - alt v.get(p.bit_num) { + match v.get(p.bit_num) { dont_care { } tt { s += @@ -261,7 +261,7 @@ fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option<ts_ann> { /********* utils ********/ fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann { - alt get_ts_ann(ccx, id) { + match get_ts_ann(ccx, id) { none { error!{"node_id_to_ts_ann: no ts_ann for node_id %d", id}; fail; @@ -277,7 +277,7 @@ fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate { fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { debug!{"stmt_to_ann"}; - alt s.node { + match s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { return node_id_to_ts_ann(ccx, id); } @@ -445,21 +445,21 @@ fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt { If it has a function type with a ! annotation, the answer is noreturn. */ fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> ret_style { - alt ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct { + match ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct { ty::ty_fn(f) { return f.ret_style; } _ { return return_val; } } } fn constraints_expr(cx: ty::ctxt, e: @expr) -> ~[@ty::constr] { - alt ty::get(ty::node_id_to_type(cx, e.id)).struct { + match ty::get(ty::node_id_to_type(cx, e.id)).struct { ty::ty_fn(f) { return f.constraints; } _ { return ~[]; } } } fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def { - alt cx.def_map.find(id) { + match cx.def_map.find(id) { none { error!{"node_id_to_def: node_id %d has no def", id}; fail; @@ -511,7 +511,7 @@ fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>, } fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { - alt tcx.def_map.find(t) { + match tcx.def_map.find(t) { none { tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t)); } @@ -521,9 +521,9 @@ fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { } fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { - alt e.node { + match e.node { expr_path(p) { - alt tcx.def_map.find(e.id) { + match tcx.def_map.find(e.id) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_binding(nid, _)) | some(def_upvar(nid, _, _)) { return @respan(p.span, @@ -559,9 +559,9 @@ fn exprs_to_constr_args(tcx: ty::ctxt, } fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr { - alt e.node { + match e.node { expr_call(operator, args, _) { - alt operator.node { + match operator.node { expr_path(p) { return respan(e.span, {path: p, @@ -601,7 +601,7 @@ fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) -> fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) -> @constr_arg_use { let num_actuals = vec::len(actuals); - alt a.node { + match a.node { carg_ident(i) { if i < num_actuals { return expr_to_constr_arg(cx, actuals[i]); @@ -620,16 +620,16 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>], let mut i = 0u; for desc.node.args.each |c| { let n = pattern[i]; - alt c.node { + match c.node { carg_ident(p) { - alt n { + match n { carg_ident(q) { if p.node != q.node { return false; } } _ { return false; } } } carg_base { if n != carg_base { return false; } } carg_lit(l) { - alt n { + match n { carg_lit(m) { if !const_eval::lit_eq(l, m) { return false; } } _ { return false; } } @@ -669,7 +669,7 @@ fn find_instances(_fcx: fn_ctxt, subst: subst, if args_mention(d.node.args, find_in_subst_bool, subst) { let old_bit_num = d.node.bit_num; let newv = replace(subst, d); - alt find_instance_(newv, v) { + match find_instance_(newv, v) { some(d1) {vec::push(res, {from: old_bit_num, to: d1})} _ {} } @@ -696,7 +696,7 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str { for stuff.each |i| { rslt += ~" " + - alt i { + match i { carg_ident(p) { *p.ident } carg_base { ~"*" } carg_lit(_) { ~"~[lit]" } @@ -709,9 +709,9 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str { fn replace(subst: subst, d: pred_args) -> ~[constr_arg_general_<inst>] { let mut rslt: ~[constr_arg_general_<inst>] = ~[]; for d.node.args.each |c| { - alt c.node { + match c.node { carg_ident(p) { - alt find_in_subst(p.node, subst) { + match find_in_subst(p.node, subst) { some(newv) { vec::push(rslt, carg_ident(newv)); } _ { vec::push(rslt, c.node); } } @@ -736,7 +736,7 @@ fn for_constraints_mentioning(fcx: fn_ctxt, id: node_id, fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) -> def_id { - alt local_node_id_to_def(fcx, i) { + match local_node_id_to_def(fcx, i) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_upvar(nid, _, _)) { return local_def(nid); @@ -760,7 +760,7 @@ fn local_node_id_to_def(fcx: fn_ctxt, i: node_id) -> option<def> { } fn local_node_id_to_def_id(fcx: fn_ctxt, i: node_id) -> option<def_id> { - alt local_node_id_to_def(fcx, i) { + match local_node_id_to_def(fcx, i) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_binding(nid, _)) | some(def_upvar(nid, _, _)) { some(local_def(nid)) @@ -771,7 +771,7 @@ fn local_node_id_to_def_id(fcx: fn_ctxt, i: node_id) -> option<def_id> { fn local_node_id_to_local_def_id(fcx: fn_ctxt, i: node_id) -> option<node_id> { - alt local_node_id_to_def_id(fcx, i) { + match local_node_id_to_def_id(fcx, i) { some(did) { some(did.node) } _ { none } } @@ -798,7 +798,7 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate, target_post: poststate, dest: inst, src: inst, ty: oper_type) { let mut subst; - alt ty { + match ty { oper_swap { subst = ~[{from: dest, to: src}, {from: src, to: dest}]; } oper_assign_op { return; // Don't do any propagation @@ -863,7 +863,7 @@ fn args_mention<T>(args: ~[@constr_arg_use], s: ~[T]) -> bool { for args.each |a| { - alt a.node { + match a.node { carg_ident(p1) { if q(s, p1.node) { return true; } } _ { } } } @@ -875,7 +875,7 @@ fn use_var(fcx: fn_ctxt, v: node_id) { } fn op_to_oper_ty(io: init_op) -> oper_type { - alt io { init_move { oper_move } _ { oper_assign } } + match io { init_move { oper_move } _ { oper_assign } } } // default function visitor @@ -894,7 +894,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg], vec::push( actuals, @respan(a.span, - alt a.node { + match a.node { carg_base { carg_base } carg_ident(i) { if i < num_args { @@ -945,7 +945,7 @@ fn locals_to_bindings(tcx: ty::ctxt, locals: ~[@local]) -> ~[binding] { fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { let ty = ty::type_autoderef(fcx.ccx.tcx, ty::node_id_to_type(fcx.ccx.tcx, callee)); - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_fn({inputs: args, _}) { let mut modes = ~[]; for args.each |arg| { vec::push(modes, arg.mode); } @@ -961,7 +961,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] { do vec::map(callee_modes(fcx, callee)) |m| { - alt ty::resolved_mode(fcx.ccx.tcx, m) { + match ty::resolved_mode(fcx.ccx.tcx, m) { by_move { init_move } by_copy | by_ref | by_val | by_mutbl_ref { init_assign } } diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index c6f46ba3888..6379e8898f7 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -13,7 +13,7 @@ import dvec::{dvec, extensions}; type ctxt = {cs: @mut ~[sp_constr], tcx: ty::ctxt}; fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) { - alt e.node { + match e.node { expr_check(_, ch) { vec::push(*cx.cs, expr_to_constr(cx.tcx, ch)); } expr_if_check(ex, _, _) { vec::push(*cx.cs, expr_to_constr(cx.tcx, ex)); @@ -58,7 +58,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) -> constraint_to_str(tcx, c) + ~" |-> " + uint::str(next)); let {path: p, def_id: d_id, args: args} = c.node; - alt tbl.find(d_id) { + match tbl.find(d_id) { some(ct) { (*ct.descs).push(respan(c.span, {args: args, bit_num: next})); } diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 9315e69d289..6036db54432 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -36,7 +36,7 @@ fn find_pre_post_method(ccx: crate_ctxt, m: @method) { } fn find_pre_post_item(ccx: crate_ctxt, i: item) { - alt i.node { + match i.node { item_const(_, e) { // do nothing -- item_consts don't refer to local vars } @@ -100,9 +100,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, maybe_alt: option<@expr>, id: node_id, chck: if_ty) { find_pre_post_expr(fcx, antec); find_pre_post_block(fcx, conseq); - alt maybe_alt { + match maybe_alt { none { - alt chck { + match chck { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); gen(fcx, antec.id, c.node); @@ -135,7 +135,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, /* Be sure to set the bit for the check condition here, so that it's *not* set in the alternative. */ - alt chck { + match chck { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); gen(fcx, antec.id, c.node); @@ -162,9 +162,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id, new_var: node_id) { - alt node_id_to_def(fcx.ccx, new_var) { + match node_id_to_def(fcx.ccx, new_var) { some(d) { - alt d { + match d { def_local(nid, _) { find_pre_post_expr(fcx, rhs); let p = expr_pp(fcx.ccx, rhs); @@ -181,12 +181,12 @@ fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id, fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, ty: oper_type) { find_pre_post_expr(fcx, rhs); - alt lhs.node { + match lhs.node { expr_path(p) { let post = expr_postcond(fcx.ccx, parent); let tmp = post.clone(); - alt ty { + match ty { oper_move { if is_path(rhs) { forget_in_postcond(fcx, parent.id, rhs.id); } } @@ -201,13 +201,13 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, } gen_if_local(fcx, lhs, rhs, parent.id, lhs.id); - alt rhs.node { + match rhs.node { expr_path(p1) { let d = local_node_id_to_local_def_id(fcx, lhs.id); let d1 = local_node_id_to_local_def_id(fcx, rhs.id); - alt d { + match d { some(id) { - alt d1 { + match d1 { some(id1) { let instlhs = {ident: path_to_ident(p), node: id}; @@ -232,7 +232,7 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, fn forget_args_moved_in(fcx: fn_ctxt, parent: @expr, modes: ~[mode], operands: ~[@expr]) { do vec::iteri(modes) |i,mode| { - alt ty::resolved_mode(fcx.ccx.tcx, mode) { + match ty::resolved_mode(fcx.ccx.tcx, mode) { by_move { forget_in_postcond(fcx, parent.id, operands[i].id); } by_ref | by_val | by_mutbl_ref | by_copy { } } @@ -251,7 +251,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { fn do_rand_(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, e); } - alt e.node { + match e.node { expr_call(operator, operands, _) { /* copy */ @@ -270,7 +270,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { operands); /* if this is a failing call, its postcondition sets everything */ - alt controlflow_expr(fcx.ccx, operator) { + match controlflow_expr(fcx.ccx, operator) { noreturn { set_postcond_false(fcx.ccx, e.id); } _ { } } @@ -315,7 +315,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_rec(fields, maybe_base) { let mut es = field_exprs(fields); - alt maybe_base { none {/* no-op */ } some(b) { vec::push(es, b); } } + match maybe_base { none {/* no-op */ } some(b) { vec::push(es, b); } } find_pre_post_exprs(fcx, es, e.id); } expr_tup(elts) { find_pre_post_exprs(fcx, elts, e.id); } @@ -331,7 +331,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_lit(_) { clear_pp(expr_pp(fcx.ccx, e)); } expr_ret(maybe_val) { - alt maybe_val { + match maybe_val { none { clear_precond(fcx.ccx, e.id); set_postcond_false(fcx.ccx, e.id); @@ -391,7 +391,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { expr_alt(ex, alts, _) { find_pre_post_expr(fcx, ex); fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post { - alt an_alt.guard { + match an_alt.guard { some(e) { find_pre_post_expr(fcx, e); } _ {} } @@ -422,7 +422,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_fail(maybe_val) { let mut prestate; - alt maybe_val { + match maybe_val { none { prestate = empty_prestate(num_local_vars); } some(fail_val) { find_pre_post_expr(fcx, fail_val); @@ -453,13 +453,13 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { debug!{"stmt = %s", stmt_to_str(s)}; - alt s.node { + match s.node { stmt_decl(adecl, id) { - alt adecl.node { + match adecl.node { decl_local(alocals) { let prev_pp = empty_pre_post(num_constraints(fcx.enclosing)); for alocals.each |alocal| { - alt alocal.node.init { + match alocal.node.init { some(an_init) { /* LHS always becomes initialized, whether or not this is a move */ @@ -473,7 +473,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { copy_pre_post(fcx.ccx, id, an_init.expr); let mut p = none; - alt an_init.expr.node { + match an_init.expr.node { expr_path(_p) { p = some(_p); } _ { } } @@ -481,7 +481,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { do pat_bindings(fcx.ccx.tcx.def_map, alocal.node.pat) |p_id, _s, n| { let ident = path_to_ident(n); - alt p { + match p { some(p) { copy_in_postcond(fcx, id, {ident: ident, node: p_id}, @@ -557,7 +557,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) { let mut pps: ~[pre_and_post] = ~[]; for b.node.stmts.each |s| { vec::push(pps, stmt_pp(fcx.ccx, *s)); } - alt b.node.expr { + match b.node.expr { none {/* no-op */ } some(e) { vec::push(pps, expr_pp(fcx.ccx, e)); } } @@ -584,7 +584,7 @@ fn find_pre_post_fn(fcx: fn_ctxt, body: blk) { find_pre_post_block(fcx, body); // Treat the tail expression as a return statement - alt body.node.expr { + match body.node.expr { some(tailexpr) { set_postcond_false(fcx.ccx, tailexpr.id); } none {/* fallthrough */ } } diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index b134f3b71af..9c4191fc20a 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -15,9 +15,9 @@ import driver::session::session; import std::map::hashmap; fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) { - alt t { + match t { oper_move { - alt local_node_id_to_def(fcx, rhs_id) { + match local_node_id_to_def(fcx, rhs_id) { some(def_upvar(_, _, _)) { fcx.ccx.tcx.sess.span_err(sp, ~"tried to deinitialize a variable \ @@ -35,12 +35,12 @@ fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: @path, forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op)); let rhs_d_id = local_node_id_to_def_id(fcx, rhs_id); - alt rhs_d_id { + match rhs_d_id { some(rhsid) { // RHS is a local var let instrhs = {ident: path_to_ident(rhs_path), node: rhsid.node}; - alt destlhs { + match destlhs { local_dest(instlhs) { copy_in_poststate(fcx, post, instlhs, instrhs, op_to_oper_ty(init_op)); @@ -59,14 +59,14 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: ~[binding]) -> let mut changed = false; let mut post = pres.clone(); for bindings.each |b| { - alt b.rhs { + match b.rhs { some(an_init) { // an expression, with or without a destination changed |= find_pre_post_state_expr(fcx, post, an_init.expr) || changed; post = expr_poststate(fcx.ccx, an_init.expr).clone(); for b.lhs.each |d| { - alt an_init.expr.node { + match an_init.expr.node { expr_path(p) { handle_move_or_copy(fcx, post, p, an_init.expr.id, d, an_init.op); @@ -94,7 +94,7 @@ fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr, changed = set_prestate_ann(fcx.ccx, parent, pres) || changed; let post = expr_poststate(fcx.ccx, e).clone(); - alt c { + match c { none { } some(c1) { set_in_poststate_(bit_num(fcx, c1), post); } } @@ -115,7 +115,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, let post = expr_poststate(fcx.ccx, rhs).clone(); - alt lhs.node { + match lhs.node { expr_path(p) { // for termination, need to make sure intermediate changes don't set // changed flag @@ -123,7 +123,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, // for substitution purposes let tmp = post.clone(); - alt ty { + match ty { oper_move { if is_path(rhs) { forget_in_poststate(fcx, post, rhs.id); } forget_in_poststate(fcx, post, lhs.id); @@ -135,13 +135,13 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, _ { forget_in_poststate(fcx, post, lhs.id); } } - alt rhs.node { + match rhs.node { expr_path(p1) { let d = local_node_id_to_local_def_id(fcx, lhs.id); let d1 = local_node_id_to_local_def_id(fcx, rhs.id); - alt d { + match d { some(id) { - alt d1 { + match d1 { some(id1) { let instlhs = {ident: path_to_ident(p), node: id}; @@ -188,7 +188,7 @@ fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id, let rs = seq_states(fcx, pres, arg_bindings(ops, es)); let mut changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres); /* if this is a failing call, it sets everything as initialized */ - alt cf { + match cf { noreturn { let post = false_postcond(num_constraints(fcx.enclosing)); changed |= set_poststate_ann(fcx.ccx, id, post); @@ -205,9 +205,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, set_prestate_ann(fcx.ccx, id, pres) | find_pre_post_state_expr(fcx, pres, antec); - alt maybe_alt { + match maybe_alt { none { - alt chk { + match chk { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); let conseq_prestate = expr_poststate(fcx.ccx, antec).clone(); @@ -232,7 +232,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, altern); let mut conseq_prestate = expr_poststate(fcx.ccx, antec); - alt chk { + match chk { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); conseq_prestate = conseq_prestate.clone(); @@ -282,7 +282,7 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id, fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { let num_constrs = num_constraints(fcx.enclosing); - alt e.node { + match e.node { expr_new(p, _, v) { return find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure); } @@ -330,7 +330,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { init_assign), exs, return_val); - let base_pres = alt vec::last_opt(exs) { none { pres } + let base_pres = match vec::last_opt(exs) { none { pres } some(f) { expr_poststate(fcx.ccx, f) }}; option::iter(maybe_base, |base| { changed |= find_pre_post_state_expr(fcx, base_pres, base) | @@ -366,7 +366,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { set_poststate_ann(fcx.ccx, e.id, post); - alt maybe_ret_val { + match maybe_ret_val { none {/* do nothing */ } some(ret_val) { changed |= find_pre_post_state_expr(fcx, pres, ret_val); @@ -452,7 +452,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { if vec::len(alts) > 0u { a_post = false_postcond(num_constrs); for alts.each |an_alt| { - alt an_alt.guard { + match an_alt.guard { some(e) { changed |= find_pre_post_state_expr(fcx, e_post, e); } @@ -512,9 +512,9 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { debug!{"*prestate = %s", stmt_ann.states.prestate.to_str()}; debug!{"*poststate = %s", stmt_ann.states.prestate.to_str()}; - alt s.node { + match s.node { stmt_decl(adecl, id) { - alt adecl.node { + match adecl.node { decl_local(alocals) { set_prestate(stmt_ann, pres); let c_and_p = seq_states(fcx, pres, @@ -574,7 +574,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool { pres = stmt_poststate(fcx.ccx, *s); } let mut post = pres; - alt b.node.expr { + match b.node.expr { none { } some(e) { changed |= find_pre_post_state_expr(fcx, pres, e); diff --git a/src/rustc/middle/tstate/tritv.rs b/src/rustc/middle/tstate/tritv.rs index ee2cf2d7a14..b6110121171 100644 --- a/src/rustc/middle/tstate/tritv.rs +++ b/src/rustc/middle/tstate/tritv.rs @@ -57,7 +57,7 @@ class t { } pure fn set(i: uint, t: trit) -> bool { let old = self.get(i); - alt t { + match t { dont_care { self.uncertain.set(i, true); self.val.set(i, false); @@ -103,7 +103,7 @@ class t { let mut rslt: ~[uint] = ~[]; for uint::range(0, self.nbits) |i| { vec::push(rslt, - alt self.get(i) { + match self.get(i) { dont_care { 2 } ttrue { 1 } tfalse { 0 } @@ -116,7 +116,7 @@ class t { let mut rs: str = ""; for uint::range(0, self.nbits) |i| { rs += - alt self.get(i) { + match self.get(i) { dont_care { "?" } ttrue { "1" } tfalse { "0" } @@ -177,10 +177,10 @@ fn minus(a: trit, b: trit) -> trit { 0 - 1 is an error 0 - anything else - 0 */ - alt a { + match a { dont_care { dont_care } ttrue { - alt b { + match b { ttrue { dont_care } tfalse { ttrue } /* internally contradictory, but @@ -191,7 +191,7 @@ fn minus(a: trit, b: trit) -> trit { } } tfalse { - alt b { + match b { ttrue { tfalse } /* see above comment */ _ { @@ -203,11 +203,11 @@ fn minus(a: trit, b: trit) -> trit { } fn trit_or(a: trit, b: trit) -> trit { - alt a { + match a { dont_care { b } ttrue { ttrue } tfalse { - alt b { + match b { ttrue { dont_care } /* FIXME (#2538): ?????? Again, unit tests would help here @@ -226,11 +226,11 @@ fn trit_or(a: trit, b: trit) -> trit { // to make it so that all constraints start out in a 0 state // (we consider a constraint false until proven true), too. fn trit_and(a: trit, b: trit) -> trit { - alt a { + match a { dont_care { b } // also seems wrong for case b = ttrue ttrue { - alt b { + match b { dont_care { ttrue } // ??? Seems wrong ttrue { diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 210c4c9af86..814e0cc2f15 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -510,7 +510,7 @@ impl of purity_to_str for purity { fn param_bounds_to_kind(bounds: param_bounds) -> kind { let mut kind = kind_noncopyable(); for vec::each(*bounds) |bound| { - alt bound { + match bound { bound_copy => { kind = raise_kind(kind, kind_implicitly_copyable()); } @@ -608,14 +608,14 @@ fn mk_t(cx: ctxt, st: sty) -> t { mk_t_with_id(cx, st, none) } // and returns the box as cast to an unsafe ptr (see comments for t above). fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t { let key = {struct: st, o_def_id: o_def_id}; - alt cx.interner.find(key) { + match cx.interner.find(key) { some(t) => unsafe { return unsafe::reinterpret_cast(t); } _ => () } let mut flags = 0u; fn rflags(r: region) -> uint { (has_regions as uint) | { - alt r { + match r { ty::re_var(_) => needs_infer as uint, _ => 0u } @@ -627,7 +627,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t { substs.self_r.iter(|r| f |= rflags(r)); return f; } - alt st { + match st { ty_estr(vstore_slice(r)) => { flags |= rflags(r); } @@ -786,7 +786,7 @@ fn mk_with_id(cx: ctxt, base: t, def_id: ast::def_id) -> t { // Converts s to its machine type equivalent pure fn mach_sty(cfg: @session::config, t: t) -> sty { - alt get(t).struct { + match get(t).struct { ty_int(ast::ty_i) => ty_int(cfg.int_type), ty_uint(ast::ty_u) => ty_uint(cfg.uint_type), ty_float(ast::ty_f) => ty_float(cfg.float_type), @@ -802,7 +802,7 @@ fn default_arg_mode_for_ty(ty: ty::t) -> ast::rmode { // Returns the narrowest lifetime enclosing the evaluation of the expression // with id `id`. fn encl_region(cx: ctxt, id: ast::node_id) -> ty::region { - alt cx.region_map.find(id) { + match cx.region_map.find(id) { some(encl_scope) => ty::re_scope(encl_scope), none => ty::re_static } @@ -814,7 +814,7 @@ fn walk_ty(ty: t, f: fn(t)) { fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { if !f(ty) { return; } - alt get(ty).struct { + match get(ty).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_self | ty_opaque_closure_ptr(_) | ty_var(_) | ty_var_integral(_) | @@ -851,7 +851,7 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty { tps: substs.tps.map(|t| fldop(t))} } - alt sty { + match sty { ty_box(tm) => { ty_box({ty: fldop(tm.ty), mutbl: tm.mutbl}) } @@ -947,7 +947,7 @@ fn fold_regions_and_ty( } let tb = ty::get(ty); - alt tb.struct { + match tb.struct { ty::ty_rptr(r, mt) => { let m_r = fldr(r); let m_t = fldt(mt.ty); @@ -1004,7 +1004,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t { fldop: fn(region, bool) -> region) -> t { let tb = get(t0); if !tbox_has_flag(tb, has_regions) { return t0; } - alt tb.struct { + match tb.struct { ty_rptr(r, {ty: t1, mutbl: m}) => { let m_r = fldop(r, under_r); let m_t1 = do_fold(cx, t1, true, fldop); @@ -1039,7 +1039,7 @@ fn subst_tps(cx: ctxt, tps: ~[t], typ: t) -> t { if tps.len() == 0u { return typ; } let tb = ty::get(typ); if !tbox_has_flag(tb, has_params) { return typ; } - alt tb.struct { + match tb.struct { ty_param(p) => tps[p.idx], sty => fold_sty_to_ty(cx, sty, |t| subst_tps(cx, tps, t)) } @@ -1076,13 +1076,13 @@ fn subst(cx: ctxt, typ: t) -> t { let tb = get(typ); if !tbox_has_flag(tb, needs_subst) { return typ; } - alt tb.struct { + match tb.struct { ty_param(p) => substs.tps[p.idx], ty_self => substs.self_ty.get(), _ => { fold_regions_and_ty( cx, typ, - |r| alt r { + |r| match r { re_bound(br_self) => substs.self_r.get(), _ => r }, @@ -1100,14 +1100,14 @@ fn type_is_nil(ty: t) -> bool { get(ty).struct == ty_nil } fn type_is_bot(ty: t) -> bool { get(ty).struct == ty_bot } fn type_is_var(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_var(_) => true, _ => false } } fn type_is_var_integral(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_var_integral(_) => true, _ => false } @@ -1116,7 +1116,7 @@ fn type_is_var_integral(ty: t) -> bool { fn type_is_bool(ty: t) -> bool { get(ty).struct == ty_bool } fn type_is_structural(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_rec(_) | ty_class(*) | ty_tup(_) | ty_enum(*) | ty_fn(_) | ty_trait(*) | ty_evec(_, vstore_fixed(_)) | ty_estr(vstore_fixed(_)) | @@ -1131,21 +1131,21 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool { } fn type_is_sequence(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_estr(_) | ty_evec(_, _) => true, _ => false } } fn type_is_str(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_estr(_) => true, _ => false } } fn sequence_element_type(cx: ctxt, ty: t) -> t { - alt get(ty).struct { + match get(ty).struct { ty_estr(_) => return mk_mach_uint(cx, ast::ty_u8), ty_evec(mt, _) | ty_unboxed_vec(mt) => return mt.ty, _ => cx.sess.bug( @@ -1154,7 +1154,7 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t { } fn get_element_type(ty: t, i: uint) -> t { - alt get(ty).struct { + match get(ty).struct { ty_rec(flds) => return flds[i].mt.ty, ty_tup(ts) => return ts[i], _ => fail ~"get_element_type called on invalid type" @@ -1162,14 +1162,14 @@ fn get_element_type(ty: t, i: uint) -> t { } pure fn type_is_box(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_box(_) => return true, _ => return false } } pure fn type_is_boxed(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_box(_) | ty_opaque_box | ty_evec(_, vstore_box) | ty_estr(vstore_box) => true, _ => false @@ -1177,35 +1177,35 @@ pure fn type_is_boxed(ty: t) -> bool { } pure fn type_is_region_ptr(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_rptr(_, _) => true, _ => false } } pure fn type_is_slice(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) => true, _ => return false } } pure fn type_is_unique_box(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_uniq(_) => return true, _ => return false } } pure fn type_is_unsafe_ptr(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_ptr(_) => return true, _ => return false } } pure fn type_is_vec(ty: t) -> bool { - return alt get(ty).struct { + return match get(ty).struct { ty_evec(_, _) | ty_unboxed_vec(_) => true, ty_estr(_) => true, _ => false @@ -1213,7 +1213,7 @@ pure fn type_is_vec(ty: t) -> bool { } pure fn type_is_unique(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_uniq(_) => return true, ty_evec(_, vstore_uniq) => true, ty_estr(vstore_uniq) => true, @@ -1227,7 +1227,7 @@ pure fn type_is_unique(ty: t) -> bool { contents are abstract to rustc.) */ pure fn type_is_scalar(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_var_integral(_) | ty_type | ty_ptr(_) => true, _ => false @@ -1240,13 +1240,13 @@ fn type_is_immediate(ty: t) -> bool { } fn type_needs_drop(cx: ctxt, ty: t) -> bool { - alt cx.needs_drop_cache.find(ty) { + match cx.needs_drop_cache.find(ty) { some(result) => return result, none => {/* fall through */ } } let mut accum = false; - let result = alt get(ty).struct { + let result = match get(ty).struct { // scalar types ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_type | ty_ptr(_) | ty_rptr(_, _) | @@ -1286,7 +1286,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { accum } ty_fn(fty) => { - alt fty.proto { + match fty.proto { proto_bare | proto_block => false, _ => true } @@ -1303,7 +1303,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { // that only contain scalars and shared boxes can avoid unwind // cleanups. fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool { - alt cx.needs_unwind_cleanup_cache.find(ty) { + match cx.needs_unwind_cleanup_cache.find(ty) { some(result) => return result, none => () } @@ -1320,7 +1320,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, encountered_box: bool) -> bool { // Prevent infinite recursion - alt tycache.find(ty) { + match tycache.find(ty) { some(_) => return false, none => { tycache.insert(ty, ()); } } @@ -1329,7 +1329,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, let mut needs_unwind_cleanup = false; do maybe_walk_ty(ty) |ty| { let old_encountered_box = encountered_box; - let result = alt get(ty).struct { + let result = match get(ty).struct { ty_box(_) | ty_opaque_box => { encountered_box = true; true @@ -1528,7 +1528,7 @@ pure fn kind_is_owned(k: kind) -> bool { } fn proto_kind(p: proto) -> kind { - alt p { + match p { ast::proto_block => kind_noncopyable(), ast::proto_box => kind_safe_for_default_mode() | kind_owned(), ast::proto_uniq => kind_send_copy() | kind_owned(), @@ -1571,7 +1571,7 @@ fn test_kinds() { // This is used to prevent objects containing mutable state from being // implicitly copied and to compute whether things have const kind. fn mutability_kind(m: mutability) -> kind { - alt (m) { + match (m) { m_mutbl => remove_const(remove_implicit(kind_top())), m_const => remove_implicit(kind_top()), m_imm => kind_top() @@ -1583,7 +1583,7 @@ fn mutable_type_kind(cx: ctxt, ty: mt) -> kind { } fn type_kind(cx: ctxt, ty: t) -> kind { - alt cx.kind_cache.find(ty) { + match cx.kind_cache.find(ty) { some(result) => return result, none => {/* fall through */ } } @@ -1591,7 +1591,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { // Insert a default in case we loop back on self recursively. cx.kind_cache.insert(ty, kind_top()); - let mut result = alt get(ty).struct { + let mut result = match get(ty).struct { // Scalar and unique types are sendable, constant, and owned ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) => { @@ -1743,7 +1743,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { /// gives a rough estimate of how much space it takes to represent /// an instance of `ty`. Used for the mode transition. fn type_size(cx: ctxt, ty: t) -> uint { - alt get(ty).struct { + match get(ty).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) | ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) | @@ -1828,7 +1828,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_to_str(cx, r_ty), ty_to_str(cx, ty)}; - let r = alt get(ty).struct { + let r = match get(ty).struct { ty_nil | ty_bot | ty_bool | @@ -1919,7 +1919,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> let sty = get(ty).struct; debug!{"type_structurally_contains: %s", ty_to_str(cx, ty)}; if test(sty) { return true; } - alt sty { + match sty { ty_enum(did, substs) => { for vec::each(*enum_variants(cx, did)) |variant| { for variant.args.each |aty| { @@ -1960,7 +1960,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool { return type_structurally_contains(cx, ty, |sty| { - alt sty { + match sty { ty_uniq(_) | ty_evec(_, vstore_uniq) | ty_estr(vstore_uniq) => true, @@ -1970,14 +1970,14 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool { } fn type_is_integral(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_var_integral(_) | ty_int(_) | ty_uint(_) | ty_bool => true, _ => false } } fn type_is_fp(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_float(_) => true, _ => false } @@ -1988,7 +1988,7 @@ fn type_is_numeric(ty: t) -> bool { } fn type_is_signed(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_int(_) => true, _ => false } @@ -1998,7 +1998,7 @@ fn type_is_signed(ty: t) -> bool { // that the cycle collector might care about. fn type_is_pod(cx: ctxt, ty: t) -> bool { let mut result = true; - alt get(ty).struct { + match get(ty).struct { // Scalar types ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_type | ty_ptr(_) => result = true, @@ -2053,7 +2053,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { } fn type_is_enum(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_enum(_, _) => return true, _ => return false } @@ -2062,7 +2062,7 @@ fn type_is_enum(ty: t) -> bool { // Whether a type is enum like, that is a enum type with only nullary // constructors fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_enum(did, substs) => { let variants = enum_variants(cx, did); let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u); @@ -2073,7 +2073,7 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool { } fn type_param(ty: t) -> option<uint> { - alt get(ty).struct { + match get(ty).struct { ty_param(p) => return some(p.idx), _ => {/* fall through */ } } @@ -2088,7 +2088,7 @@ fn deref(cx: ctxt, t: t, expl: bool) -> option<mt> { deref_sty(cx, get(t).struct, expl) } fn deref_sty(cx: ctxt, sty: sty, expl: bool) -> option<mt> { - alt sty { + match sty { ty_rptr(_, mt) | ty_box(mt) | ty_uniq(mt) => { some(mt) } @@ -2114,7 +2114,7 @@ fn deref_sty(cx: ctxt, sty: sty, expl: bool) -> option<mt> { fn type_autoderef(cx: ctxt, t: t) -> t { let mut t = t; loop { - alt deref(cx, t, false) { + match deref(cx, t, false) { none => return t, some(mt) => t = mt.ty } @@ -2127,7 +2127,7 @@ fn index(cx: ctxt, t: t) -> option<mt> { } fn index_sty(cx: ctxt, sty: sty) -> option<mt> { - alt sty { + match sty { ty_evec(mt, _) => some(mt), ty_estr(_) => some({ty: mk_u8(cx), mutbl: ast::m_imm}), _ => none @@ -2135,7 +2135,7 @@ fn index_sty(cx: ctxt, sty: sty) -> option<mt> { } pure fn hash_bound_region(br: &bound_region) -> uint { - alt *br { // no idea if this is any good + match *br { // no idea if this is any good ty::br_self => 0u, ty::br_anon => 1u, ty::br_named(str) => str::hash(str), @@ -2163,7 +2163,7 @@ pure fn hash_type_structure(st: sty) -> uint { h } pure fn hash_region(r: ®ion) -> uint { - alt *r { // no idea if this is any good + match *r { // no idea if this is any good re_bound(br) => (hash_bound_region(&br)) << 2u | 0u, re_free(id, br) => ((id as uint) << 4u) | (hash_bound_region(&br)) << 2u | 1u, @@ -2176,10 +2176,10 @@ pure fn hash_type_structure(st: sty) -> uint { let h = hash_subtys(h, substs.tps); h + substs.self_r.map_default(0u, |r| hash_region(&r)) } - alt st { + match st { ty_nil => 0u, ty_bool => 1u, - ty_int(t) => alt t { + ty_int(t) => match t { ast::ty_i => 2u, ast::ty_char => 3u, ast::ty_i8 => 4u, @@ -2187,14 +2187,14 @@ pure fn hash_type_structure(st: sty) -> uint { ast::ty_i32 => 6u, ast::ty_i64 => 7u } - ty_uint(t) => alt t { + ty_uint(t) => match t { ast::ty_u => 8u, ast::ty_u8 => 9u, ast::ty_u16 => 10u, ast::ty_u32 => 11u, ast::ty_u64 => 12u } - ty_float(t) => alt t { + ty_float(t) => match t { ast::ty_f => 13u, ast::ty_f32 => 14u, ast::ty_f64 => 15u @@ -2246,7 +2246,7 @@ pure fn hash_type_structure(st: sty) -> uint { } fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { - alt smallintmap::find(*cx.node_types, id as uint) { + match smallintmap::find(*cx.node_types, id as uint) { some(t) => t, none => cx.sess.bug(fmt!{"node_id_to_type: unbound node ID %s", ast_map::node_id_to_str(cx.items, id)}) @@ -2254,7 +2254,7 @@ fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { } fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] { - alt cx.node_type_substs.find(id) { + match cx.node_type_substs.find(id) { none => return ~[], some(ts) => return ts } @@ -2266,35 +2266,35 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { // Type accessors for substructures of types fn ty_fn_args(fty: t) -> ~[arg] { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.inputs, _ => fail ~"ty_fn_args() called on non-fn type" } } fn ty_fn_proto(fty: t) -> ast::proto { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.proto, _ => fail ~"ty_fn_proto() called on non-fn type" } } pure fn ty_fn_ret(fty: t) -> t { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.output, _ => fail ~"ty_fn_ret() called on non-fn type" } } fn ty_fn_ret_style(fty: t) -> ast::ret_style { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.ret_style, _ => fail ~"ty_fn_ret_style() called on non-fn type" } } fn is_fn_ty(fty: t) -> bool { - alt get(fty).struct { + match get(fty).struct { ty_fn(_) => return true, _ => return false } @@ -2312,14 +2312,14 @@ fn is_pred_ty(fty: t) -> bool { } fn ty_var_id(typ: t) -> tv_vid { - alt get(typ).struct { + match get(typ).struct { ty_var(vid) => return vid, _ => { error!{"ty_var_id called on non-var ty"}; fail; } } } fn ty_var_integral_id(typ: t) -> tvi_vid { - alt get(typ).struct { + match get(typ).struct { ty_var_integral(vid) => return vid, _ => { error!{"ty_var_integral_id called on ty other than \ ty_var_integral"}; @@ -2361,7 +2361,7 @@ fn expr_has_ty_params(cx: ctxt, expr: @ast::expr) -> bool { } fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool { - alt e.node { + match e.node { ast::expr_path(_) | ast::expr_unary(ast::deref, _) => true, ast::expr_field(_, _, _) | ast::expr_index(_, _) => { !method_map.contains_key(e.id) @@ -2371,7 +2371,7 @@ fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool { } fn stmt_node_id(s: @ast::stmt) -> ast::node_id { - alt s.node { + match s.node { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { return id; } @@ -2385,13 +2385,13 @@ fn field_idx(id: ast::ident, fields: ~[field]) -> option<uint> { } fn get_field(rec_ty: t, id: ast::ident) -> field { - alt check vec::find(get_fields(rec_ty), |f| str::eq(f.ident, id)) { + match check vec::find(get_fields(rec_ty), |f| str::eq(f.ident, id)) { some(f) => f } } fn get_fields(rec_ty:t) -> ~[field] { - alt check get(rec_ty).struct { + match check get(rec_ty).struct { ty_rec(fields) => fields } } @@ -2408,7 +2408,7 @@ fn method_idx(id: ast::ident, meths: ~[method]) -> option<uint> { fn param_tys_in_type(ty: t) -> ~[param_ty] { let mut rslt = ~[]; do walk_ty(ty) |ty| { - alt get(ty).struct { + match get(ty).struct { ty_param(p) => { vec::push(rslt, p); } @@ -2425,7 +2425,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { fn vars_in_type(ty: t) -> ~[tv_vid] { let mut rslt = ~[]; do walk_ty(ty) |ty| { - alt get(ty).struct { + match get(ty).struct { ty_var(v) => vec::push(rslt, v), _ => () } @@ -2454,8 +2454,8 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { // the current head value for `m0`. fn canon<T:copy>(tbl: hashmap<ast::node_id, ast::inferable<T>>, m0: ast::inferable<T>) -> ast::inferable<T> { - alt m0 { - ast::infer(id) => alt tbl.find(id) { + match m0 { + ast::infer(id) => match tbl.find(id) { none => m0, some(m1) => { let cm1 = canon(tbl, m1); @@ -2477,7 +2477,7 @@ fn canon_mode(cx: ctxt, m0: ast::mode) -> ast::mode { // Returns the head value for mode, failing if `m` was a infer(_) that // was never inferred. This should be safe for use after typeck. fn resolved_mode(cx: ctxt, m: ast::mode) -> ast::rmode { - alt canon_mode(cx, m) { + match canon_mode(cx, m) { ast::infer(_) => { cx.sess.bug(fmt!{"mode %? was never resolved", m}); } @@ -2490,7 +2490,7 @@ fn arg_mode(cx: ctxt, a: arg) -> ast::rmode { resolved_mode(cx, a.mode) } // Unifies `m1` and `m2`. Returns unified value or failure code. fn unify_mode(cx: ctxt, m1: ast::mode, m2: ast::mode) -> result<ast::mode, type_err> { - alt (canon_mode(cx, m1), canon_mode(cx, m2)) { + match (canon_mode(cx, m1), canon_mode(cx, m2)) { (m1, m2) if (m1 == m2) => { result::ok(m1) } @@ -2511,7 +2511,7 @@ fn unify_mode(cx: ctxt, m1: ast::mode, m2: ast::mode) // If `m` was never unified, unifies it with `m_def`. Returns the final value // for `m`. fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { - alt canon_mode(cx, m) { + match canon_mode(cx, m) { ast::infer(id) => { cx.inferred_modes.insert(id, ast::expl(m_def)); } @@ -2520,7 +2520,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { } fn ty_sort_str(cx: ctxt, t: t) -> ~str { - alt get(t).struct { + match get(t).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_opaque_closure_ptr(_) => { @@ -2548,14 +2548,14 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str { fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str { - alt k { terr_vec => ~"[]", terr_str => ~"str" } + match k { terr_vec => ~"[]", terr_str => ~"str" } } - alt err { + match err { terr_mismatch => return ~"types differ", terr_ret_style_mismatch(expect, actual) => { fn to_str(s: ast::ret_style) -> ~str { - alt s { + match s { ast::noreturn => ~"non-returning", ast::return_val => ~"return-by-value" } @@ -2631,7 +2631,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { } fn def_has_ty_params(def: ast::def) -> bool { - alt def { + match def { ast::def_fn(_, _) | ast::def_variant(_, _) | ast::def_class(_, _) => true, _ => false @@ -2643,7 +2643,7 @@ fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) { } fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { - alt cx.trait_method_cache.find(id) { + match cx.trait_method_cache.find(id) { some(ms) => return ms, _ => () } @@ -2657,7 +2657,7 @@ fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { if id.crate == ast::local_crate { debug!{"(impl_traits) searching for trait impl %?", id}; - alt cx.items.find(id.node) { + match cx.items.find(id.node) { some(ast_map::node_item(@{ node: ast::item_impl(_, trait_refs, _, _), _}, @@ -2669,7 +2669,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { } some(ast_map::node_item(@{node: ast::item_class(*), _},_)) => { - alt cx.def_map.find(id.node) { + match cx.def_map.find(id.node) { some(def_ty(trait_id)) => { // XXX: Doesn't work cross-crate. debug!{"(impl_traits) found trait id %?", trait_id}; @@ -2692,7 +2692,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { } fn ty_to_def_id(ty: t) -> option<ast::def_id> { - alt get(ty).struct { + match get(ty).struct { ty_trait(id, _) | ty_class(id, _) | ty_enum(id, _) => some(id), _ => none } @@ -2723,7 +2723,7 @@ fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str { Otherwise return none. */ fn ty_dtor(cx: ctxt, class_id: def_id) -> option<def_id> { if is_local(class_id) { - alt cx.items.find(class_id.node) { + match cx.items.find(class_id.node) { some(ast_map::node_item(@{node: ast::item_class(_, _, _, _, some(dtor)), _}, _)) => some(local_def(dtor.node.id)), @@ -2744,9 +2744,9 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { csearch::get_item_path(cx, id) } else { let node = cx.items.get(id.node); - alt node { + match node { ast_map::node_item(item, path) => { - let item_elt = alt item.node { + let item_elt = match item.node { item_mod(_) | item_foreign_mod(_) => { ast_map::path_mod(item.ident) } @@ -2796,14 +2796,14 @@ fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool { } fn type_is_empty(cx: ctxt, t: t) -> bool { - alt ty::get(t).struct { + match ty::get(t).struct { ty_enum(did, _) => (*enum_variants(cx, did)).is_empty(), _ => false } } fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { - alt cx.enum_var_cache.find(id) { + match cx.enum_var_cache.find(id) { some(variants) => return variants, _ => { /* fallthrough */ } } @@ -2816,7 +2816,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { call eval_const_expr, it should never get called twice for the same expr, since check_enum_variants also updates the enum_var_cache */ - alt cx.items.get(id.node) { + match cx.items.get(id.node) { ast_map::node_item(@{node: ast::item_enum(variants, _), _}, _) => { let mut disr_val = -1; @vec::map(variants, |variant| { @@ -2826,10 +2826,10 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { ty_fn_args(ctor_ty).map(|a| a.ty) } else { ~[] } }; - alt variant.node.disr_expr { + match variant.node.disr_expr { some (ex) => { // FIXME: issue #1417 - disr_val = alt const_eval::eval_const_expr(cx, ex) { + disr_val = match const_eval::eval_const_expr(cx, ex) { const_eval::const_int(val) =>val as int, _ => cx.sess.bug(~"tag_variants: bad disr expr") } @@ -2869,7 +2869,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id, // If the given item is in an external crate, looks up its type and adds it to // the type cache. Returns the type parameters and type. fn lookup_item_type(cx: ctxt, did: ast::def_id) -> ty_param_bounds_and_ty { - alt cx.tcache.find(did) { + match cx.tcache.find(did) { some(tpt) => return tpt, none => { // The item is in this crate. The caller should have added it to the @@ -2891,7 +2891,7 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id, node_id_to_type(tcx, id.node) } else { - alt tcx.tcache.find(id) { + match tcx.tcache.find(id) { some(tpt) => tpt.ty, none => { let tpt = csearch::get_field_type(tcx, class_id, id); @@ -2907,9 +2907,9 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id, // Fails if the id is not bound to a class. fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { if did.crate == ast::local_crate { - alt cx.items.find(did.node) { + match cx.items.find(did.node) { some(ast_map::node_item(i,_)) => { - alt i.node { + match i.node { ast::item_class(_, _, items, _, _) => { class_field_tys(items) } @@ -2929,7 +2929,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id) -> field_ty { - alt vec::find(lookup_class_fields(cx, parent), + match vec::find(lookup_class_fields(cx, parent), |f| f.id.node == field_id.node) { some(t) => t, none => cx.sess.bug(~"class ID not found in parent's fields") @@ -2962,7 +2962,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, -> ~[{name: ident, id: node_id, vis: visibility}] { assert is_local(did); - alt cx.items.find(did.node) { + match cx.items.find(did.node) { some(ast_map::node_item(@{ node: item_class(_,_,items,_,_), _ }, _)) => { @@ -2994,7 +2994,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, fn class_field_tys(items: ~[@class_member]) -> ~[field_ty] { let mut rslt = ~[]; for items.each |it| { - alt it.node { + match it.node { instance_var(nm, _, cm, id, vis) => { vec::push(rslt, {ident: nm, id: ast_util::local_def(id), vis: vis, mutability: cm}); @@ -3020,7 +3020,7 @@ fn class_items_as_mutable_fields(cx:ctxt, did: ast::def_id, // mutability. fn class_items_as_fields(cx:ctxt, did: ast::def_id, substs: substs) -> ~[field] { - class_item_fields(cx, did, substs, |mt| alt mt { + class_item_fields(cx, did, substs, |mt| match mt { class_mutable => m_mutbl, class_immutable => m_imm }) } @@ -3058,7 +3058,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { const opcat_logic: int = 7; fn opcat(op: ast::binop) -> int { - alt op { + match op { ast::add => opcat_add, ast::subtract => opcat_sub, ast::mul => opcat_mult, @@ -3081,7 +3081,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { } fn tycat(ty: t) -> int { - alt get(ty).struct { + match get(ty).struct { ty_bool => tycat_bool, ty_int(_) | ty_uint(_) | ty_var_integral(_) => tycat_int, ty_float(_) => tycat_float, @@ -3126,7 +3126,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t { } } - alt cx.normalized_cache.find(t) { + match cx.normalized_cache.find(t) { some(t) => return t, none => () } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index a0c1d1da02f..e96fe4e8679 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -180,7 +180,7 @@ fn write_substs_to_tcx(tcx: ty::ctxt, } fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def { - alt tcx.def_map.find(id) { + match tcx.def_map.find(id) { some(x) => x, _ => { tcx.sess.span_fatal(sp, ~"internal error looking up a definition") @@ -205,7 +205,7 @@ fn require_same_types( msg: fn() -> ~str) -> bool { let l_tcx, l_infcx; - alt maybe_infcx { + match maybe_infcx { none => { l_tcx = tcx; l_infcx = infer::new_infer_ctxt(tcx); @@ -216,7 +216,7 @@ fn require_same_types( } } - alt infer::mk_eqty(l_infcx, t1, t2) { + match infer::mk_eqty(l_infcx, t1, t2) { result::ok(()) => true, result::err(terr) => { l_tcx.sess.span_err(span, msg() + ~": " + @@ -227,10 +227,10 @@ fn require_same_types( } fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool { - alt ty::get(a.ty).struct { + match ty::get(a.ty).struct { ty::ty_evec(mt, vstore_uniq) => { if mt.mutbl != ast::m_imm { return false; } - alt ty::get(mt.ty).struct { + match ty::get(mt.ty).struct { ty::ty_estr(vstore_uniq) => return true, _ => return false } @@ -245,12 +245,12 @@ fn check_main_fn_ty(ccx: @crate_ctxt, let tcx = ccx.tcx; let main_t = ty::node_id_to_type(tcx, main_id); - alt ty::get(main_t).struct { + match ty::get(main_t).struct { ty::ty_fn({purity: ast::impure_fn, proto: ast::proto_bare, inputs, output, ret_style: ast::return_val}) => { - alt tcx.items.find(main_id) { + match tcx.items.find(main_id) { some(ast_map::node_item(it,_)) => { - alt it.node { + match it.node { ast::item_fn(_,ps,_) if vec::is_not_empty(ps) => { tcx.sess.span_err(main_span, ~"main function is not allowed to have type parameters"); @@ -284,7 +284,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt, fn check_for_main_fn(ccx: @crate_ctxt) { let tcx = ccx.tcx; if !tcx.sess.building_library { - alt copy tcx.sess.main_fn { + match copy tcx.sess.main_fn { some((id, sp)) => check_main_fn_ty(ccx, id, sp), none => tcx.sess.err(~"main function not found") } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index 1211c5aa8d6..fffc70e9525 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -59,7 +59,7 @@ fn get_region_reporting_err(tcx: ty::ctxt, span: span, res: result<ty::region, ~str>) -> ty::region { - alt res { + match res { result::ok(r) => r, result::err(e) => { tcx.sess.span_err(span, e); @@ -71,7 +71,7 @@ fn get_region_reporting_err(tcx: ty::ctxt, fn ast_region_to_region<AC: ast_conv, RS: region_scope copy owned>( self: AC, rscope: RS, span: span, a_r: @ast::region) -> ty::region { - let res = alt a_r.node { + let res = match a_r.node { ast::re_anon => rscope.anon_region(), ast::re_named(id) => rscope.named_region(id) }; @@ -93,7 +93,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>( // If the type is parameterized by the self region, then replace self // region with the current anon region binding (in other words, // whatever & would get replaced with). - let self_r = alt (decl_rp, path.rp) { + let self_r = match (decl_rp, path.rp) { (false, none) => { none } @@ -168,14 +168,14 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( let tcx = self.tcx(); - alt a_seq_ty.ty.node { + match a_seq_ty.ty.node { // to convert to an e{vec,str}, there can't be a mutability argument _ if a_seq_ty.mutbl != ast::m_imm => (), ast::ty_vec(mt) => { return ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst); } ast::ty_path(path, id) => { - alt tcx.def_map.find(id) { + match tcx.def_map.find(id) { some(ast::def_prim_ty(ast::ty_str)) => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); return ty::mk_estr(tcx, vst); @@ -212,7 +212,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( let tcx = self.tcx(); - alt tcx.ast_ty_to_ty_cache.find(ast_ty) { + match tcx.ast_ty_to_ty_cache.find(ast_ty) { some(ty::atttce_resolved(ty)) => return ty, some(ty::atttce_unresolved) => { tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ @@ -223,7 +223,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( } tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_unresolved); - let typ = alt ast_ty.node { + let typ = match ast_ty.node { ast::ty_nil => ty::mk_nil(tcx), ast::ty_bot => ty::mk_bot(tcx), ast::ty_box(mt) => { @@ -265,17 +265,17 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( ty::mk_fn(tcx, ty_of_fn_decl(self, rscope, proto, decl, none)) } ast::ty_path(path, id) => { - let a_def = alt tcx.def_map.find(id) { + let a_def = match tcx.def_map.find(id) { none => tcx.sess.span_fatal(ast_ty.span, fmt!{"unbound path %s", path_to_str(path)}), some(d) => d }; - alt a_def { + match a_def { ast::def_ty(did) | ast::def_class(did, _) => { ast_path_to_ty(self, rscope, did, path, id).ty } ast::def_prim_ty(nty) => { - alt nty { + match nty { ast::ty_bool => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_bool(tcx) @@ -356,20 +356,20 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>( self: AC, rscope: RS, a: ast::arg, expected_ty: option<ty::arg>) -> ty::arg { - let ty = alt a.ty.node { + let ty = match a.ty.node { ast::ty_infer if expected_ty.is_some() => expected_ty.get().ty, ast::ty_infer => self.ty_infer(a.ty.span), _ => ast_ty_to_ty(self, rscope, a.ty) }; let mode = { - alt a.mode { + match a.mode { ast::infer(_) if expected_ty.is_some() => { result::get(ty::unify_mode(self.tcx(), a.mode, expected_ty.get().mode)) } ast::infer(_) => { - alt ty::get(ty).struct { + match ty::get(ty).struct { // If the type is not specified, then this must be a fn expr. // Leave the mode as infer(_), it will get inferred based // on constraints elsewhere. @@ -417,7 +417,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy owned>( }; let expected_ret_ty = expected_tys.map(|e| e.output); - let output_ty = alt decl.output.node { + let output_ty = match decl.output.node { ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(), ast::ty_infer => self.ty_infer(decl.output.span), _ => ast_ty_to_ty(self, rb, decl.output) diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index c875ac8c386..efe728f9e12 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -177,7 +177,7 @@ fn check_bare_fn(ccx: @crate_ctxt, id: ast::node_id, self_info: option<self_info>) { let fty = ty::node_id_to_type(ccx.tcx, id); - let fn_ty = alt check ty::get(fty).struct { ty::ty_fn(f) => f }; + let fn_ty = match check ty::get(fty).struct { ty::ty_fn(f) => f }; check_fn(ccx, self_info, fn_ty, decl, body, false, none); } @@ -216,7 +216,7 @@ fn check_fn(ccx: @crate_ctxt, // in the case of function expressions, based on the outer context. let fcx: @fn_ctxt = { let {infcx, locals, purity, node_types, node_type_substs} = - alt old_fcx { + match old_fcx { none => { {infcx: infer::new_infer_ctxt(tcx), locals: int_hash(), @@ -236,7 +236,7 @@ fn check_fn(ccx: @crate_ctxt, let indirect_ret_ty = if indirect_ret { let ofcx = option::get(old_fcx); - alt ofcx.indirect_ret_ty { + match ofcx.indirect_ret_ty { some(t) => some(t), none => some(ofcx.ret_ty) } @@ -260,7 +260,7 @@ fn check_fn(ccx: @crate_ctxt, // We unify the tail expr's type with the // function result type, if there is a tail expr. - alt body.node.expr { + match body.node.expr { some(tail_expr) => { let tail_expr_ty = fcx.expr_ty(tail_expr); demand::suptype(fcx, tail_expr.span, fcx.ret_ty, tail_expr_ty); @@ -293,7 +293,7 @@ fn check_fn(ccx: @crate_ctxt, let assign = fn@(nid: ast::node_id, ty_opt: option<ty::t>) { let var_id = fcx.infcx.next_ty_var_id(); fcx.locals.insert(nid, var_id); - alt ty_opt { + match ty_opt { none => {/* nothing to do */ } some(typ) => { infer::mk_eqty(fcx.infcx, ty::mk_var(tcx, var_id), typ); @@ -311,7 +311,7 @@ fn check_fn(ccx: @crate_ctxt, // Add explicitly-declared locals. let visit_local = fn@(local: @ast::local, &&e: (), v: visit::vt<()>) { - let o_ty = alt local.node.ty.node { + let o_ty = match local.node.ty.node { ast::ty_infer => none, _ => some(fcx.to_ty(local.node.ty)) }; @@ -324,7 +324,7 @@ fn check_fn(ccx: @crate_ctxt, // Add pattern bindings. let visit_pat = fn@(p: @ast::pat, &&e: (), v: visit::vt<()>) { - alt p.node { + match p.node { ast::pat_ident(_, path, _) if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) => { assign(p.id, none); @@ -371,7 +371,7 @@ fn check_method(ccx: @crate_ctxt, method: @ast::method, fn check_class_member(ccx: @crate_ctxt, class_t: self_info, cm: @ast::class_member) { - alt cm.node { + match cm.node { ast::instance_var(_,t,_,_,_) => (), ast::class_method(m) => check_method(ccx, m, class_t) } @@ -383,7 +383,7 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields: |x,y| str::eq(*x, *y)); for fields.each |p| { let (id, sp) = p; - alt field_names.find(id) { + match field_names.find(id) { some(orig_sp) => { tcx.sess.span_err(sp, fmt!{"Duplicate field \ name %s in record type declaration", @@ -401,7 +401,7 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields: } fn check_item(ccx: @crate_ctxt, it: @ast::item) { - alt it.node { + match it.node { ast::item_const(_, e) => check_const(ccx, it.span, e, it.id), ast::item_enum(vs, _) => { check_enum_variants(ccx, it.span, vs, it.id); @@ -419,7 +419,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { } ast::item_trait(_, _, trait_methods) => { for trait_methods.each |trait_method| { - alt trait_method { + match trait_method { required(ty_m) => { // Nothing to do, since required methods don't have // bodies to check. @@ -471,7 +471,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id); check_bounds_are_used(ccx, t.span, tps, tpt_ty); // If this is a record ty, check for duplicate fields - alt t.node { + match t.node { ast::ty_rec(fields) => { check_no_duplicate_fields(ccx.tcx, fields.map(|f| (f.node.ident, f.span))); @@ -519,7 +519,7 @@ impl of region_scope for @fn_ctxt { } fn named_region(id: ast::ident) -> result<ty::region, ~str> { do empty_rscope.named_region(id).chain_err |_e| { - alt self.in_scope_regions.find(ty::br_named(id)) { + match self.in_scope_regions.find(ty::br_named(id)) { some(r) => result::ok(r), none if *id == ~"blk" => self.block_region(), none => { @@ -564,7 +564,7 @@ impl methods for @fn_ctxt { } fn expr_ty(ex: @ast::expr) -> ty::t { - alt self.node_types.find(ex.id) { + match self.node_types.find(ex.id) { some(t) => t, none => { self.tcx().sess.bug(fmt!{"no type for expr %d (%s) in fcx %s", @@ -573,7 +573,7 @@ impl methods for @fn_ctxt { } } fn node_ty(id: ast::node_id) -> ty::t { - alt self.node_types.find(id) { + match self.node_types.find(id) { some(t) => t, none => { self.tcx().sess.bug( @@ -584,7 +584,7 @@ impl methods for @fn_ctxt { } } fn node_ty_substs(id: ast::node_id) -> ty::substs { - alt self.node_type_substs.find(id) { + match self.node_type_substs.find(id) { some(ts) => ts, none => { self.tcx().sess.bug( @@ -637,7 +637,7 @@ impl methods for @fn_ctxt { } fn require_unsafe(sp: span, op: ~str) { - alt self.purity { + match self.purity { ast::unsafe_fn => {/*ok*/} _ => { self.ccx.tcx.sess.span_err( @@ -662,9 +662,9 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { let sty = structure_of(fcx, sp, t1); // Some extra checks to detect weird cycles and so forth: - alt sty { + match sty { ty::ty_box(inner) | ty::ty_uniq(inner) | ty::ty_rptr(_, inner) => { - alt ty::get(t1).struct { + match ty::get(t1).struct { ty::ty_var(v1) => { ty::occurs_check(fcx.ccx.tcx, sp, v1, ty::mk_box(fcx.ccx.tcx, inner)); @@ -687,7 +687,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { } // Otherwise, deref if type is derefable: - alt ty::deref_sty(fcx.ccx.tcx, sty, false) { + match ty::deref_sty(fcx.ccx.tcx, sty, false) { none => return t1, some(mt) => t1 = mt.ty } @@ -698,7 +698,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t { let tcx = fcx.ccx.tcx; - alt lit.node { + match lit.node { ast::lit_str(s) => ty::mk_estr(tcx, ty::vstore_slice(ty::re_static)), ast::lit_int(_, t) => ty::mk_mach_int(tcx, t), ast::lit_uint(_, t) => ty::mk_mach_uint(tcx, t), @@ -740,7 +740,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty { let {n_tps, rp, raw_ty} = if did.crate == ast::local_crate { let rp = fcx.tcx().region_paramd_items.contains_key(did.node); - alt check tcx.items.find(did.node) { + match check tcx.items.find(did.node) { some(ast_map::node_item(@{node: ast::item_impl(ts, _, st, _), _}, _)) => { {n_tps: ts.len(), @@ -818,7 +818,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // process the types bound by the function but not by any nested // functions. Therefore, we match one level of structure. let fn_ty = - alt structure_of(fcx, sp, in_fty) { + match structure_of(fcx, sp, in_fty) { sty @ ty::ty_fn(fn_ty) => { replace_bound_regions_in_fn_ty( fcx.ccx.tcx, @nil, none, fn_ty, @@ -872,7 +872,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // right way to do this. for [false, true]/_.each |check_blocks| { for args.eachi |i, a| { - let is_block = alt a.node { + let is_block = match a.node { ast::expr_fn_block(*) => true, _ => false }; @@ -905,7 +905,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // Index expressions need to be handled seperately, to inform // them that they appear in call position. - let mut bot = alt f.node { + let mut bot = match f.node { ast::expr_field(base, field, tys) => { check_field(fcx, f, true, base, field, tys) } @@ -922,7 +922,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }; // Pull the return type out of the type of the function. - alt structure_of(fcx, sp, fty) { + match structure_of(fcx, sp, fty) { ty::ty_fn(f) => { bot |= (f.ret_style == ast::noreturn); fcx.write_ty(call_expr_id, f.output); @@ -952,7 +952,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, elsopt: option<@ast::expr>, id: ast::node_id, _sp: span) -> bool { let (if_t, if_bot) = - alt elsopt { + match elsopt { some(els) => { let if_t = fcx.infcx.next_ty_var(); let thn_bot = check_block(fcx, thn); @@ -976,7 +976,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, -> option<(ty::t, bool)> { let lkup = method::lookup(fcx, op_ex, self_ex, op_ex.id, op_ex.callee_id, @opname, self_t, ~[], false); - alt lkup.method() { + match lkup.method() { some(origin) => { let {fty: method_ty, bot: bot} = { let method_ty = fcx.node_ty(op_ex.callee_id); @@ -998,7 +998,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let lhs_bot = check_expr(fcx, lhs, none); let lhs_t = fcx.expr_ty(lhs); let lhs_t = structurally_resolved_type(fcx, lhs.span, lhs_t); - return alt (op, ty::get(lhs_t).struct) { + return match (op, ty::get(lhs_t).struct) { (_, _) if ty::type_is_integral(lhs_t) && ast_util::is_shift_binop(op) => { // Shift is a special case: rhs can be any integral type @@ -1013,7 +1013,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let tvar = fcx.infcx.next_ty_var(); demand::suptype(fcx, expr.span, tvar, lhs_t); let rhs_bot = check_expr_with(fcx, rhs, tvar); - let rhs_t = alt op { + let rhs_t = match op { ast::eq | ast::lt | ast::le | ast::ne | ast::ge | ast::gt => { // these comparison operators are handled in a @@ -1042,9 +1042,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, lhs_expr: @ast::expr, lhs_resolved_t: ty::t, op: ast::binop, rhs: @ast::expr) -> (ty::t, bool) { let tcx = fcx.ccx.tcx; - alt ast_util::binop_to_method_name(op) { + match ast_util::binop_to_method_name(op) { some(name) => { - alt lookup_op_method(fcx, ex, + match lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t, name, ~[rhs]) { some(pair) => return pair, @@ -1064,7 +1064,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // If the or operator is used it might be that the user forgot to // supply the do keyword. Let's be more helpful in that situation. if op == ast::or { - alt ty::get(lhs_resolved_t).struct { + match ty::get(lhs_resolved_t).struct { ty::ty_fn(f) => { tcx.sess.span_note( ex.span, ~"did you forget the 'do' keyword for the call?"); @@ -1078,7 +1078,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn check_user_unop(fcx: @fn_ctxt, op_str: ~str, mname: ~str, ex: @ast::expr, rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t { - alt lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) { + match lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) { some((ret_ty, _)) => ret_ty, _ => { fcx.ccx.tcx.sess.span_err( @@ -1096,9 +1096,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn unpack_expected<O: copy>(fcx: @fn_ctxt, expected: option<ty::t>, unpack: fn(ty::sty) -> option<O>) -> option<O> { - alt expected { + match expected { some(t) => { - alt resolve_type(fcx.infcx, t, force_tvar) { + match resolve_type(fcx.infcx, t, force_tvar) { result::ok(t) => unpack(ty::get(t).struct), _ => none } @@ -1121,7 +1121,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // def'n of br_cap_avoid() for a more lengthy explanation of // what's going on here. let expected_tys = do unpack_expected(fcx, expected) |sty| { - alt sty { + match sty { ty::ty_fn(fn_ty) => { let {fn_ty, _} = replace_bound_regions_in_fn_ty( @@ -1160,9 +1160,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let base_t = do_autoderef(fcx, expr.span, expr_t); let mut handled = false; let n_tys = vec::len(tys); - alt structure_of(fcx, expr.span, base_t) { + match structure_of(fcx, expr.span, base_t) { ty::ty_rec(fields) => { - alt ty::field_idx(field, fields) { + match ty::field_idx(field, fields) { some(ix) => { if n_tys > 0u { tcx.sess.span_err(expr.span, @@ -1194,7 +1194,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, else { lookup_public_fields(tcx, base_id) }; - alt lookup_field_ty(tcx, base_id, cls_items, field, substs) { + match lookup_field_ty(tcx, base_id, cls_items, field, substs) { some(field_ty) => { // (2) look up what field's type is, and return it fcx.write_ty(expr.id, field_ty); @@ -1216,7 +1216,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let lkup = method::lookup(fcx, expr, base, borrow_lb, expr.id, field, expr_t, tps, is_self_ref); - alt lkup.method() { + match lkup.method() { some(entry) => { fcx.ccx.method_map.insert(expr.id, entry); @@ -1248,9 +1248,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let tcx = fcx.ccx.tcx; let id = expr.id; let mut bot = false; - alt expr.node { + match expr.node { ast::expr_vstore(ev, vst) => { - let typ = alt ev.node { + let typ = match ev.node { ast::expr_lit(@{node: ast::lit_str(s), span:_}) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst); ty::mk_estr(tcx, tt) @@ -1315,8 +1315,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ast::expr_unary(unop, oprnd) => { let exp_inner = do unpack_expected(fcx, expected) |sty| { - alt unop { - ast::box(_) | ast::uniq(_) => alt sty { + match unop { + ast::box(_) | ast::uniq(_) => match sty { ty::ty_box(mt) | ty::ty_uniq(mt) => some(mt.ty), _ => none } @@ -1326,7 +1326,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }; bot = check_expr(fcx, oprnd, exp_inner); let mut oprnd_t = fcx.expr_ty(oprnd); - alt unop { + match unop { ast::box(mutbl) => { oprnd_t = ty::mk_box(tcx, {ty: oprnd_t, mutbl: mutbl}); } @@ -1338,7 +1338,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // deref'ing an unsafe pointer requires that we be in an unsafe // context - alt sty { + match sty { ty::ty_ptr(*) => { fcx.require_unsafe( expr.span, @@ -1347,10 +1347,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, _ => { /*ok*/ } } - alt ty::deref_sty(tcx, sty, true) { + match ty::deref_sty(tcx, sty, true) { some(mt) => { oprnd_t = mt.ty } none => { - alt sty { + match sty { ty::ty_enum(*) => { tcx.sess.span_err( expr.span, @@ -1389,7 +1389,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ast::expr_addr_of(mutbl, oprnd) => { bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, |ty| - alt ty { ty::ty_rptr(_, mt) => some(mt.ty), _ => none } + match ty { ty::ty_rptr(_, mt) => some(mt.ty), _ => none } )); //let region = region_of(fcx, oprnd); let region = fcx.infcx.next_region_var_with_scope_lb(expr.id); @@ -1406,7 +1406,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_mac(_) => tcx.sess.bug(~"unexpanded macro"), ast::expr_fail(expr_opt) => { bot = true; - alt expr_opt { + match expr_opt { none => {/* do nothing */ } some(e) => { check_expr_with(fcx, e, @@ -1419,11 +1419,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_again => { fcx.write_bot(id); bot = true; } ast::expr_ret(expr_opt) => { bot = true; - let ret_ty = alt fcx.indirect_ret_ty { + let ret_ty = match fcx.indirect_ret_ty { some(t) => t, none => fcx.ret_ty }; - alt expr_opt { - none => alt fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) { + match expr_opt { + none => match fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) { result::ok(_) => { /* fall through */ } result::err(_) => { tcx.sess.span_err( @@ -1482,7 +1482,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_fn_block(decl, body, cap_clause) => { // Take the prototype from the expected type, but default to block: let proto = unpack_expected(fcx, expected, |sty| - alt sty { ty::ty_fn({proto, _}) => some(proto), _ => none } + match sty { ty::ty_fn({proto, _}) => some(proto), _ => none } ).get_default(ast::proto_box); check_expr_fn(fcx, expr, proto, decl, body, false, expected); capture::check_capture_clause(tcx, expr.id, cap_clause); @@ -1495,9 +1495,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // 1. a closure that returns a bool is expected // 2. the cloure that was given returns unit let expected_sty = unpack_expected(fcx, expected, |x| some(x)); - let (inner_ty, proto) = alt expected_sty { + let (inner_ty, proto) = match expected_sty { some(ty::ty_fn(fty)) => { - alt infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) { + match infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) { result::ok(_) => (), result::err(err) => { tcx.sess.span_fatal( @@ -1514,7 +1514,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, type"); } }; - alt check b.node { + match check b.node { ast::expr_fn_block(decl, body, cap_clause) => { check_expr_fn(fcx, b, proto, decl, body, true, some(inner_ty)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); @@ -1523,7 +1523,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } let block_ty = structurally_resolved_type( fcx, expr.span, fcx.node_ty(b.id)); - alt check ty::get(block_ty).struct { + match check ty::get(block_ty).struct { ty::ty_fn(fty) => { fcx.write_ty(expr.id, ty::mk_fn(tcx, {output: ty::mk_bool(tcx) with fty})); @@ -1532,7 +1532,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ast::expr_do_body(b) => { let expected_sty = unpack_expected(fcx, expected, |x| some(x)); - let (inner_ty, proto) = alt expected_sty { + let (inner_ty, proto) = match expected_sty { some(ty::ty_fn(fty)) => { (ty::mk_fn(tcx, fty), fty.proto) } @@ -1542,7 +1542,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, passed to a `do` function"); } }; - alt check b.node { + match check b.node { ast::expr_fn_block(decl, body, cap_clause) => { check_expr_fn(fcx, b, proto, decl, body, true, some(inner_ty)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); @@ -1551,7 +1551,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } let block_ty = structurally_resolved_type( fcx, expr.span, fcx.node_ty(b.id)); - alt check ty::get(block_ty).struct { + match check ty::get(block_ty).struct { ty::ty_fn(fty) => { fcx.write_ty(expr.id, ty::mk_fn(tcx, fty)); } @@ -1561,7 +1561,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // If this is an unchecked block, turn off purity-checking bot = check_block(fcx, b); let typ = - alt b.node.expr { + match b.node.expr { some(expr) => fcx.expr_ty(expr), none => ty::mk_nil(tcx) }; @@ -1578,7 +1578,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, debug!{"t_1=%s", fcx.infcx.ty_to_str(t_1)}; debug!{"t_e=%s", fcx.infcx.ty_to_str(t_e)}; - alt ty::get(t_1).struct { + match ty::get(t_1).struct { // This will be looked up later on ty::ty_trait(*) => (), @@ -1631,7 +1631,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let mut elt_ts = ~[]; vec::reserve(elt_ts, vec::len(elts)); let flds = unpack_expected(fcx, expected, |sty| { - alt sty { ty::ty_tup(flds) => some(flds), _ => none } + match sty { ty::ty_tup(flds) => some(flds), _ => none } }); for elts.eachi |i, e| { check_expr(fcx, e, flds.map(|fs| fs[i])); @@ -1647,7 +1647,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, some(fcx.expr_ty(base.get())) } else { expected }; let flds = unpack_expected(fcx, expected, |sty| - alt sty { ty::ty_rec(flds) => some(flds), _ => none } + match sty { ty::ty_rec(flds) => some(flds), _ => none } ); let fields_t = vec::map(fields, |f| { bot |= check_expr(fcx, f.node.expr, flds.chain(|flds| @@ -1659,7 +1659,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // should be f.node.expr.span, not f.span respan(f.node.expr.span, {ident: f.node.ident, mt: expr_mt}) }); - alt base { + match base { none => { fn get_node(f: spanned<field>) -> field { f.node } let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node)); @@ -1674,7 +1674,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } some(bexpr) => { let bexpr_t = fcx.expr_ty(bexpr); - let base_fields = alt structure_of(fcx, expr.span, bexpr_t) { + let base_fields = match structure_of(fcx, expr.span, bexpr_t) { ty::ty_rec(flds) => flds, _ => { tcx.sess.span_fatal(expr.span, @@ -1702,7 +1702,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_struct(path, fields, base_expr) => { // Resolve the path. let class_id; - alt tcx.def_map.find(id) { + match tcx.def_map.find(id) { some(ast::def_class(type_def_id, _)) => { class_id = type_def_id; } @@ -1718,7 +1718,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, if class_id.crate == ast::local_crate { region_parameterized = tcx.region_paramd_items.contains_key(class_id.node); - alt tcx.items.find(class_id.node) { + match tcx.items.find(class_id.node) { some(ast_map::node_item(@{ node: ast::item_class(type_parameters, _, _, _, _), _ @@ -1779,7 +1779,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // Typecheck each field. for fields.each |field| { - alt class_field_map.find(*field.node.ident) { + match class_field_map.find(*field.node.ident) { none => { tcx.sess.span_err(field.span, fmt!{"structure has no field named \ @@ -1848,7 +1848,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let base_t = do_autoderef(fcx, expr.span, raw_base_t); bot |= check_expr(fcx, idx, none); let idx_t = fcx.expr_ty(idx); - alt ty::index_sty(tcx, structure_of(fcx, expr.span, base_t)) { + match ty::index_sty(tcx, structure_of(fcx, expr.span, base_t)) { some(mt) => { require_integral(fcx, idx.span, idx_t); fcx.write_ty(id, mt.ty); @@ -1856,7 +1856,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, none => { let resolved = structurally_resolved_type(fcx, expr.span, raw_base_t); - alt lookup_op_method(fcx, expr, base, resolved, ~"index", + match lookup_op_method(fcx, expr, base, resolved, ~"index", ~[idx]) { some((ret_ty, _)) => fcx.write_ty(id, ret_ty), _ => { @@ -1874,7 +1874,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, debug!{"type of expr %s is %s, expected is %s", syntax::print::pprust::expr_to_str(expr), ty_to_str(tcx, fcx.expr_ty(expr)), - alt expected { + match expected { some(t) => ty_to_str(tcx, t), _ => ~"empty" }}; @@ -1904,7 +1904,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { let t = ty::mk_var(fcx.ccx.tcx, fcx.locals.get(local.node.id)); fcx.write_ty(local.node.id, t); - alt local.node.init { + match local.node.init { some(init) => { bot = check_decl_initializer(fcx, local.node.id, init); } @@ -1927,10 +1927,10 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool { let mut node_id; let mut bot = false; - alt stmt.node { + match stmt.node { ast::stmt_decl(decl, id) => { node_id = id; - alt decl.node { + match decl.node { ast::decl_local(ls) => for ls.each |l| { bot |= check_decl_local(fcx, l); } @@ -1961,7 +1961,7 @@ fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool { } fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { - let fcx = alt blk.node.rules { + let fcx = match blk.node.rules { ast::unchecked_blk => @fn_ctxt_({purity: ast::impure_fn with **fcx0}), ast::unsafe_blk => @fn_ctxt_({purity: ast::unsafe_fn with **fcx0}), ast::default_blk => fcx0 @@ -1971,7 +1971,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { let mut warned = false; for blk.node.stmts.each |s| { if bot && !warned && - alt s.node { + match s.node { ast::stmt_decl(@{node: ast::decl_local(_), _}, _) | ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => { true @@ -1983,7 +1983,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { } bot |= check_stmt(fcx, s); } - alt blk.node.expr { + match blk.node.expr { none => fcx.write_nil(blk.node.id), some(e) => { if bot && !warned { @@ -2044,7 +2044,7 @@ fn check_enum_variants(ccx: @crate_ctxt, let mut disr_val = 0; let mut variants = ~[]; for vs.each |v| { - alt v.node.disr_expr { + match v.node.disr_expr { some(e) => { let fcx = blank_fn_ctxt(ccx, rty, e.id); check_expr(fcx, e, none); @@ -2055,7 +2055,7 @@ fn check_enum_variants(ccx: @crate_ctxt, // Also, check_expr (from check_const pass) doesn't guarantee that // the expression in an form that eval_const_expr can handle, so // we may still get an internal compiler error - alt const_eval::eval_const_expr(ccx.tcx, e) { + match const_eval::eval_const_expr(ccx.tcx, e) { const_eval::const_int(val) => { disr_val = val as int; } @@ -2088,7 +2088,7 @@ fn check_enum_variants(ccx: @crate_ctxt, // Check that it is possible to represent this enum: let mut outer = true, did = local_def(id); if ty::type_structurally_contains(ccx.tcx, rty, |sty| { - alt sty { + match sty { ty::ty_enum(id, _) if id == did => { if outer { outer = false; false } else { true } @@ -2119,7 +2119,7 @@ fn self_ref(fcx: @fn_ctxt, id: ast::node_id) -> bool { } fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> tv_vid { - alt fcx.locals.find(id) { + match fcx.locals.find(id) { some(x) => x, _ => { fcx.ccx.tcx.sess.span_fatal(sp, @@ -2136,7 +2136,7 @@ fn lookup_def(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> ast::def { fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ty_param_bounds_and_ty { - alt defn { + match defn { ast::def_arg(nid, _) => { assert (fcx.locals.contains_key(nid)); let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid)); @@ -2148,7 +2148,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> return no_params(typ); } ast::def_self(_) => { - alt fcx.self_info { + match fcx.self_info { some(self_info) => { return no_params(self_info.self_ty); } @@ -2223,7 +2223,7 @@ fn instantiate_path(fcx: @fn_ctxt, // determine the region bound, using the value given by the user // (if any) and otherwise using a fresh region variable - let self_r = alt pth.rp { + let self_r = match pth.rp { some(r) if !tpt.rp => { fcx.ccx.tcx.sess.span_err (sp, ~"this item is not region-parameterized"); @@ -2267,7 +2267,7 @@ fn instantiate_path(fcx: @fn_ctxt, // Resolves `typ` by a single level if `typ` is a type variable. If no // resolution is possible, then an error is reported. fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t { - alt infer::resolve_type(fcx.infcx, tp, force_tvar) { + match infer::resolve_type(fcx.infcx, tp, force_tvar) { result::ok(t_s) if !ty::type_is_var(t_s) => return t_s, _ => { fcx.ccx.tcx.sess.span_fatal @@ -2298,7 +2298,7 @@ fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool { fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, v: ast::vstore) -> ty::vstore { - alt v { + match v { ast::vstore_fixed(none) => ty::vstore_fixed(n), ast::vstore_fixed(some(u)) => { if n != u { @@ -2309,7 +2309,7 @@ fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, } ast::vstore_uniq => ty::vstore_uniq, ast::vstore_box => ty::vstore_box, - ast::vstore_slice(a_r) => alt fcx.block_region() { + ast::vstore_slice(a_r) => match fcx.block_region() { result::ok(b_r) => { let rscope = in_anon_rscope(fcx, b_r); let r = astconv::ast_region_to_region(fcx, rscope, e.span, a_r); @@ -2335,7 +2335,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt, ccx.tcx, ty, |_r| {}, |t| { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_param({idx, _}) => { tps_used[idx] = true; } _ => () } @@ -2358,7 +2358,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { {mode: ast::expl(m), ty: ty} } let tcx = ccx.tcx; - let (n_tps, inputs, output) = alt *it.ident { + let (n_tps, inputs, output) = match *it.ident { ~"size_of" | ~"pref_align_of" | ~"min_align_of" => (1u, ~[], ty::mk_uint(ccx.tcx)), ~"init" => (1u, ~[], param(ccx, 0u)), diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index 316ef5a8927..2de26873316 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -29,7 +29,7 @@ fn check_alt(fcx: @fn_ctxt, let mut result_ty = fcx.infcx.next_ty_var(); let mut arm_non_bot = false; for arms.each |arm| { - alt arm.guard { + match arm.guard { some(e) => { check_expr_with(fcx, e, ty::mk_bool(tcx)); }, none => () } @@ -68,7 +68,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id); // Take the enum type params out of `expected`. - alt structure_of(pcx.fcx, pat.span, expected) { + match structure_of(pcx.fcx, pat.span, expected) { ty::ty_enum(_, expected_substs) => { // check that the type of the value being matched is a subtype // of the type of the pattern: @@ -82,7 +82,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, tcx, v_def_ids.enm, v_def_ids.var); vinfo.args.map(|t| { ty::subst(tcx, expected_substs, t) }) }; - let arg_len = arg_types.len(), subpats_len = alt subpats { + let arg_len = arg_types.len(), subpats_len = match subpats { none => arg_len, some(ps) => ps.len() }; @@ -127,7 +127,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; - alt pat.node { + match pat.node { ast::pat_wild => { fcx.write_ty(pat.id, expected); } @@ -167,7 +167,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { demand::suptype(fcx, pat.span, ct, typ); } fcx.write_ty(pat.id, typ); - alt sub { + match sub { some(p) => check_pat(pcx, p, expected), _ => () } @@ -179,7 +179,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { check_pat_variant(pcx, pat, path, subpats, expected); } ast::pat_rec(fields, etc) => { - let ex_fields = alt structure_of(fcx, pat.span, expected) { + let ex_fields = match structure_of(fcx, pat.span, expected) { ty::ty_rec(fields) => fields, _ => { tcx.sess.span_fatal @@ -201,7 +201,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { str::eq(name, f.ident) } for fields.each |f| { - alt vec::find(ex_fields, |a| matches(f.ident, a)) { + match vec::find(ex_fields, |a| matches(f.ident, a)) { some(field) => { check_pat(pcx, f.pat, field.mt.ty); } @@ -216,7 +216,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.write_ty(pat.id, expected); } ast::pat_tup(elts) => { - let ex_elts = alt structure_of(fcx, pat.span, expected) { + let ex_elts = match structure_of(fcx, pat.span, expected) { ty::ty_tup(elts) => elts, _ => { tcx.sess.span_fatal @@ -241,7 +241,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.write_ty(pat.id, expected); } ast::pat_box(inner) => { - alt structure_of(fcx, pat.span, expected) { + match structure_of(fcx, pat.span, expected) { ty::ty_box(e_inner) => { check_pat(pcx, inner, e_inner.ty); fcx.write_ty(pat.id, expected); @@ -256,7 +256,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } } ast::pat_uniq(inner) => { - alt structure_of(fcx, pat.span, expected) { + match structure_of(fcx, pat.span, expected) { ty::ty_uniq(e_inner) => { check_pat(pcx, inner, e_inner.ty); fcx.write_ty(pat.id, expected); diff --git a/src/rustc/middle/typeck/check/demand.rs b/src/rustc/middle/typeck/check/demand.rs index e1cf67e94e6..17f171bdf90 100644 --- a/src/rustc/middle/typeck/check/demand.rs +++ b/src/rustc/middle/typeck/check/demand.rs @@ -6,7 +6,7 @@ fn suptype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) { // n.b.: order of actual, expected is reversed - alt infer::mk_subty(fcx.infcx, actual, expected) { + match infer::mk_subty(fcx.infcx, actual, expected) { result::ok(()) => { /* ok */ } result::err(err) => { fcx.report_mismatched_types(sp, expected, actual, err); @@ -17,7 +17,7 @@ fn suptype(fcx: @fn_ctxt, sp: span, fn eqtype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) { - alt infer::mk_eqty(fcx.infcx, actual, expected) { + match infer::mk_eqty(fcx.infcx, actual, expected) { result::ok(()) => { /* ok */ } result::err(err) => { fcx.report_mismatched_types(sp, expected, actual, err); @@ -29,7 +29,7 @@ fn eqtype(fcx: @fn_ctxt, sp: span, fn assign(fcx: @fn_ctxt, sp: span, borrow_lb: ast::node_id, expected: ty::t, expr: @ast::expr) { let expr_ty = fcx.expr_ty(expr); - alt fcx.mk_assignty(expr, borrow_lb, expr_ty, expected) { + match fcx.mk_assignty(expr, borrow_lb, expr_ty, expected) { result::ok(()) => { /* ok */ } result::err(err) => { fcx.report_mismatched_types(sp, expected, expr_ty, err); diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index f86d5bf3a7a..442920a0681 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -24,7 +24,7 @@ fn transform_self_type_for_method(fcx: @fn_ctxt, impl_ty: ty::t, method_info: MethodInfo) -> ty::t { - alt method_info.self_type { + match method_info.self_type { sty_by_ref | sty_value => { impl_ty } @@ -88,7 +88,7 @@ class lookup { // Determine if there are any inherent methods we can call. let optional_inherent_methods; - alt get_base_type_def_id(self.fcx.infcx, + match get_base_type_def_id(self.fcx.infcx, self.self_expr.span, self.self_ty) { none => { @@ -110,7 +110,7 @@ class lookup { loop { // First, see whether this is a bounded parameter. - alt ty::get(self.self_ty).struct { + match ty::get(self.self_ty).struct { ty::ty_param(p) => { self.add_candidates_from_param(p.idx, p.def_id); } @@ -151,7 +151,7 @@ class lookup { if self.candidates.len() > 0u { break; } // check whether we can autoderef and if so loop around again. - alt ty::deref(self.tcx(), self.self_ty, false) { + match ty::deref(self.tcx(), self.self_ty, false) { none => break, some(mt) => { self.self_ty = mt.ty; @@ -168,7 +168,7 @@ class lookup { ~"multiple applicable methods in scope"); for self.candidates.eachi |i, candidate| { - alt candidate.entry.origin { + match candidate.entry.origin { method_static(did) => { self.report_static_candidate(i, did); } @@ -189,7 +189,7 @@ class lookup { fn report_static_candidate(idx: uint, did: ast::def_id) { let span = if did.crate == ast::local_crate { - alt check self.tcx().items.get(did.node) { + match check self.tcx().items.get(did.node) { ast_map::node_method(m, _, _) => m.span, } } else { @@ -226,20 +226,20 @@ class lookup { let mut trait_bnd_idx = 0u; // count only trait bounds let bounds = tcx.ty_param_bounds.get(did.node); for vec::each(*bounds) |bound| { - let (iid, bound_substs) = alt bound { + let (iid, bound_substs) = match bound { ty::bound_copy | ty::bound_send | ty::bound_const | ty::bound_owned => { again; /* ok */ } ty::bound_trait(bound_t) => { - alt check ty::get(bound_t).struct { + match check ty::get(bound_t).struct { ty::ty_trait(i, substs) => (i, substs) } } }; let trt_methods = ty::trait_methods(tcx, iid); - alt vec::position(*trt_methods, |m| m.ident == self.m_name) { + match vec::position(*trt_methods, |m| m.ident == self.m_name) { none => { /* check next bound */ trait_bnd_idx += 1u; @@ -329,14 +329,14 @@ class lookup { } fn ty_from_did(did: ast::def_id) -> ty::t { - alt check ty::get(ty::lookup_item_type(self.tcx(), did).ty).struct { + match check ty::get(ty::lookup_item_type(self.tcx(), did).ty).struct { ty::ty_fn(fty) => { ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty}) } } /* if did.crate == ast::local_crate { - alt check self.tcx().items.get(did.node) { + match check self.tcx().items.get(did.node) { ast_map::node_method(m, _, _) { // NDM trait/impl regions let mt = ty_of_method(self.fcx.ccx, m, ast::rp_none); @@ -344,7 +344,9 @@ class lookup { } } } else { - alt check ty::get(csearch::get_type(self.tcx(), did).ty).struct { + match check ty::get(csearch::get_type(self.tcx(), did).ty) + .struct { + ty::ty_fn(fty) { ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty}) } @@ -408,7 +410,7 @@ class lookup { self.fcx.can_mk_subty(self.self_ty, impl_ty) }; debug!{"matches = %?", matches}; - alt matches { + match matches { result::err(_) => { /* keep looking */ } result::ok(_) => { if !self.candidate_impls.contains_key(im.did) { @@ -454,7 +456,7 @@ class lookup { use_assignability: bool) { // Add inherent methods. - alt optional_inherent_methods { + match optional_inherent_methods { none => { // Continue. } @@ -473,7 +475,7 @@ class lookup { } // Add trait methods. - alt self.fcx.ccx.trait_map.find(self.expr.id) { + match self.fcx.ccx.trait_map.find(self.expr.id) { none => { // Should only happen for placement new right now. } @@ -484,7 +486,7 @@ class lookup { self.def_id_to_str(trait_id)}; let coherence_info = self.fcx.ccx.coherence_info; - alt coherence_info.extension_methods.find(trait_id) { + match coherence_info.extension_methods.find(trait_id) { none => { // Do nothing. } @@ -523,7 +525,7 @@ class lookup { // Make the actual receiver type (cand.self_ty) assignable to the // required receiver type (cand.rcvr_ty). If this method is not // from an impl, this'll basically be a no-nop. - alt self.fcx.mk_assignty(self.self_expr, self.borrow_lb, + match self.fcx.mk_assignty(self.self_expr, self.borrow_lb, cand.self_ty, cand.rcvr_ty) { result::ok(_) => (), result::err(_) => { diff --git a/src/rustc/middle/typeck/check/regionck.rs b/src/rustc/middle/typeck/check/regionck.rs index 7871e1802ea..03a27e88c97 100644 --- a/src/rustc/middle/typeck/check/regionck.rs +++ b/src/rustc/middle/typeck/check/regionck.rs @@ -104,7 +104,7 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) { fn visit_pat(p: @ast::pat, &&rcx: @rcx, v: rvt) { let fcx = rcx.fcx; - alt p.node { + match p.node { ast::pat_ident(_, path, _) if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) => { debug!{"visit_pat binding=%s", *path.idents[0]}; @@ -123,14 +123,14 @@ fn visit_block(b: ast::blk, &&rcx: @rcx, v: rvt) { fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { debug!{"visit_expr(e=%s)", pprust::expr_to_str(e)}; - alt e.node { + match e.node { ast::expr_path(*) => { // Avoid checking the use of local variables, as we already // check their definitions. The def'n always encloses the // use. So if the def'n is enclosed by the region, then the // uses will also be enclosed (and otherwise, an error will // have been reported at the def'n site). - alt lookup_def(rcx.fcx, e.span, e.id) { + match lookup_def(rcx.fcx, e.span, e.id) { ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) => return, _ => () } @@ -150,12 +150,12 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { // is an extensive comment on the function // check_cast_for_escaping_regions() in kind.rs explaining how // it goes about doing that. - alt rcx.resolve_node_type(e.id) { + match rcx.resolve_node_type(e.id) { result::err(_) => { return; /* typeck will fail anyhow */ } result::ok(target_ty) => { - alt ty::get(target_ty).struct { + match ty::get(target_ty).struct { ty::ty_trait(_, substs) => { - let trait_region = alt substs.self_r { + let trait_region = match substs.self_r { some(r) => {r} none => {ty::re_static} }; @@ -191,7 +191,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool { // Try to resolve the type. If we encounter an error, then typeck // is going to fail anyway, so just stop here and let typeck // report errors later on in the writeback phase. - let ty = alt rcx.resolve_node_type(id) { + let ty = match rcx.resolve_node_type(id) { result::err(_) => return true, result::ok(ty) => ty }; @@ -232,7 +232,7 @@ fn constrain_regions_in_type( ppaux::region_to_str(tcx, encl_region), ppaux::region_to_str(tcx, region)}; - alt region { + match region { ty::re_bound(_) => { // a bound region is one which appears inside an fn type. // (e.g., the `&` in `fn(&T)`). Such regions need not be @@ -243,7 +243,7 @@ fn constrain_regions_in_type( _ => () } - alt rcx.fcx.mk_subr(encl_region, region) { + match rcx.fcx.mk_subr(encl_region, region) { result::err(_) => { let region1 = rcx.fcx.infcx.resolve_region_if_possible(region); tcx.sess.span_err( diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index aee2a62d947..b9073f97399 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -12,7 +12,7 @@ fn replace_bound_regions_in_fn_ty( // Take self_info apart; the self_ty part is the only one we want // to update here. - let self_ty = alt self_info { + let self_ty = match self_info { some(s) => some(s.self_ty), none => none }; @@ -44,8 +44,8 @@ fn replace_bound_regions_in_fn_ty( // Glue updated self_ty back together with its original node_id. - let new_self_info = alt self_info { - some(s) => alt check t_self { + let new_self_info = match self_info { + some(s) => match check t_self { some(t) => some({self_ty: t, node_id: s.node_id}) // this 'none' case shouldn't happen } @@ -54,7 +54,7 @@ fn replace_bound_regions_in_fn_ty( return {isr: isr, self_info: new_self_info, - fn_ty: alt check ty::get(t_fn).struct { ty::ty_fn(o) => o }}; + fn_ty: match check ty::get(t_fn).struct { ty::ty_fn(o) => o }}; // Takes `isr`, a (possibly empty) mapping from in-scope region @@ -82,13 +82,13 @@ fn replace_bound_regions_in_fn_ty( fn append_isr(isr: isr_alist, to_r: fn(ty::bound_region) -> ty::region, r: ty::region) -> isr_alist { - alt r { + match r { ty::re_free(_, _) | ty::re_static | ty::re_scope(_) | ty::re_var(_) => { isr } ty::re_bound(br) => { - alt isr.find(br) { + match isr.find(br) { some(_) => isr, none => @cons((br, to_r(br)), isr) } @@ -124,14 +124,14 @@ fn replace_bound_regions_in_fn_ty( ty: ty::t) -> ty::t { do ty::fold_regions(tcx, ty) |r, in_fn| { - alt r { + match r { // As long as we are not within a fn() type, `&T` is // mapped to the free region anon_r. But within a fn // type, it remains bound. ty::re_bound(ty::br_anon) if in_fn => r, ty::re_bound(br) => { - alt isr.find(br) { + match isr.find(br) { // In most cases, all named, bound regions will be // mapped to some free region. some(fr) => fr, diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index e1d85828c13..ec8e89ef2ad 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -6,7 +6,7 @@ import dvec::extensions; fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool { vec::any(tps, |bs| { vec::any(*bs, |b| { - alt b { ty::bound_trait(_) => true, _ => false } + match b { ty::bound_trait(_) => true, _ => false } }) }) } @@ -18,7 +18,7 @@ fn lookup_vtables(fcx: @fn_ctxt, sp: span, let mut result = ~[], i = 0u; for substs.tps.each |ty| { for vec::each(*bounds[i]) |bound| { - alt bound { + match bound { ty::bound_trait(i_ty) => { let i_ty = ty::subst(tcx, substs, i_ty); vec::push(result, lookup_vtable(fcx, sp, ty, i_ty, @@ -38,7 +38,7 @@ fn fixup_substs(fcx: @fn_ctxt, sp: span, // use a dummy type just to package up the substs that need fixing up let t = ty::mk_trait(tcx, id, substs); let t_f = fixup_ty(fcx, sp, t); - alt check ty::get(t_f).struct { + match check ty::get(t_f).struct { ty::ty_trait(_, substs_f) => substs_f, } } @@ -61,21 +61,21 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, let _i = indenter(); let tcx = fcx.ccx.tcx; - let (trait_id, trait_substs) = alt check ty::get(trait_ty).struct { + let (trait_id, trait_substs) = match check ty::get(trait_ty).struct { ty::ty_trait(did, substs) => (did, substs) }; let ty = fixup_ty(fcx, sp, ty); - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_param({idx: n, def_id: did}) => { let mut n_bound = 0u; for vec::each(*tcx.ty_param_bounds.get(did.node)) |bound| { - alt bound { + match bound { ty::bound_send | ty::bound_copy | ty::bound_const | ty::bound_owned => { /* ignore */ } ty::bound_trait(ity) => { - alt check ty::get(ity).struct { + match check ty::get(ity).struct { ty::ty_trait(idid, substs) => { if trait_id == idid { debug!{"(checking vtable) @0 relating ty to trait ty @@ -118,7 +118,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, let mut impls_seen = new_def_hash(); - alt fcx.ccx.coherence_info.extension_methods.find(trait_id) { + match fcx.ccx.coherence_info.extension_methods.find(trait_id) { none => { // Nothing found. Continue. } @@ -137,7 +137,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, // find the trait that im implements (if any) for vec::each(ty::impl_traits(tcx, im.did)) |of_ty| { // it must have the same id as the expected one - alt ty::get(of_ty).struct { + match ty::get(of_ty).struct { ty::ty_trait(id, _) if id != trait_id => again, _ => { /* ok */ } } @@ -147,7 +147,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, let {substs: substs, ty: for_ty} = impl_self_ty(fcx, im.did); let im_bs = ty::lookup_item_type(tcx, im.did).bounds; - alt fcx.mk_subty(ty, for_ty) { + match fcx.mk_subty(ty, for_ty) { result::err(_) => again, result::ok(()) => () } @@ -176,7 +176,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, } } - alt found.len() { + match found.len() { 0u => { /* fallthrough */ } 1u => { return found[0]; } _ => { @@ -196,7 +196,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, fn fixup_ty(fcx: @fn_ctxt, sp: span, ty: ty::t) -> ty::t { let tcx = fcx.ccx.tcx; - alt resolve_type(fcx.infcx, ty, resolve_all | force_all) { + match resolve_type(fcx.infcx, ty, resolve_all | force_all) { result::ok(new_type) => new_type, result::err(e) => { tcx.sess.span_fatal( @@ -217,7 +217,7 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], let trait_ty = ty::subst_tps(tcx, impl_tys, ity); debug!{"(connect trait tps) trait type is %?, impl did is %?", ty::get(trait_ty).struct, impl_did}; - alt check ty::get(trait_ty).struct { + match check ty::get(trait_ty).struct { ty::ty_trait(_, substs) => { vec::iter2(substs.tps, trait_tys, |a, b| demand::suptype(fcx, sp, a, b)); @@ -227,9 +227,9 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { let cx = fcx.ccx; - alt ex.node { + match ex.node { ast::expr_path(*) => { - alt fcx.opt_node_ty_substs(ex.id) { + match fcx.opt_node_ty_substs(ex.id) { some(substs) => { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(ex.id)); let item_ty = ty::lookup_item_type(cx.tcx, did); @@ -248,11 +248,11 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { ast::expr_field(*) | ast::expr_binary(*) | ast::expr_unary(*) | ast::expr_assign_op(*) | ast::expr_index(*) => { - alt cx.method_map.find(ex.id) { + match cx.method_map.find(ex.id) { some({origin: method_static(did), _}) => { let bounds = ty::lookup_item_type(cx.tcx, did).bounds; if has_trait_bounds(*bounds) { - let callee_id = alt ex.node { + let callee_id = match ex.node { ast::expr_field(_, _, _) => ex.id, _ => ex.callee_id }; @@ -269,7 +269,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { } ast::expr_cast(src, _) => { let target_ty = fcx.expr_ty(ex); - alt ty::get(target_ty).struct { + match ty::get(target_ty).struct { ty::ty_trait(*) => { /* Look up vtables for the type we're casting to, diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index bafcfc4855d..fc5a3763615 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -10,7 +10,7 @@ export resolve_type_vars_in_expr; fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) -> option<ty::t> { if !ty::type_needs_infer(typ) { return some(typ); } - alt resolve_type(fcx.infcx, typ, resolve_all | force_all) { + match resolve_type(fcx.infcx, typ, resolve_all | force_all) { result::ok(new_type) => return some(new_type), result::err(e) => { if !fcx.ccx.tcx.sess.has_errors() { @@ -28,7 +28,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) -> option<ty::t> { let fcx = wbcx.fcx, tcx = fcx.ccx.tcx; let n_ty = fcx.node_ty(id); - alt resolve_type_vars_in_type(fcx, sp, n_ty) { + match resolve_type_vars_in_type(fcx, sp, n_ty) { none => { wbcx.success = false; return none; @@ -38,11 +38,11 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) debug!{"resolve_type_vars_for_node(id=%d, n_ty=%s, t=%s)", id, ty_to_str(tcx, n_ty), ty_to_str(tcx, t)}; write_ty_to_tcx(tcx, id, t); - alt fcx.opt_node_ty_substs(id) { + match fcx.opt_node_ty_substs(id) { some(substs) => { let mut new_tps = ~[]; for substs.tps.each |subst| { - alt resolve_type_vars_in_type(fcx, sp, subst) { + match resolve_type_vars_in_type(fcx, sp, subst) { some(t) => vec::push(new_tps, t), none => { wbcx.success = false; return none; } } @@ -80,7 +80,7 @@ fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) { fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, e.span, e.id); - alt e.node { + match e.node { ast::expr_fn(_, decl, _, _) | ast::expr_fn_block(decl, _, _) => { do vec::iter(decl.inputs) |input| { @@ -88,7 +88,7 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { // Just in case we never constrained the mode to anything, // constrain it to the default for the type in question. - alt (r_ty, input.mode) { + match (r_ty, input.mode) { (some(t), ast::infer(_)) => { let tcx = wbcx.fcx.ccx.tcx; let m_def = ty::default_arg_mode_for_ty(t); @@ -127,7 +127,7 @@ fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) { if !wbcx.success { return; } let var_id = lookup_local(wbcx.fcx, l.span, l.node.id); let var_ty = ty::mk_var(wbcx.fcx.tcx(), var_id); - alt resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) { + match resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) { result::ok(lty) => { debug!{"Type for local %s (id %d) resolved to %s", pat_to_str(l.node.pat), l.node.id, diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index 74f9b6c3061..c6633efe43f 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -40,7 +40,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t) -> option<t> { let resolved_type; - alt resolve_type(inference_context, + match resolve_type(inference_context, original_type, resolve_ivar) { ok(resulting_type) if !type_is_var(resulting_type) => { @@ -55,7 +55,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t) } } - alt get(resolved_type).struct { + match get(resolved_type).struct { ty_box(base_mutability_and_type) | ty_uniq(base_mutability_and_type) | ty_ptr(base_mutability_and_type) | @@ -88,12 +88,12 @@ fn get_base_type_def_id(inference_context: infer_ctxt, original_type: t) -> option<def_id> { - alt get_base_type(inference_context, span, original_type) { + match get_base_type(inference_context, span, original_type) { none => { return none; } some(base_type) => { - alt get(base_type).struct { + match get(base_type).struct { ty_enum(def_id, _) | ty_class(def_id, _) | ty_trait(def_id, _) => { @@ -160,7 +160,7 @@ class CoherenceChecker { visit_item: |item| { debug!{"(checking coherence) item '%s'", *item.ident}; - alt item.node { + match item.node { item_impl(_, associated_traits, _, _) => { self.check_implementation(item, associated_traits); } @@ -203,7 +203,7 @@ class CoherenceChecker { '%s'", *item.ident}; - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, item.span, self_type.ty) { none => { @@ -235,7 +235,7 @@ class CoherenceChecker { // Add the implementation to the mapping from implementation to base // type def ID, if there is a base type for this implementation. - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, item.span, self_type.ty) { none => { @@ -253,7 +253,7 @@ class CoherenceChecker { fn add_inherent_method(base_def_id: def_id, implementation: @Impl) { let implementation_list; - alt self.crate_context.coherence_info.inherent_methods + match self.crate_context.coherence_info.inherent_methods .find(base_def_id) { none => { @@ -271,7 +271,7 @@ class CoherenceChecker { fn add_trait_method(trait_id: def_id, implementation: @Impl) { let implementation_list; - alt self.crate_context.coherence_info.extension_methods + match self.crate_context.coherence_info.extension_methods .find(trait_id) { none => { @@ -363,7 +363,7 @@ class CoherenceChecker { visit_crate(*crate, (), mk_vt(@{ visit_item: |item, _context, visitor| { - alt item.node { + match item.node { item_mod(module_) => { // First, gather up all privileged types. let privileged_types = @@ -386,7 +386,9 @@ class CoherenceChecker { } } item_impl(_, associated_traits, _, _) => { - alt self.base_type_def_ids.find(local_def(item.id)) { + match self.base_type_def_ids.find( + local_def(item.id)) { + none => { // Nothing to do. } @@ -468,7 +470,7 @@ class CoherenceChecker { fn gather_privileged_types(items: ~[@item]) -> @dvec<def_id> { let results = @dvec(); for items.each |item| { - alt item.node { + match item.node { item_class(*) | item_enum(*) | item_trait(*) => { results.push(local_def(item.id)); } @@ -486,7 +488,7 @@ class CoherenceChecker { // Converts an implementation in the AST to an Impl structure. fn create_impl_from_item(item: @item) -> @Impl { - alt item.node { + match item.node { item_impl(ty_params, _, _, ast_methods) => { let mut methods = ~[]; for ast_methods.each |ast_method| { @@ -507,7 +509,7 @@ class CoherenceChecker { item_class(ty_params, _, class_members, _, _) => { let mut methods = ~[]; for class_members.each |class_member| { - alt class_member.node { + match class_member.node { instance_var(*) => { // Nothing to do. } @@ -538,7 +540,7 @@ class CoherenceChecker { fn span_of_impl(implementation: @Impl) -> span { assert implementation.did.crate == local_crate; - alt self.crate_context.tcx.items.find(implementation.did.node) { + match self.crate_context.tcx.items.find(implementation.did.node) { some(node_item(item, _)) => { return item.span; } @@ -562,7 +564,7 @@ class CoherenceChecker { for (*implementations).each |implementation| { // Make sure we don't visit the same implementation // multiple times. - alt impls_seen.find(implementation.did) { + match impls_seen.find(implementation.did) { none => { // Good. Continue. impls_seen.insert(implementation.did, ()); @@ -582,7 +584,7 @@ class CoherenceChecker { // types. if associated_traits.len() == 0 { - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, dummy_sp(), self_type.ty) { none => { @@ -601,7 +603,7 @@ class CoherenceChecker { // Record all the trait methods. for associated_traits.each |trait_type| { - alt get(trait_type).struct { + match get(trait_type).struct { ty_trait(trait_id, _) => { self.add_trait_method(trait_id, implementation); } @@ -617,7 +619,7 @@ class CoherenceChecker { // implementation to base type def ID, if there is a base // type for this implementation. - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, dummy_sp(), self_type.ty) { none => { @@ -645,7 +647,7 @@ class CoherenceChecker { for each_path(crate_store, crate_number) |path_entry| { let module_def_id; - alt path_entry.def_like { + match path_entry.def_like { dl_def(def_mod(def_id)) => { module_def_id = def_id; } diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 5a13d1d8efc..c1211d79a7e 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -30,14 +30,14 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { for crate.node.module.items.each |crate_item| { if *crate_item.ident == ~"intrinsic" { - alt crate_item.node { + match crate_item.node { ast::item_mod(m) => { for m.items.each |intrinsic_item| { let def_id = { crate: ast::local_crate, node: intrinsic_item.id }; let substs = {self_r: none, self_ty: none, tps: ~[]}; - alt intrinsic_item.node { + match intrinsic_item.node { ast::item_trait(*) => { let ty = ty::mk_trait(ccx.tcx, def_id, substs); ccx.tcx.intrinsic_defs.insert @@ -83,7 +83,7 @@ impl of ast_conv for @crate_ctxt { if id.crate != ast::local_crate { csearch::get_type(self.tcx, id) } else { - alt self.tcx.items.find(id.node) { + match self.tcx.items.find(id.node) { some(ast_map::node_item(item, _)) => { ty_of_item(self, item) } @@ -145,10 +145,10 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id) { let tcx = ccx.tcx; let rp = tcx.region_paramd_items.contains_key(id); - alt check tcx.items.get(id) { + match check tcx.items.get(id) { ast_map::node_item(@{node: ast::item_trait(_, _, ms), _}, _) => { store_methods::<ast::trait_method>(ccx, id, ms, |m| { - alt m { + match m { required(ty_m) => { ty_of_ty_method(ccx, ty_m, rp) } @@ -253,7 +253,7 @@ fn check_methods_against_trait(ccx: @crate_ctxt, ensure_trait_methods(ccx, did.node); } for vec::each(*ty::trait_methods(tcx, did)) |trait_m| { - alt vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) { + match vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) { some({mty: impl_m, id, span}) => { if impl_m.purity != trait_m.purity { ccx.tcx.sess.span_err( @@ -271,13 +271,13 @@ fn check_methods_against_trait(ccx: @crate_ctxt, // implementation in the trait itself. If not, raise a // "missing method" error. - alt tcx.items.get(did.node) { + match tcx.items.get(did.node) { ast_map::node_item( @{node: ast::item_trait(_, _, trait_methods), _}, _) => { let (_, provided_methods) = split_trait_methods(trait_methods); - alt vec::find(provided_methods, |provided_method| + match vec::find(provided_methods, |provided_method| provided_method.ident == trait_m.ident) { some(m) => { // If there's a provided method with the name we @@ -339,7 +339,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { let tcx = ccx.tcx; let rp = tcx.region_paramd_items.contains_key(it.id); debug!{"convert: item %s with id %d rp %b", *it.ident, it.id, rp}; - alt it.node { + match it.node { // These don't define types. ast::item_foreign_mod(_) | ast::item_mod(_) => {} ast::item_enum(variants, ty_params) => { @@ -449,7 +449,7 @@ fn convert_foreign(ccx: @crate_ctxt, i: @ast::foreign_item) { // type of the foreign item. We simply write it into the node type // table. let tpt = ty_of_foreign_item(ccx, i); - alt i.node { + match i.node { ast::foreign_item_fn(_, _) => { write_ty_to_tcx(ccx.tcx, i.id, tpt.ty); ccx.tcx.tcache.insert(local_def(i.id), tpt); @@ -494,11 +494,11 @@ fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: bool) let rscope = type_rscope(rp); - alt lookup_def_tcx(ccx.tcx, t.path.span, t.ref_id) { + match lookup_def_tcx(ccx.tcx, t.path.span, t.ref_id) { ast::def_ty(t_id) => { let tpt = astconv::ast_path_to_ty(ccx, rscope, t_id, t.path, t.ref_id); - alt ty::get(tpt.ty).struct { + match ty::get(tpt.ty).struct { ty::ty_trait(*) => { (t_id, tpt) } @@ -514,12 +514,12 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) let def_id = local_def(it.id); let tcx = ccx.tcx; - alt tcx.tcache.find(def_id) { + match tcx.tcache.find(def_id) { some(tpt) => return tpt, _ => {} } let rp = tcx.region_paramd_items.contains_key(it.id); - alt it.node { + match it.node { ast::item_const(t, _) => { let typ = ccx.to_ty(empty_rscope, t); let tpt = no_params(typ); @@ -539,7 +539,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) return tpt; } ast::item_ty(t, tps) => { - alt tcx.tcache.find(local_def(it.id)) { + match tcx.tcache.find(local_def(it.id)) { some(tpt) => return tpt, none => { } } @@ -592,7 +592,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item) -> ty::ty_param_bounds_and_ty { - alt it.node { + match it.node { ast::foreign_item_fn(fn_decl, params) => { return ty_of_foreign_fn_decl(ccx, fn_decl, params, local_def(it.id)); @@ -605,14 +605,14 @@ fn ty_param_bounds(ccx: @crate_ctxt, fn compute_bounds(ccx: @crate_ctxt, param: ast::ty_param) -> ty::param_bounds { @do vec::flat_map(*param.bounds) |b| { - alt b { + match b { ast::bound_send => ~[ty::bound_send], ast::bound_copy => ~[ty::bound_copy], ast::bound_const => ~[ty::bound_const], ast::bound_owned => ~[ty::bound_owned], ast::bound_trait(t) => { let ity = ast_ty_to_ty(ccx, empty_rscope, t); - alt ty::get(ity).struct { + match ty::get(ity).struct { ty::ty_trait(*) => { ~[ty::bound_trait(ity)] } @@ -629,7 +629,7 @@ fn ty_param_bounds(ccx: @crate_ctxt, } @do params.map |param| { - alt ccx.tcx.ty_param_bounds.find(param.id) { + match ccx.tcx.ty_param_bounds.find(param.id) { some(bs) => bs, none => { let bounds = compute_bounds(ccx, param); diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index d13a18dfcc6..8c9cbc07598 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -249,8 +249,8 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) -> fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) -> int_ty_set { - alt get(t).struct { - ty_int(int_ty) => alt int_ty { + match get(t).struct { + ty_int(int_ty) => match int_ty { ast::ty_i8 => int_ty_set(INT_TY_SET_i8), ast::ty_i16 => int_ty_set(INT_TY_SET_i16), ast::ty_i32 => int_ty_set(INT_TY_SET_i32), @@ -259,7 +259,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) ast::ty_char => tcx.sess.bug( ~"char type passed to convert_integral_ty_to_int_ty_set()") } - ty_uint(uint_ty) => alt uint_ty { + ty_uint(uint_ty) => match uint_ty { ast::ty_u8 => int_ty_set(INT_TY_SET_u8), ast::ty_u16 => int_ty_set(INT_TY_SET_u16), ast::ty_u32 => int_ty_set(INT_TY_SET_u32), @@ -335,7 +335,7 @@ enum fixup_err { } fn fixup_err_to_str(f: fixup_err) -> ~str { - alt f { + match f { unresolved_int_ty(_) => ~"unconstrained integral type", unresolved_ty(_) => ~"unconstrained type", cyclic_ty(_) => ~"cyclic type of infinite size", @@ -418,7 +418,7 @@ fn resolve_region(cx: infer_ctxt, r: ty::region, modes: uint) fn resolve_borrowings(cx: infer_ctxt) { for cx.borrowings.each |item| { - alt resolve_region(cx, item.scope, resolve_all|force_all) { + match resolve_region(cx, item.scope, resolve_all|force_all) { ok(region) => { debug!{"borrowing for expr %d resolved to region %?, mutbl %?", item.expr_id, region, item.mutbl}; @@ -455,7 +455,7 @@ trait cres_helpers<T> { impl methods<T:copy> of cres_helpers<T> for cres<T> { fn to_ures() -> ures { - alt self { + match self { ok(_v) => ok(()), err(e) => err(e) } @@ -496,7 +496,7 @@ impl of to_str for ty::region { impl<V:copy to_str> of to_str for bound<V> { fn to_str(cx: infer_ctxt) -> ~str { - alt self { + match self { some(v) => v.to_str(cx), none => ~"none" } @@ -513,7 +513,7 @@ impl<T:copy to_str> of to_str for bounds<T> { impl of to_str for int_ty_set { fn to_str(_cx: infer_ctxt) -> ~str { - alt self { + match self { int_ty_set(v) => uint::to_str(v, 10u) } } @@ -521,7 +521,7 @@ impl of to_str for int_ty_set { impl<V:copy vid, T:copy to_str> of to_str for var_value<V,T> { fn to_str(cx: infer_ctxt) -> ~str { - alt self { + match self { redirect(vid) => fmt!{"redirect(%s)", vid.to_str()}, root(pt, rk) => fmt!{"root(%s, %s)", pt.to_str(cx), uint::to_str(rk, 10u)} @@ -602,7 +602,7 @@ impl transaction_methods for infer_ctxt { debug!{"try(tvbl=%u, rbl=%u)", tvbl, rbl}; let r <- f(); - alt r { + match r { result::ok(_) => debug!{"try--ok"}, result::err(_) => { debug!{"try--rollback"}; @@ -681,14 +681,14 @@ impl methods for infer_ctxt { } fn resolve_type_vars_if_possible(typ: ty::t) -> ty::t { - alt resolve_type(self, typ, resolve_all) { + match resolve_type(self, typ, resolve_all) { result::ok(new_type) => return new_type, result::err(_) => return typ } } fn resolve_region_if_possible(oldr: ty::region) -> ty::region { - alt resolve_region(self, oldr, resolve_all) { + match resolve_region(self, oldr, resolve_all) { result::ok(newr) => return newr, result::err(_) => return oldr } @@ -714,12 +714,12 @@ impl unify_methods for infer_ctxt { -> node<V, T> { let vid_u = vid.to_uint(); - alt vb.vals.find(vid_u) { + match vb.vals.find(vid_u) { none => { self.tcx.sess.bug(fmt!{"failed lookup of vid `%u`", vid_u}); } some(var_val) => { - alt var_val { + match var_val { redirect(vid) => { let nde = self.get(vb, vid); if nde.root != vid { @@ -744,7 +744,7 @@ impl unify_methods for infer_ctxt { debug!{"merge_bnd(%s,%s)", a.to_str(self), b.to_str(self)}; let _r = indenter(); - alt (a, b) { + match (a, b) { (none, none) => ok(none), (some(_), none) => ok(a), (none, some(_)) => ok(b), @@ -853,10 +853,10 @@ impl unify_methods for infer_ctxt { // If both A's UB and B's LB have already been bound to types, // see if we can make those types subtypes. - alt (a_bounds.ub, b_bounds.lb) { + match (a_bounds.ub, b_bounds.lb) { (some(a_ub), some(b_lb)) => { let r = self.try(|| a_ub.sub(self, b_lb)); - alt r { + match r { ok(()) => return result::ok(()), err(_) => { /*fallthrough */ } } @@ -1022,7 +1022,7 @@ impl unify_methods for infer_ctxt { debug!{"bnds(%s <: %s)", a.to_str(self), b.to_str(self)}; do indent { - alt (a, b) { + match (a, b) { (none, none) | (some(_), none) | (none, some(_)) => { @@ -1141,7 +1141,7 @@ impl methods for resolve_state { assert vec::is_empty(self.v_seen); let rty = indent(|| self.resolve_type(typ) ); assert vec::is_empty(self.v_seen); - alt self.err { + match self.err { none => { debug!{"Resolved to %s (modes=%x)", ty_to_str(self.infcx.tcx, rty), @@ -1155,7 +1155,7 @@ impl methods for resolve_state { fn resolve_region_chk(orig: ty::region) -> fres<ty::region> { self.err = none; let resolved = indent(|| self.resolve_region(orig) ); - alt self.err { + match self.err { none => ok(resolved), some(e) => err(e) } @@ -1166,7 +1166,7 @@ impl methods for resolve_state { indent(fn&() -> ty::t { if !ty::type_needs_infer(typ) { return typ; } - alt ty::get(typ).struct { + match ty::get(typ).struct { ty::ty_var(vid) => { self.resolve_ty_var(vid) } @@ -1201,7 +1201,7 @@ impl methods for resolve_state { fn resolve_region(orig: ty::region) -> ty::region { debug!{"Resolve_region(%s)", orig.to_str(self.infcx)}; - alt orig { + match orig { ty::re_var(rid) => self.resolve_region_var(rid), _ => orig } @@ -1213,7 +1213,7 @@ impl methods for resolve_state { } let nde = self.infcx.get(self.infcx.rb, rid); let bounds = nde.possible_types; - alt bounds { + match bounds { { ub:_, lb:some(r) } => { self.assert_not_rvar(rid, r); r } { ub:some(r), lb:_ } => { self.assert_not_rvar(rid, r); r } { ub:none, lb:none } => { @@ -1226,7 +1226,7 @@ impl methods for resolve_state { } fn assert_not_rvar(rid: region_vid, r: ty::region) { - alt r { + match r { ty::re_var(rid2) => { self.err = some(region_var_bound_by_region_var(rid, rid2)); } @@ -1251,7 +1251,7 @@ impl methods for resolve_state { let nde = self.infcx.get(self.infcx.tvb, vid); let bounds = nde.possible_types; - let t1 = alt bounds { + let t1 = match bounds { { ub:_, lb:some(t) } if !type_is_bot(t) => self.resolve_type(t), { ub:some(t), lb:_ } => self.resolve_type(t), { ub:_, lb:some(t) } => self.resolve_type(t), @@ -1277,7 +1277,7 @@ impl methods for resolve_state { // If there's only one type in the set of possible types, then // that's the answer. - alt single_type_contained_in(self.infcx.tcx, pt) { + match single_type_contained_in(self.infcx.tcx, pt) { some(t) => t, none => { if self.should(force_ivar) { @@ -1351,9 +1351,9 @@ impl assignment for infer_ctxt { fn assign_tys(anmnt: assignment, a: ty::t, b: ty::t) -> ures { fn select(fst: option<ty::t>, snd: option<ty::t>) -> option<ty::t> { - alt fst { + match fst { some(t) => some(t), - none => alt snd { + none => match snd { some(t) => some(t), none => none } @@ -1364,7 +1364,7 @@ impl assignment for infer_ctxt { anmnt, a.to_str(self), b.to_str(self)}; let _r = indenter(); - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) => { uok() } @@ -1413,15 +1413,15 @@ impl assignment for infer_ctxt { let _r = indenter(); fn is_borrowable(v: ty::vstore) -> bool { - alt v { + match v { ty::vstore_fixed(_) | ty::vstore_uniq | ty::vstore_box => true, ty::vstore_slice(_) => false } } - alt (a_bnd, b_bnd) { + match (a_bnd, b_bnd) { (some(a_bnd), some(b_bnd)) => { - alt (ty::get(a_bnd).struct, ty::get(b_bnd).struct) { + match (ty::get(a_bnd).struct, ty::get(b_bnd).struct) { (ty::ty_box(mt_a), ty::ty_rptr(r_b, mt_b)) => { let nr_b = ty::mk_box(self.tcx, {ty: mt_b.ty, mutbl: m_const}); @@ -1569,7 +1569,7 @@ fn super_substs<C:combine>( fn eq_opt_regions(infcx: infer_ctxt, a: option<ty::region>, b: option<ty::region>) -> cres<option<ty::region>> { - alt (a, b) { + match (a, b) { (none, none) => { ok(none) } @@ -1625,7 +1625,7 @@ fn super_self_tys<C:combine>( // Note: the self type parameter is (currently) always treated as // *invariant* (otherwise the type system would be unsound). - alt (a, b) { + match (a, b) { (none, none) => { ok(none) } @@ -1677,7 +1677,7 @@ fn super_vstores<C:combine>( self: C, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres<ty::vstore> { - alt (a, b) { + match (a, b) { (ty::vstore_slice(a_r), ty::vstore_slice(b_r)) => { do self.contraregions(a_r, b_r).chain |r| { ok(ty::vstore_slice(r)) @@ -1732,7 +1732,7 @@ fn super_tys<C:combine>( self: C, a: ty::t, b: ty::t) -> cres<ty::t> { let tcx = self.infcx().tcx; - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { // The "subtype" ought to be handling cases involving bot or var: (ty::ty_bot, _) | (_, ty::ty_bot) | @@ -1897,7 +1897,7 @@ impl of combine for sub { a.to_str(self.infcx()), b.to_str(self.infcx())}; do indent { - alt (a, b) { + match (a, b) { (ty::re_var(a_id), ty::re_var(b_id)) => { do self.infcx().vars(self.rb, a_id, b_id).then { ok(a) @@ -1929,7 +1929,7 @@ impl of combine for sub { return err(ty::terr_mutability); } - alt b.mutbl { + match b.mutbl { m_mutbl => { // If supertype is mut, subtype must match exactly // (i.e., invariant if mut): @@ -1965,7 +1965,7 @@ impl of combine for sub { a.to_str(*self), b.to_str(*self)}; if a == b { return ok(a); } do indent { - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) => { ok(a) } @@ -2077,7 +2077,7 @@ impl of combine for lub { m_const }; - alt m { + match m { m_imm | m_const => { self.tys(a.ty, b.ty).chain(|t| ok({ty: t, mutbl: m}) ) } @@ -2113,7 +2113,7 @@ impl of combine for lub { } fn purities(f1: purity, f2: purity) -> cres<purity> { - alt (f1, f2) { + match (f1, f2) { (unsafe_fn, _) | (_, unsafe_fn) => ok(unsafe_fn), (impure_fn, _) | (_, impure_fn) => ok(impure_fn), (extern_fn, _) | (_, extern_fn) => ok(extern_fn), @@ -2122,7 +2122,7 @@ impl of combine for lub { } fn ret_styles(r1: ret_style, r2: ret_style) -> cres<ret_style> { - alt (r1, r2) { + match (r1, r2) { (ast::return_val, _) | (_, ast::return_val) => ok(ast::return_val), (ast::noreturn, ast::noreturn) => ok(ast::noreturn) @@ -2140,7 +2140,7 @@ impl of combine for lub { b.to_str(self.infcx())}; do indent { - alt (a, b) { + match (a, b) { (ty::re_static, _) | (_, ty::re_static) => { ok(ty::re_static) // nothing lives longer than static } @@ -2155,7 +2155,7 @@ impl of combine for lub { // at least as big as the block f_id". So, we can // reasonably compare free regions and scopes: let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, f_id, s_id) { + match region::nearest_common_ancestor(rm, f_id, s_id) { // if the free region's scope `f_id` is bigger than // the scope region `s_id`, then the LUB is the free // region itself: @@ -2172,7 +2172,7 @@ impl of combine for lub { // subtype of the region corresponding to an inner // block. let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, a_id, b_id) { + match region::nearest_common_ancestor(rm, a_id, b_id) { some(r_id) => ok(ty::re_scope(r_id)), _ => ok(ty::re_static) } @@ -2248,7 +2248,7 @@ impl of combine for glb { mt_to_str(tcx, a), mt_to_str(tcx, b)}; - alt (a.mutbl, b.mutbl) { + match (a.mutbl, b.mutbl) { // If one side or both is mut, then the GLB must use // the precise type from the mut side. (m_mutbl, m_const) => { @@ -2310,7 +2310,7 @@ impl of combine for glb { } fn purities(f1: purity, f2: purity) -> cres<purity> { - alt (f1, f2) { + match (f1, f2) { (pure_fn, _) | (_, pure_fn) => ok(pure_fn), (extern_fn, _) | (_, extern_fn) => ok(extern_fn), (impure_fn, _) | (_, impure_fn) => ok(impure_fn), @@ -2319,7 +2319,7 @@ impl of combine for glb { } fn ret_styles(r1: ret_style, r2: ret_style) -> cres<ret_style> { - alt (r1, r2) { + match (r1, r2) { (ast::return_val, ast::return_val) => { ok(ast::return_val) } @@ -2337,7 +2337,7 @@ impl of combine for glb { b.to_str(self.infcx())}; do indent { - alt (a, b) { + match (a, b) { (ty::re_static, r) | (r, ty::re_static) => { // static lives longer than everything else ok(r) @@ -2355,7 +2355,7 @@ impl of combine for glb { // is the scope `s_id`. Otherwise, as we do not know // big the free region is precisely, the GLB is undefined. let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, f_id, s_id) { + match region::nearest_common_ancestor(rm, f_id, s_id) { some(r_id) if r_id == f_id => ok(s), _ => err(ty::terr_regions_differ(b, a)) } @@ -2367,7 +2367,7 @@ impl of combine for glb { // these: so, if one of these scopes is a subscope of the // other, return it. Otherwise fail. let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, a_id, b_id) { + match region::nearest_common_ancestor(rm, a_id, b_id) { some(r_id) if a_id == r_id => ok(b), some(r_id) if b_id == r_id => ok(a), _ => err(ty::terr_regions_differ(b, a)) @@ -2475,7 +2475,7 @@ fn lattice_tys<L:lattice_ops combine>( b.to_str(self.infcx())}; if a == b { return ok(a); } do indent { - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) => self.ty_bot(b), (_, ty::ty_bot) => self.ty_bot(a), @@ -2505,7 +2505,7 @@ fn lattice_tys<L:lattice_ops combine>( fn lattice_rvars<L:lattice_ops combine>( self: L, a: ty::region, b: ty::region) -> cres<ty::region> { - alt (a, b) { + match (a, b) { (ty::re_var(a_id), ty::re_var(b_id)) => { lattice_vars(self, self.infcx().rb, a, a_id, b_id, @@ -2558,9 +2558,9 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>( // If both A and B have an UB type, then we can just compute the // LUB of those types: let a_bnd = self.bnd(a_bounds), b_bnd = self.bnd(b_bounds); - alt (a_bnd, b_bnd) { + match (a_bnd, b_bnd) { (some(a_ty), some(b_ty)) => { - alt self.infcx().try(|| c_ts(a_ty, b_ty) ) { + match self.infcx().try(|| c_ts(a_ty, b_ty) ) { ok(t) => return ok(t), err(_) => { /*fallthrough */ } } @@ -2590,7 +2590,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>( a_id.to_str(), a_bounds.to_str(self.infcx()), b.to_str(self.infcx())}; - alt self.bnd(a_bounds) { + match self.bnd(a_bounds) { some(a_bnd) => { // If a has an upper bound, return the LUB(a.ub, b) debug!{"bnd=some(%s)", a_bnd.to_str(self.infcx())}; diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index d471ba677b5..906f3b7bdb3 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -42,7 +42,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool { let visit_expr = |e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| { *flag |= p(e.node); - alt e.node { + match e.node { // Skip inner loops, since a break in the inner loop isn't a // break inside the outer loop ast::expr_loop(*) | ast::expr_while(*) @@ -58,7 +58,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool { fn has_nonlocal_exits(b: ast::blk) -> bool { do loop_query(b) |e| { - alt e { + match e { ast::expr_break | ast::expr_again => true, _ => false } @@ -67,7 +67,7 @@ fn has_nonlocal_exits(b: ast::blk) -> bool { fn may_break(b: ast::blk) -> bool { do loop_query(b) |e| { - alt e { + match e { ast::expr_break => true, _ => false } @@ -75,7 +75,7 @@ fn may_break(b: ast::blk) -> bool { } fn local_rhs_span(l: @ast::local, def: span) -> span { - alt l.node.init { + match l.node.init { some(i) => return i.expr.span, _ => return def } diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 571da9db069..1f180bfb764 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -25,14 +25,14 @@ import driver::session::session; /// that attempts to explain a lifetime in a way it might plausibly be /// understood. fn explain_region(cx: ctxt, region: ty::region) -> ~str { - return alt region { + return match region { re_scope(node_id) => { - let scope_str = alt cx.items.find(node_id) { + let scope_str = match cx.items.find(node_id) { some(ast_map::node_block(blk)) => { explain_span(cx, ~"block", blk.span) } some(ast_map::node_expr(expr)) => { - alt expr.node { + match expr.node { ast::expr_call(*) => { explain_span(cx, ~"call", expr.span) } ast::expr_alt(*) => { explain_span(cx, ~"alt", expr.span) } _ => { explain_span(cx, ~"expression", expr.span) } @@ -47,7 +47,7 @@ fn explain_region(cx: ctxt, region: ty::region) -> ~str { } re_free(id, br) => { - alt cx.items.find(id) { + match cx.items.find(id) { some(ast_map::node_block(blk)) => { fmt!{"reference with lifetime %s as defined on %s", bound_region_to_str(cx, br), @@ -76,7 +76,7 @@ fn explain_region(cx: ctxt, region: ty::region) -> ~str { } fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { - alt br { + match br { br_anon => { ~"&" } br_named(str) => { fmt!{"&%s", *str} } br_self if cx.sess.ppregions() => { ~"&<self>" } @@ -95,13 +95,13 @@ fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { } fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { - alt cx.items.find(node_id) { + match cx.items.find(node_id) { some(ast_map::node_block(blk)) => { fmt!{"<block at %s>", codemap::span_to_str(blk.span, cx.sess.codemap)} } some(ast_map::node_expr(expr)) => { - alt expr.node { + match expr.node { ast::expr_call(*) => { fmt!{"<call at %s>", codemap::span_to_str(expr.span, cx.sess.codemap)} @@ -134,7 +134,7 @@ fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { } fn region_to_str(cx: ctxt, region: region) -> ~str { - alt region { + match region { re_scope(node_id) => { if cx.sess.ppregions() { fmt!{"&%s", re_scope_id_to_str(cx, node_id)} @@ -162,7 +162,7 @@ fn region_to_str(cx: ctxt, region: region) -> ~str { } fn mt_to_str(cx: ctxt, m: mt) -> ~str { - let mstr = alt m.mutbl { + let mstr = match m.mutbl { ast::m_mutbl => ~"mut ", ast::m_imm => ~"", ast::m_const => ~"const " @@ -171,7 +171,7 @@ fn mt_to_str(cx: ctxt, m: mt) -> ~str { } fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { - alt vs { + match vs { ty::vstore_fixed(n) => fmt!{"%u", n}, ty::vstore_uniq => ~"~", ty::vstore_box => ~"@", @@ -180,7 +180,7 @@ fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { } fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str { - alt vs { + match vs { ty::vstore_fixed(_) => { fmt!{"%s/%s", ty, vstore_to_str(cx, vs)} } @@ -198,7 +198,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) -> ~str { let {mode, ty} = input; - let modestr = alt canon_mode(cx, mode) { + let modestr = match canon_mode(cx, mode) { ast::infer(_) => ~"", ast::expl(m) => { if !ty::type_needs_infer(ty) && @@ -216,12 +216,12 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { inputs: ~[arg], output: t, cf: ast::ret_style) -> ~str { let mut s; - s = alt purity { + s = match purity { ast::impure_fn => ~"", _ => purity_to_str(purity) + ~" " }; s += proto_to_str(proto); - alt ident { + match ident { some(i) => { s += ~" "; s += *i; } _ => { } } @@ -232,7 +232,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { s += ~")"; if ty::get(output).struct != ty_nil { s += ~" -> "; - alt cf { + match cf { ast::noreturn => { s += ~"!"; } ast::return_val => { s += ty_to_str(cx, output); } } @@ -255,7 +255,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { } // pretty print the structural type representation: - return alt ty::get(typ).struct { + return match ty::get(typ).struct { ty_nil => ~"()", ty_bot => ~"_|_", ty_bool => ~"bool", @@ -325,7 +325,7 @@ fn parameterized(cx: ctxt, self_r: option<ty::region>, tps: ~[ty::t]) -> ~str { - let r_str = alt self_r { + let r_str = match self_r { none => ~"", some(r) => { fmt!{"/%s", region_to_str(cx, r)} diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 58341e2152d..655587b165d 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -77,7 +77,7 @@ fn act(po: comm::port<msg>, source: ~str, parse: parser) { let mut keep_going = true; while keep_going { - alt comm::recv(po) { + match comm::recv(po) { handle_request(f) => { f(ctxt); } diff --git a/src/rustdoc/attr_parser.rs b/src/rustdoc/attr_parser.rs index ba633111a6a..c590a1ac61e 100644 --- a/src/rustdoc/attr_parser.rs +++ b/src/rustdoc/attr_parser.rs @@ -93,7 +93,7 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() { } fn parse_desc(attrs: ~[ast::attribute]) -> option<~str> { - alt doc_meta(attrs) { + match doc_meta(attrs) { some(meta) => { attr::get_meta_item_value_str(meta).map(|x| *x ) } @@ -118,9 +118,9 @@ fn parse_desc_should_parse_simple_doc_attributes() { } fn parse_hidden(attrs: ~[ast::attribute]) -> bool { - alt doc_meta(attrs) { + match doc_meta(attrs) { some(meta) => { - alt attr::get_meta_item_list(meta) { + match attr::get_meta_item_list(meta) { some(metas) => { let hiddens = attr::find_meta_items_by_name(metas, ~"hidden"); vec::is_not_empty(hiddens) diff --git a/src/rustdoc/attr_pass.rs b/src/rustdoc/attr_pass.rs index 9c55ebc4a95..0a404ce1f51 100644 --- a/src/rustdoc/attr_pass.rs +++ b/src/rustdoc/attr_pass.rs @@ -93,7 +93,7 @@ fn parse_item_attrs<T:send>( id: doc::ast_id, +parse_attrs: fn~(~[ast::attribute]) -> T) -> T { do astsrv::exec(srv) |ctxt| { - let attrs = alt ctxt.ast_map.get(id) { + let attrs = match ctxt.ast_map.get(id) { ast_map::node_item(item, _) => item.attrs, ast_map::node_foreign_item(item, _, _) => item.attrs, _ => fail ~"parse_item_attrs: not an item" @@ -144,7 +144,7 @@ fn fold_enum( { variants: do par::map(doc.variants) |variant| { let desc = do astsrv::exec(srv) |ctxt| { - alt check ctxt.ast_map.get(doc_id) { + match check ctxt.ast_map.get(doc_id) { ast_map::node_item(@{ node: ast::item_enum(ast_variants, _), _ }, _) => { @@ -201,12 +201,12 @@ fn merge_method_attrs( // Create an assoc list from method name to attributes let attrs: ~[(~str, option<~str>)] = do astsrv::exec(srv) |ctxt| { - alt ctxt.ast_map.get(item_id) { + match ctxt.ast_map.get(item_id) { ast_map::node_item(@{ node: ast::item_trait(_, _, methods), _ }, _) => { vec::map(methods, |method| { - alt method { + match method { ast::required(ty_m) => { (*ty_m.ident, attr_parser::parse_desc(ty_m.attrs)) } diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs index 398892d715f..9a03a3e4455 100644 --- a/src/rustdoc/config.rs +++ b/src/rustdoc/config.rs @@ -100,7 +100,7 @@ fn parse_config_( ) -> result<config, ~str> { let args = vec::tail(args); let opts = vec::unzip(opts()).first(); - alt getopts::getopts(args, opts) { + match getopts::getopts(args, opts) { result::ok(matches) => { if vec::len(matches.free) == 1u { let input_crate = vec::head(matches.free); @@ -176,7 +176,7 @@ fn config_from_opts( } fn parse_output_format(output_format: ~str) -> result<output_format, ~str> { - alt output_format { + match output_format { ~"markdown" => result::ok(markdown), ~"html" => result::ok(pandoc_html), _ => result::err(fmt!{"unknown output format '%s'", output_format}) @@ -184,7 +184,7 @@ fn parse_output_format(output_format: ~str) -> result<output_format, ~str> { } fn parse_output_style(output_style: ~str) -> result<output_style, ~str> { - alt output_style { + match output_style { ~"doc-per-crate" => result::ok(doc_per_crate), ~"doc-per-mod" => result::ok(doc_per_mod), _ => result::err(fmt!{"unknown output style '%s'", output_style}) @@ -200,10 +200,10 @@ fn maybe_find_pandoc( return result::ok(maybe_pandoc_cmd); } - let possible_pandocs = alt maybe_pandoc_cmd { + let possible_pandocs = match maybe_pandoc_cmd { some(pandoc_cmd) => ~[pandoc_cmd], none => { - ~[~"pandoc"] + alt os::homedir() { + ~[~"pandoc"] + match os::homedir() { some(dir) => { ~[path::connect(dir, ~".cabal/bin/pandoc")] } diff --git a/src/rustdoc/desc_to_brief_pass.rs b/src/rustdoc/desc_to_brief_pass.rs index 76c74c71ef4..661eb3f879e 100644 --- a/src/rustdoc/desc_to_brief_pass.rs +++ b/src/rustdoc/desc_to_brief_pass.rs @@ -104,7 +104,7 @@ fn parse_desc(desc: ~str) -> option<~str> { const max_brief_len: uint = 120u; - alt first_sentence(desc) { + match first_sentence(desc) { some(first_sentence) => { if str::len(first_sentence) <= max_brief_len { some(first_sentence) @@ -143,7 +143,7 @@ fn first_sentence_(s: ~str) -> ~str { } } }; - alt idx { + match idx { some(idx) if idx > 2u => { str::slice(s, 0u, idx - 1u) } diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 723bcff5fb0..6fb1faa4483 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -141,7 +141,7 @@ type index_entry = { impl util for doc { fn cratedoc() -> cratedoc { option::get(vec::foldl(none, self.pages, |_m, page| { - alt page { + match page { doc::cratepage(doc) => some(doc), _ => none } @@ -158,7 +158,7 @@ impl util for moddoc { fn mods() -> ~[moddoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { modtag(moddoc) => some(moddoc), _ => none } @@ -167,7 +167,7 @@ impl util for moddoc { fn nmods() -> ~[nmoddoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { nmodtag(nmoddoc) => some(nmoddoc), _ => none } @@ -176,7 +176,7 @@ impl util for moddoc { fn fns() -> ~[fndoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { fntag(fndoc) => some(fndoc), _ => none } @@ -185,7 +185,7 @@ impl util for moddoc { fn consts() -> ~[constdoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { consttag(constdoc) => some(constdoc), _ => none } @@ -194,7 +194,7 @@ impl util for moddoc { fn enums() -> ~[enumdoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { enumtag(enumdoc) => some(enumdoc), _ => none } @@ -203,7 +203,7 @@ impl util for moddoc { fn traits() -> ~[traitdoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { traittag(traitdoc) => some(traitdoc), _ => none } @@ -212,7 +212,7 @@ impl util for moddoc { fn impls() -> ~[impldoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { impltag(impldoc) => some(impldoc), _ => none } @@ -221,7 +221,7 @@ impl util for moddoc { fn types() -> ~[tydoc] { do vec::filter_map(self.items) |itemtag| { - alt itemtag { + match itemtag { tytag(tydoc) => some(tydoc), _ => none } @@ -244,7 +244,7 @@ impl util of page_utils for ~[page] { fn mods() -> ~[moddoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(modtag(moddoc)) => some(moddoc), _ => none } @@ -253,7 +253,7 @@ impl util of page_utils for ~[page] { fn nmods() -> ~[nmoddoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(nmodtag(nmoddoc)) => some(nmoddoc), _ => none } @@ -262,7 +262,7 @@ impl util of page_utils for ~[page] { fn fns() -> ~[fndoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(fntag(fndoc)) => some(fndoc), _ => none } @@ -271,7 +271,7 @@ impl util of page_utils for ~[page] { fn consts() -> ~[constdoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(consttag(constdoc)) => some(constdoc), _ => none } @@ -280,7 +280,7 @@ impl util of page_utils for ~[page] { fn enums() -> ~[enumdoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(enumtag(enumdoc)) => some(enumdoc), _ => none } @@ -289,7 +289,7 @@ impl util of page_utils for ~[page] { fn traits() -> ~[traitdoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(traittag(traitdoc)) => some(traitdoc), _ => none } @@ -298,7 +298,7 @@ impl util of page_utils for ~[page] { fn impls() -> ~[impldoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(impltag(impldoc)) => some(impldoc), _ => none } @@ -307,7 +307,7 @@ impl util of page_utils for ~[page] { fn types() -> ~[tydoc] { do vec::filter_map(self) |page| { - alt page { + match page { itempage(tytag(tydoc)) => some(tydoc), _ => none } @@ -321,7 +321,7 @@ trait item { impl of item for itemtag { pure fn item() -> itemdoc { - alt self { + match self { doc::modtag(doc) => doc.item, doc::nmodtag(doc) => doc.item, doc::fntag(doc) => doc.item, diff --git a/src/rustdoc/extract.rs b/src/rustdoc/extract.rs index 7d56efcc4ee..b8be338bffd 100644 --- a/src/rustdoc/extract.rs +++ b/src/rustdoc/extract.rs @@ -58,7 +58,7 @@ fn moddoc_from_mod( item: itemdoc, items: do vec::filter_map(module_.items) |item| { let itemdoc = mk_itemdoc(item.id, item.ident); - alt item.node { + match item.node { ast::item_mod(m) => { some(doc::modtag( moddoc_from_mod(itemdoc, m) @@ -114,7 +114,7 @@ fn nmoddoc_from_mod( item: itemdoc, fns: do vec::map(module_.items) |item| { let itemdoc = mk_itemdoc(item.id, item.ident); - alt item.node { + match item.node { ast::foreign_item_fn(_, _) => { fndoc_from_fn(itemdoc) } @@ -189,7 +189,7 @@ fn traitdoc_from_trait( { item: itemdoc, methods: do vec::map(methods) |method| { - alt method { + match method { ast::required(ty_m) => { { name: *ty_m.ident, diff --git a/src/rustdoc/fold.rs b/src/rustdoc/fold.rs index b848c6b8899..45d4882a87b 100644 --- a/src/rustdoc/fold.rs +++ b/src/rustdoc/fold.rs @@ -134,7 +134,7 @@ fn default_par_fold<T:send copy>(ctxt: T) -> fold<T> { fn default_seq_fold_doc<T>(fold: fold<T>, doc: doc::doc) -> doc::doc { doc::doc_({ pages: do vec::map(doc.pages) |page| { - alt page { + match page { doc::cratepage(doc) => { doc::cratepage(fold.fold_crate(fold, doc)) } @@ -242,7 +242,7 @@ fn default_par_fold_nmod<T:send copy>( } fn fold_itemtag<T>(fold: fold<T>, doc: doc::itemtag) -> doc::itemtag { - alt doc { + match doc { doc::modtag(moddoc) => { doc::modtag(fold.fold_mod(fold, moddoc)) } diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 123ad89ecd4..9a58d0c9179 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -78,7 +78,7 @@ fn item_to_entry( doc: doc::itemtag, config: config::config ) -> doc::index_entry { - let link = alt doc { + let link = match doc { doc::modtag(_) | doc::nmodtag(_) if config.output_style == config::doc_per_mod => { markdown_writer::make_filename(config, doc::itempage(doc)) diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index 90d00d292b1..dbba57960c0 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -28,7 +28,7 @@ fn run( pure fn mods_last(item1: &doc::itemtag, item2: &doc::itemtag) -> bool { pure fn is_mod(item: &doc::itemtag) -> bool { - alt *item { + match *item { doc::modtag(_) => true, _ => false } @@ -94,7 +94,7 @@ fn write_markdown( fn write_page(ctxt: ctxt, page: doc::page) { write_title(ctxt, page); - alt page { + match page { doc::cratepage(doc) => { write_crate(ctxt, doc); } @@ -128,7 +128,7 @@ fn write_title(ctxt: ctxt, page: doc::page) { } fn make_title(page: doc::page) -> ~str { - let item = alt page { + let item = match page { doc::cratepage(cratedoc) => { doc::modtag(cratedoc.topmod) } @@ -150,7 +150,7 @@ fn should_write_title_for_each_page() { write_markdown(doc, writer_factory); for iter::repeat(2u) { let (page, markdown) = comm::recv(po); - alt page { + match page { doc::cratepage(_) => { assert str::contains(markdown, ~"% Crate core"); } @@ -180,7 +180,7 @@ fn write_header_(ctxt: ctxt, lvl: hlvl, title: ~str) { } fn header_kind(doc: doc::itemtag) -> ~str { - alt doc { + match doc { doc::modtag(_) => { if doc.id() == syntax::ast::crate_node_id { ~"Crate" @@ -214,7 +214,7 @@ fn header_kind(doc: doc::itemtag) -> ~str { fn header_name(doc: doc::itemtag) -> ~str { let fullpath = str::connect(doc.path() + ~[doc.name()], ~"::"); - alt doc { + match doc { doc::modtag(_) if doc.id() != syntax::ast::crate_node_id => { fullpath } @@ -289,7 +289,7 @@ fn write_desc( ctxt: ctxt, desc: option<~str> ) { - alt desc { + match desc { some(desc) => { ctxt.w.write_line(desc); ctxt.w.write_line(~""); @@ -347,7 +347,7 @@ fn write_item_(ctxt: ctxt, doc: doc::itemtag, write_header: bool) { write_item_header(ctxt, doc); } - alt doc { + match doc { doc::modtag(moddoc) => write_mod(ctxt, moddoc), doc::nmodtag(nmoddoc) => write_nmod(ctxt, nmoddoc), doc::fntag(fndoc) => write_fn(ctxt, fndoc), @@ -364,7 +364,7 @@ fn write_item_header(ctxt: ctxt, doc: doc::itemtag) { } fn item_header_lvl(doc: doc::itemtag) -> hlvl { - alt doc { + match doc { doc::modtag(_) | doc::nmodtag(_) => h1, _ => h2 } @@ -481,7 +481,7 @@ fn write_fnlike( } fn write_sig(ctxt: ctxt, sig: option<~str>) { - alt sig { + match sig { some(sig) => { ctxt.w.write_line(code_block_indent(sig)); ctxt.w.write_line(~""); @@ -602,7 +602,7 @@ fn write_variants( fn write_variant(ctxt: ctxt, doc: doc::variantdoc) { assert option::is_some(doc.sig); let sig = option::get(doc.sig); - alt doc.desc { + match doc.desc { some(desc) => { ctxt.w.write_line(fmt!{"* `%s` - %s", sig, desc}); } diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index 3f46f8f3d5b..a3b40a1caaa 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -38,7 +38,7 @@ impl writer_util of writer_utils for writer { } fn make_writer_factory(config: config::config) -> writer_factory { - alt config.output_format { + match config.output_format { config::markdown => { markdown_writer_factory(config) } @@ -150,7 +150,7 @@ fn generic_writer(+process: fn~(markdown: ~str)) -> writer { let mut markdown = ~""; let mut keep_going = true; while keep_going { - alt comm::recv(po) { + match comm::recv(po) { write(s) => markdown += s, done => keep_going = false } @@ -176,7 +176,7 @@ fn make_filename( page: doc::page ) -> ~str { let filename = { - alt page { + match page { doc::cratepage(doc) => { if config.output_format == config::pandoc_html && config.output_style == config::doc_per_mod { @@ -191,7 +191,7 @@ fn make_filename( } } }; - let ext = alt config.output_format { + let ext = match config.output_format { config::markdown => ~"md", config::pandoc_html => ~"html" }; @@ -256,7 +256,7 @@ mod test { fn write_file(path: ~str, s: ~str) { import io::writer_util; - alt io::file_writer(path, ~[io::create, io::truncate]) { + match io::file_writer(path, ~[io::create, io::truncate]) { result::ok(writer) => { writer.write_str(s); } @@ -292,7 +292,7 @@ fn future_writer() -> (writer, future::future<~str>) { let future = do future::from_fn { let mut res = ~""; loop { - alt comm::recv(port) { + match comm::recv(port) { write(s) => res += s, done => break } diff --git a/src/rustdoc/page_pass.rs b/src/rustdoc/page_pass.rs index 11cf4f735cf..09543ae59ca 100644 --- a/src/rustdoc/page_pass.rs +++ b/src/rustdoc/page_pass.rs @@ -106,7 +106,7 @@ fn fold_mod( fn strip_mod(doc: doc::moddoc) -> doc::moddoc { doc::moddoc_({ items: do vec::filter(doc.items) |item| { - alt item { + match item { doc::modtag(_) => false, doc::nmodtag(_) => false, _ => true diff --git a/src/rustdoc/prune_hidden_pass.rs b/src/rustdoc/prune_hidden_pass.rs index d8060257a63..970c081903a 100644 --- a/src/rustdoc/prune_hidden_pass.rs +++ b/src/rustdoc/prune_hidden_pass.rs @@ -38,7 +38,7 @@ fn is_hidden(srv: astsrv::srv, doc: doc::itemdoc) -> bool { let id = doc.id; do astsrv::exec(srv) |ctxt| { - let attrs = alt ctxt.ast_map.get(id) { + let attrs = match ctxt.ast_map.get(id) { ast_map::node_item(item, _) => item.attrs, _ => ~[] }; diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index 015da4b52d8..eb6c88c62e7 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -107,7 +107,7 @@ fn main(args: ~[~str]) { return; } - let config = alt config::parse_config(args) { + let config = match config::parse_config(args) { result::ok(config) => config, result::err(err) => { io::println(fmt!{"error: %s", err}); diff --git a/src/rustdoc/sectionalize_pass.rs b/src/rustdoc/sectionalize_pass.rs index 29bebdf10e5..0ff86ecbcbe 100644 --- a/src/rustdoc/sectionalize_pass.rs +++ b/src/rustdoc/sectionalize_pass.rs @@ -95,7 +95,7 @@ fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { let mut sections = ~[]; for lines.each |line| { - alt parse_header(line) { + match parse_header(line) { some(header) => { if option::is_some(current_section) { sections += ~[option::get(current_section)]; @@ -106,7 +106,7 @@ fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { }); } none => { - alt copy current_section { + match copy current_section { some(section) => { current_section = some({ body: section.body + ~"\n" + line @@ -114,7 +114,7 @@ fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { }); } none => { - new_desc = alt new_desc { + new_desc = match new_desc { some(desc) => { some(desc + ~"\n" + line) } diff --git a/src/rustdoc/sort_item_type_pass.rs b/src/rustdoc/sort_item_type_pass.rs index afa299345dc..1d619f0a8f1 100644 --- a/src/rustdoc/sort_item_type_pass.rs +++ b/src/rustdoc/sort_item_type_pass.rs @@ -7,7 +7,7 @@ export mk_pass; fn mk_pass() -> pass { pure fn by_score(item1: &doc::itemtag, item2: &doc::itemtag) -> bool { pure fn score(item: &doc::itemtag) -> int { - alt *item { + match *item { doc::consttag(_) => 0, doc::tytag(_) => 1, doc::enumtag(_) => 2, diff --git a/src/rustdoc/tystr_pass.rs b/src/rustdoc/tystr_pass.rs index a2ae6d5eba4..ba3b9f74ab3 100644 --- a/src/rustdoc/tystr_pass.rs +++ b/src/rustdoc/tystr_pass.rs @@ -46,7 +46,7 @@ fn fold_fn( fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option<~str> { do astsrv::exec(srv) |ctxt| { - alt check ctxt.ast_map.get(fn_id) { + match check ctxt.ast_map.get(fn_id) { ast_map::node_item(@{ ident: ident, node: ast::item_fn(decl, tys, _), _ @@ -81,7 +81,7 @@ fn fold_const( { sig: some(do astsrv::exec(srv) |ctxt| { - alt check ctxt.ast_map.get(doc.id()) { + match check ctxt.ast_map.get(doc.id()) { ast_map::node_item(@{ node: ast::item_const(ty, _), _ }, _) => { @@ -109,7 +109,7 @@ fn fold_enum( { variants: do par::map(doc.variants) |variant| { let sig = do astsrv::exec(srv) |ctxt| { - alt check ctxt.ast_map.get(doc_id) { + match check ctxt.ast_map.get(doc_id) { ast_map::node_item(@{ node: ast::item_enum(ast_variants, _), _ }, _) => { @@ -167,18 +167,18 @@ fn get_method_sig( method_name: ~str ) -> option<~str> { do astsrv::exec(srv) |ctxt| { - alt check ctxt.ast_map.get(item_id) { + match check ctxt.ast_map.get(item_id) { ast_map::node_item(@{ node: ast::item_trait(_, _, methods), _ }, _) => { - alt check vec::find(methods, |method| { - alt method { + match check vec::find(methods, |method| { + match method { ast::required(ty_m) => *ty_m.ident == method_name, ast::provided(m) => *m.ident == method_name, } }) { some(method) => { - alt method { + match method { ast::required(ty_m) => { some(pprust::fun_to_str( ty_m.decl, @@ -200,7 +200,7 @@ fn get_method_sig( ast_map::node_item(@{ node: ast::item_impl(_, _, _, methods), _ }, _) => { - alt check vec::find(methods, |method| { + match check vec::find(methods, |method| { *method.ident == method_name }) { some(method) => { @@ -231,7 +231,7 @@ fn fold_impl( let srv = fold.ctxt; let (trait_types, self_ty) = do astsrv::exec(srv) |ctxt| { - alt ctxt.ast_map.get(doc.id()) { + match ctxt.ast_map.get(doc.id()) { ast_map::node_item(@{ node: ast::item_impl(_, trait_types, self_ty, _), _ }, _) => { @@ -286,7 +286,7 @@ fn fold_type( { sig: do astsrv::exec(srv) |ctxt| { - alt ctxt.ast_map.get(doc.id()) { + match ctxt.ast_map.get(doc.id()) { ast_map::node_item(@{ ident: ident, node: ast::item_ty(ty, params), _ diff --git a/src/test/auxiliary/issue2378a.rs b/src/test/auxiliary/issue2378a.rs index 3a681ef7a3b..b34ba63404c 100644 --- a/src/test/auxiliary/issue2378a.rs +++ b/src/test/auxiliary/issue2378a.rs @@ -2,7 +2,7 @@ enum maybe<T> { just(T), nothing } impl methods<T:copy> for maybe<T> { fn ~[](idx: uint) -> T { - alt self { + match self { just(t) { t } nothing { fail; } } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 3c7057320ec..dd92b28c41c 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -76,7 +76,7 @@ fn str_set() { let mut found = 0; for int::range(0, 1000) |_i| { - alt s.find(r.gen_str(10)) { + match s.find(r.gen_str(10)) { some(_) => { found += 1; } none => { } } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index dfc74f12cef..d510b978f93 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -157,7 +157,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { }; fn is_gray(c: color) -> bool { - alt c { + match c { gray(_) => { true } _ => { false } } @@ -170,7 +170,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { i += 1u; colors = do colors.mapi() |i, c| { let c : color = c; - alt c { + match c { white => { let i = i as node_id; @@ -196,7 +196,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { // Convert the results. do vec::map(colors) |c| { - alt c { + match c { white => { -1i64 } black(parent) => { parent } _ => { fail ~"Found remaining gray nodes in BFS" } @@ -227,7 +227,7 @@ fn pbfs(&&graph: arc::arc<graph>, key: node_id) -> bfs_result { #[inline(always)] fn is_gray(c: color) -> bool { - alt c { + match c { gray(_) => { true } _ => { false } } @@ -249,7 +249,7 @@ fn pbfs(&&graph: arc::arc<graph>, key: node_id) -> bfs_result { let c : color = c; let colors = arc::get(&colors); let graph = arc::get(&graph); - alt c { + match c { white => { let i = i as node_id; @@ -276,7 +276,7 @@ fn pbfs(&&graph: arc::arc<graph>, key: node_id) -> bfs_result { // Convert the results. do par::map(colors) |c| { - alt c { + match c { white => { -1i64 } black(parent) => { parent } _ => { fail ~"Found remaining gray nodes in BFS" } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index e0ebda079f7..423cec10f5a 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -31,7 +31,7 @@ fn server(requests: port<request>, responses: pipes::chan<uint>) { let mut count = 0u; let mut done = false; while !done { - alt requests.try_recv() { + match requests.try_recv() { some(get_count) => { responses.send(copy count); } some(bytes(b)) => { //error!{"server: received %? bytes", b}; diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 067bd710b3d..60cc52825e8 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -26,7 +26,7 @@ fn server(requests: port_set<request>, responses: pipes::chan<uint>) { let mut count = 0u; let mut done = false; while !done { - alt requests.try_recv() { + match requests.try_recv() { some(get_count) => { responses.send(copy count); } some(bytes(b)) => { //error!{"server: received %? bytes", b}; diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs index c494bfc485a..42df57f5bf3 100644 --- a/src/test/bench/msgsend-ring-pipes.rs +++ b/src/test/bench/msgsend-ring-pipes.rs @@ -43,7 +43,7 @@ fn thread_ring(i: uint, num_port2 <-> num_port; num_chan = some(ring::client::num(option::unwrap(num_chan2), i * j)); let port = option::unwrap(num_port2); - alt recv(port) { + match recv(port) { ring::num(_n, p) => { //log(error, _n); num_port = some(move_out!{p}); diff --git a/src/test/bench/msgsend.rs b/src/test/bench/msgsend.rs index 5b2488efa2f..adbf6253214 100644 --- a/src/test/bench/msgsend.rs +++ b/src/test/bench/msgsend.rs @@ -18,7 +18,7 @@ fn server(requests: comm::port<request>, responses: comm::chan<uint>) { let mut count = 0u; let mut done = false; while !done { - alt comm::recv(requests) { + match comm::recv(requests) { get_count => { comm::send(responses, copy count); } bytes(b) => { count += b; } stop => { done = true; } diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index 2a9a20fc07d..17830af6869 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -40,7 +40,7 @@ macro_rules! follow { { $($message:path($($x: ident),+) -> $next:ident $e:expr)+ } => ( - |m| alt move m { + |m| match move m { $(some($message($($x,)* next)) => { // FIXME (#2329) use regular move here once move out of // enums is supported. @@ -53,7 +53,7 @@ macro_rules! follow { { $($message:path -> $next:ident $e:expr)+ } => ( - |m| alt move m { + |m| match move m { $(some($message(next)) => { // FIXME (#2329) use regular move here once move out of // enums is supported. diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index be3a868beb2..c9a984117da 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -5,7 +5,7 @@ import methods = std::arena::arena; enum tree/& { nil, node(&tree, &tree, int), } fn item_check(t: &tree) -> int { - alt *t { + match *t { nil => { return 0; } node(left, right, item) => { return item + item_check(left) - item_check(right); diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 7adc176bcff..fd367181df4 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -22,7 +22,7 @@ enum color { Red, Yellow, Blue } type creature_info = { name: uint, color: color }; fn show_color(cc: color) -> ~str { - alt (cc) { + match (cc) { Red => {~"red"} Yellow => {~"yellow"} Blue => {~"blue"} @@ -39,7 +39,7 @@ fn show_color_list(set: ~[color]) -> ~str { } fn show_digit(nn: uint) -> ~str { - alt (nn) { + match (nn) { 0 => {~"zero"} 1 => {~"one"} 2 => {~"two"} @@ -71,7 +71,7 @@ fn show_number(nn: uint) -> ~str { } fn transform(aa: color, bb: color) -> color { - alt (aa, bb) { + match (aa, bb) { (Red, Red ) => { Red } (Red, Yellow) => { Blue } (Red, Blue ) => { Yellow } @@ -101,7 +101,7 @@ fn creature( let resp = comm::recv(from_rendezvous); // log and change, or print and quit - alt resp { + match resp { option::some(other_creature) => { color = transform(color, other_creature.color); diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index ca014b61455..7aed4749eed 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -59,7 +59,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { // given a map, search for the frequency of a pattern fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint { - alt mm.find(str::bytes(str::to_lower(key))) { + match mm.find(str::bytes(str::to_lower(key))) { option::none => { return 0u; } option::some(num) => { return num; } } @@ -68,7 +68,7 @@ fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint { // given a map, increment the counter for a key fn update_freq(mm: hashmap<~[u8], uint>, key: &[u8]) { let key = vec::slice(key, 0, key.len()); - alt mm.find(key) { + match mm.find(key) { option::none => { mm.insert(key, 1u ); } option::some(val) => { mm.insert(key, 1u + val); } } @@ -110,7 +110,7 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::port<~[u8]>, }); } - let buffer = alt sz { + let buffer = match sz { 1u => { sort_and_fmt(freqs, total) } 2u => { sort_and_fmt(freqs, total) } 3u => { fmt!{"%u\t%s", find(freqs, ~"GGT"), ~"GGT"} } @@ -172,11 +172,11 @@ fn main(args: ~[~str]) { if str::len(line) == 0u { again; } - alt (line[0], proc_mode) { + match (line[0], proc_mode) { // start processing if this is the one ('>' as u8, false) => { - alt str::find_str_from(line, ~"THREE", 1u) { + match str::find_str_from(line, ~"THREE", 1u) { option::some(_) => { proc_mode = true; } option::none => { } } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 5ffa7cc4f26..6eeb50d52f5 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -57,7 +57,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { // given a map, search for the frequency of a pattern fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint { - alt mm.find(str::bytes(str::to_lower(key))) { + match mm.find(str::bytes(str::to_lower(key))) { option::none => { return 0u; } option::some(num) => { return num; } } @@ -66,7 +66,7 @@ fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint { // given a map, increment the counter for a key fn update_freq(mm: hashmap<~[u8], uint>, key: &[u8]) { let key = vec::slice(key, 0, key.len()); - alt mm.find(key) { + match mm.find(key) { option::none => { mm.insert(key, 1u ); } option::some(val) => { mm.insert(key, 1u + val); } } @@ -108,7 +108,7 @@ fn make_sequence_processor(sz: uint, from_parent: comm::port<~[u8]>, }); } - let buffer = alt sz { + let buffer = match sz { 1u => { sort_and_fmt(freqs, total) } 2u => { sort_and_fmt(freqs, total) } 3u => { fmt!{"%u\t%s", find(freqs, ~"GGT"), ~"GGT"} } @@ -159,11 +159,11 @@ fn main(args: ~[~str]) { if str::len(line) == 0u { again; } - alt (line[0], proc_mode) { + match (line[0], proc_mode) { // start processing if this is the one ('>' as u8, false) => { - alt str::find_str_from(line, ~"THREE", 1u) { + match str::find_str_from(line, ~"THREE", 1u) { option::some(_) => proc_mode = true, option::none => () } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index f00396f9b14..93a1d60ff7f 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -103,7 +103,7 @@ fn writer(path: ~str, writech: comm::chan<comm::chan<line>>, size: uint) let p: comm::port<line> = comm::port(); let ch = comm::chan(p); comm::send(writech, ch); - let cout: io::writer = alt path { + let cout: io::writer = match path { ~"" => { {dn: 0} as io::writer } diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 3889fa00ff0..4b4d41e72ba 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -51,7 +51,7 @@ fn parse_opts(argv: ~[~str]) -> config { let opt_args = vec::slice(argv, 1u, vec::len(argv)); - alt getopts::getopts(opt_args, opts) { + match getopts::getopts(opt_args, opts) { ok(m) => { return {stress: getopts::opt_present(m, ~"stress")} } err(_) => { fail; } } diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index e99d2946e81..26bc2b739fa 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -21,7 +21,7 @@ fn start(+token: int) { fn roundtrip(id: int, p: comm::port<int>, ch: comm::chan<int>) { while (true) { - alt comm::recv(p) { + match comm::recv(p) { 1 => { io::println(fmt!{"%d\n", id}); return; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 2a8750b64bd..eac1f67dcaa 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -53,7 +53,7 @@ fn recurse_or_fail(depth: int, st: option<st>) { } else { let depth = depth - 1; - let st = alt st { + let st = match st { none => { st_({ box: @nil, diff --git a/src/test/bench/task-perf-one-million.rs b/src/test/bench/task-perf-one-million.rs index 85008b0daf9..7b434a5f255 100644 --- a/src/test/bench/task-perf-one-million.rs +++ b/src/test/bench/task-perf-one-million.rs @@ -19,7 +19,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) { } for iter::repeat (children) { - alt check comm::recv(port) { + match check comm::recv(port) { ready(child_ch) => { vec::push(child_chs, child_ch); } @@ -28,7 +28,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) { comm::send(parent_ch, ready(chan)); - alt check comm::recv(port) { + match check comm::recv(port) { start => { do vec::iter (child_chs) |child_ch| { comm::send(child_ch, start); @@ -37,7 +37,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) { } for iter::repeat (children) { - alt check comm::recv(port) { + match check comm::recv(port) { done(child_sum) => { sum += child_sum; } } } @@ -60,12 +60,12 @@ fn main(args: ~[~str]) { do task::spawn { calc(children, chan); }; - alt check comm::recv(port) { + match check comm::recv(port) { ready(chan) => { comm::send(chan, start); } } - let sum = alt check comm::recv(port) { + let sum = match check comm::recv(port) { done(sum) => { sum } }; error!{"How many tasks? %d tasks.", sum}; diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index c31ccde2ca6..2281939b57a 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -79,7 +79,7 @@ impl of word_reader for io::reader { } fn file_word_reader(filename: ~str) -> word_reader { - alt io::file_reader(filename) { + match io::file_reader(filename) { result::ok(f) => { f as word_reader } result::err(e) => { fail fmt!{"%?", e} } } @@ -88,7 +88,7 @@ fn file_word_reader(filename: ~str) -> word_reader { fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) { let f = f(); loop { - alt f.read_word() { + match f.read_word() { some(w) => { emit(w, 1); } none => { break; } } @@ -98,7 +98,7 @@ fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) { fn reduce(&&word: ~str, get: map_reduce::getter<int>) { let mut count = 0; - loop { alt get() { some(_) => { count += 1; } none => { break; } } } + loop { match get() { some(_) => { count += 1; } none => { break; } } } io::println(fmt!{"%s\t%?", word, count}); } @@ -181,12 +181,12 @@ mod map_reduce { do map(input) |key, val| { let mut c = none; - alt intermediates.find(key) { + match intermediates.find(key) { some(_c) => { c = some(_c); } none => { do ctrl.swap |ctrl| { let ctrl = ctrl_proto::client::find_reducer(ctrl, key); - alt pipes::recv(ctrl) { + match pipes::recv(ctrl) { ctrl_proto::reducer(c_, ctrl) => { c = some(c_); move_out!{ctrl} @@ -224,7 +224,7 @@ mod map_reduce { &ref_count: int, &is_done: bool) -> option<V> { while !is_done || ref_count > 0 { - alt recv(p) { + match recv(p) { emit_val(v) => { // error!{"received %d", v}; return some(v); @@ -259,7 +259,7 @@ mod map_reduce { while num_mappers > 0 { let (_ready, message, ctrls) = pipes::select(ctrl); - alt option::unwrap(message) { + match option::unwrap(message) { ctrl_proto::mapper_done => { // error!{"received mapper terminated."}; num_mappers -= 1; @@ -268,7 +268,7 @@ mod map_reduce { ctrl_proto::find_reducer(k, cc) => { let c; // log(error, "finding reducer for " + k); - alt reducers.find(k) { + match reducers.find(k) { some(_c) => { // log(error, // "reusing existing reducer for " + k); diff --git a/src/test/compile-fail/alt-arrows-block-then-binop.rs b/src/test/compile-fail/alt-arrows-block-then-binop.rs index 037e0c8b517..7b973633c7d 100644 --- a/src/test/compile-fail/alt-arrows-block-then-binop.rs +++ b/src/test/compile-fail/alt-arrows-block-then-binop.rs @@ -1,6 +1,6 @@ fn main() { - alt 0 { + match 0 { 0 => { } + 5 //~ ERROR unexpected token: `+` } diff --git a/src/test/compile-fail/alt-join.rs b/src/test/compile-fail/alt-join.rs index 1557ff12090..83dcc69609e 100644 --- a/src/test/compile-fail/alt-join.rs +++ b/src/test/compile-fail/alt-join.rs @@ -4,7 +4,7 @@ fn my_fail() -> ! { fail; } fn main() { - alt true { false => { my_fail(); } true => { } } + match true { false => { my_fail(); } true => { } } log(debug, x); //~ ERROR unresolved name: x let x: int; diff --git a/src/test/compile-fail/alt-pattern-field-mismatch-2.rs b/src/test/compile-fail/alt-pattern-field-mismatch-2.rs index 6ba942decfc..617bb168629 100644 --- a/src/test/compile-fail/alt-pattern-field-mismatch-2.rs +++ b/src/test/compile-fail/alt-pattern-field-mismatch-2.rs @@ -6,7 +6,7 @@ fn main() { } fn foo(c: color) { - alt c { + match c { rgb(_, _, _) => { } cmyk(_, _, _, _) => { } no_color(_) => { } diff --git a/src/test/compile-fail/alt-pattern-field-mismatch.rs b/src/test/compile-fail/alt-pattern-field-mismatch.rs index 71f44764e14..9a54985efc1 100644 --- a/src/test/compile-fail/alt-pattern-field-mismatch.rs +++ b/src/test/compile-fail/alt-pattern-field-mismatch.rs @@ -6,7 +6,7 @@ fn main() { } fn foo(c: color) { - alt c { + match c { rgb(_, _) => { } //~^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields cmyk(_, _, _, _) => { } diff --git a/src/test/compile-fail/alt-range-fail-dominate.rs b/src/test/compile-fail/alt-range-fail-dominate.rs index d1ba0f625b1..f58d0865265 100644 --- a/src/test/compile-fail/alt-range-fail-dominate.rs +++ b/src/test/compile-fail/alt-range-fail-dominate.rs @@ -5,27 +5,27 @@ //error-pattern: unreachable fn main() { - alt check 5u { + match check 5u { 1u to 10u => { } 5u to 6u => { } }; - alt check 5u { + match check 5u { 3u to 6u => { } 4u to 6u => { } }; - alt check 5u { + match check 5u { 4u to 6u => { } 4u to 6u => { } }; - alt check 'c' { + match check 'c' { 'A' to 'z' => {} 'a' to 'z' => {} }; - alt check 1.0 { + match check 1.0 { 0.01 to 6.5 => {} 0.02 => {} }; diff --git a/src/test/compile-fail/alt-range-fail.rs b/src/test/compile-fail/alt-range-fail.rs index afda6d7015e..229b5c47eba 100644 --- a/src/test/compile-fail/alt-range-fail.rs +++ b/src/test/compile-fail/alt-range-fail.rs @@ -3,16 +3,16 @@ //error-pattern: mismatched types fn main() { - alt 5u { + match 5u { 6u to 1u => { } _ => { } }; - alt "wow" { + match "wow" { "bar" to "foo" => { } }; - alt 5u { + match 5u { 'c' to 100u => { } _ => { } }; diff --git a/src/test/compile-fail/alt-tag-nullary.rs b/src/test/compile-fail/alt-tag-nullary.rs index 4f34c675cef..9f7b471221d 100644 --- a/src/test/compile-fail/alt-tag-nullary.rs +++ b/src/test/compile-fail/alt-tag-nullary.rs @@ -3,5 +3,5 @@ enum a { A, } enum b { B, } -fn main() { let x: a = A; alt x { B => { } } } +fn main() { let x: a = A; match x { B => { } } } diff --git a/src/test/compile-fail/alt-tag-unary.rs b/src/test/compile-fail/alt-tag-unary.rs index f0546574912..5902454c461 100644 --- a/src/test/compile-fail/alt-tag-unary.rs +++ b/src/test/compile-fail/alt-tag-unary.rs @@ -3,5 +3,5 @@ enum a { A(int), } enum b { B(int), } -fn main() { let x: a = A(0); alt x { B(y) => { } } } +fn main() { let x: a = A(0); match x { B(y) => { } } } diff --git a/src/test/compile-fail/bad-alt.rs b/src/test/compile-fail/bad-alt.rs index 4d8de65492f..041f84bc6ee 100644 --- a/src/test/compile-fail/bad-alt.rs +++ b/src/test/compile-fail/bad-alt.rs @@ -2,5 +2,5 @@ fn main() { let int x = 5; - alt x; + match x; } diff --git a/src/test/compile-fail/bad-record-pat-2.rs b/src/test/compile-fail/bad-record-pat-2.rs index 4c8d72444c1..c043a076042 100644 --- a/src/test/compile-fail/bad-record-pat-2.rs +++ b/src/test/compile-fail/bad-record-pat-2.rs @@ -1,3 +1,3 @@ // error-pattern:did not expect a record with a field `q` -fn main() { alt {x: 1, y: 2} { {x: x, q: q} => { } } } +fn main() { match {x: 1, y: 2} { {x: x, q: q} => { } } } diff --git a/src/test/compile-fail/bad-record-pat.rs b/src/test/compile-fail/bad-record-pat.rs index 48155a0b529..d7e7fb16ad8 100644 --- a/src/test/compile-fail/bad-record-pat.rs +++ b/src/test/compile-fail/bad-record-pat.rs @@ -1,3 +1,3 @@ // error-pattern:expected a record with 2 fields, found one with 1 -fn main() { alt {x: 1, y: 2} { {x: x} => { } } } +fn main() { match {x: 1, y: 2} { {x: x} => { } } } diff --git a/src/test/compile-fail/bogus-tag.rs b/src/test/compile-fail/bogus-tag.rs index 0414bb5e867..06cfb60e1a8 100644 --- a/src/test/compile-fail/bogus-tag.rs +++ b/src/test/compile-fail/bogus-tag.rs @@ -6,7 +6,7 @@ enum color { rgb(int, int, int), rgba(int, int, int, int), } fn main() { let red: color = rgb(255, 0, 0); - alt red { + match red { rgb(r, g, b) => { debug!{"rgb"}; } hsl(h, s, l) => { debug!{"hsl"}; } } diff --git a/src/test/compile-fail/borrowck-binding-mutbl.rs b/src/test/compile-fail/borrowck-binding-mutbl.rs index 8a188fe9239..57c0375f4e4 100644 --- a/src/test/compile-fail/borrowck-binding-mutbl.rs +++ b/src/test/compile-fail/borrowck-binding-mutbl.rs @@ -4,7 +4,7 @@ fn impure(_v: ~[int]) { fn main() { let x = {mut f: ~[3]}; - alt x { + match x { {f: v} => { impure(v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location //~^ NOTE impure due to access to impure function diff --git a/src/test/compile-fail/borrowck-issue-2657-1.rs b/src/test/compile-fail/borrowck-issue-2657-1.rs index 2d396bd591c..f8cbb52d996 100644 --- a/src/test/compile-fail/borrowck-issue-2657-1.rs +++ b/src/test/compile-fail/borrowck-issue-2657-1.rs @@ -1,6 +1,6 @@ fn main() { let x = some(~1); -alt x { //~ NOTE loan of immutable local variable granted here +match x { //~ NOTE loan of immutable local variable granted here some(y) => { let _a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan } diff --git a/src/test/compile-fail/borrowck-issue-2657-2.rs b/src/test/compile-fail/borrowck-issue-2657-2.rs index 85d062dd98c..ab6e63174aa 100644 --- a/src/test/compile-fail/borrowck-issue-2657-2.rs +++ b/src/test/compile-fail/borrowck-issue-2657-2.rs @@ -1,6 +1,6 @@ fn main() { let x = some(~1); -alt x { +match x { some(y) => { let _b <- y; //~ ERROR moving out of pattern binding } diff --git a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs index acb018dbb2d..ef696048219 100644 --- a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs +++ b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs @@ -5,7 +5,7 @@ enum cycle { fn main() { let x = ~node({mut a: ~empty}); // Create a cycle! - alt check *x { //~ NOTE loan of immutable local variable granted here + match check *x { //~ NOTE loan of immutable local variable granted here node(y) => { y.a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan } diff --git a/src/test/compile-fail/borrowck-pat-enum-in-box.rs b/src/test/compile-fail/borrowck-pat-enum-in-box.rs index 103de904609..cd4893f87f2 100644 --- a/src/test/compile-fail/borrowck-pat-enum-in-box.rs +++ b/src/test/compile-fail/borrowck-pat-enum-in-box.rs @@ -1,12 +1,12 @@ fn match_imm_box(v: &const @option<int>) -> int { - alt *v { + match *v { @some(i) => {i} @none => {0} } } fn match_const_box(v: &const @const option<int>) -> int { - alt *v { + match *v { @some(i) => { i } // ok because this is pure @none => {0} } @@ -15,7 +15,7 @@ fn match_const_box(v: &const @const option<int>) -> int { pure fn pure_process(_i: int) {} fn match_const_box_and_do_pure_things(v: &const @const option<int>) { - alt *v { + match *v { @some(i) => { pure_process(i) } @@ -26,7 +26,7 @@ fn match_const_box_and_do_pure_things(v: &const @const option<int>) { fn process(_i: int) {} fn match_const_box_and_do_bad_things(v: &const @const option<int>) { - alt *v { + match *v { @some(i) => { //~ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location process(i) //~ NOTE impure due to access to impure function } diff --git a/src/test/compile-fail/borrowck-pat-enum.rs b/src/test/compile-fail/borrowck-pat-enum.rs index 6dd37e647ac..b29321ed818 100644 --- a/src/test/compile-fail/borrowck-pat-enum.rs +++ b/src/test/compile-fail/borrowck-pat-enum.rs @@ -1,5 +1,5 @@ fn match_ref(&&v: option<int>) -> int { - alt v { + match v { some(i) => { i } @@ -8,14 +8,14 @@ fn match_ref(&&v: option<int>) -> int { } fn match_ref_unused(&&v: option<int>) { - alt v { + match v { some(_) => {} none => {} } } fn match_const_reg(v: &const option<int>) -> int { - alt *v { + match *v { some(i) => {i} // OK because this is pure none => {0} } @@ -25,14 +25,14 @@ fn impure(_i: int) { } fn match_const_reg_unused(v: &const option<int>) { - alt *v { + match *v { some(_) => {impure(0)} // OK because nothing is captured none => {} } } fn match_const_reg_impure(v: &const option<int>) { - alt *v { + match *v { some(i) => {impure(i)} //~ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location //~^ NOTE impure due to access to impure function none => {} @@ -40,7 +40,7 @@ fn match_const_reg_impure(v: &const option<int>) { } fn match_imm_reg(v: &option<int>) { - alt *v { + match *v { some(i) => {impure(i)} // OK because immutable none => {} } diff --git a/src/test/compile-fail/borrowck-pat-reassign-binding.rs b/src/test/compile-fail/borrowck-pat-reassign-binding.rs index 2d7f33e6620..02604f65227 100644 --- a/src/test/compile-fail/borrowck-pat-reassign-binding.rs +++ b/src/test/compile-fail/borrowck-pat-reassign-binding.rs @@ -2,7 +2,7 @@ fn main() { let mut x: option<int> = none; - alt x { //~ NOTE loan of mutable local variable granted here + match x { //~ NOTE loan of mutable local variable granted here none => {} some(i) => { // Not ok: i is an outstanding ptr into x. diff --git a/src/test/compile-fail/borrowck-pat-reassign-sometimes-binding.rs b/src/test/compile-fail/borrowck-pat-reassign-sometimes-binding.rs index 12c2d0ef6e8..42dd5024603 100644 --- a/src/test/compile-fail/borrowck-pat-reassign-sometimes-binding.rs +++ b/src/test/compile-fail/borrowck-pat-reassign-sometimes-binding.rs @@ -2,7 +2,7 @@ fn main() { let mut x = none; - alt x { //~ NOTE loan of mutable local variable granted here + match x { //~ NOTE loan of mutable local variable granted here none => { // It is ok to reassign x here, because there is in // fact no outstanding loan of x! diff --git a/src/test/compile-fail/borrowck-unchecked-with-borrow.rs b/src/test/compile-fail/borrowck-unchecked-with-borrow.rs index 34031aa70d6..86a855de6f1 100644 --- a/src/test/compile-fail/borrowck-unchecked-with-borrow.rs +++ b/src/test/compile-fail/borrowck-unchecked-with-borrow.rs @@ -2,7 +2,7 @@ fn impure(_i: int) {} // check that unchecked alone does not override borrowck: fn foo(v: &const option<int>) { - alt *v { + match *v { some(i) => { //~^ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location unchecked { @@ -15,7 +15,7 @@ fn foo(v: &const option<int>) { } fn bar(v: &const option<int>) { - alt *v { + match *v { some(i) => { unsafe { impure(i); diff --git a/src/test/compile-fail/deref-non-pointer.rs b/src/test/compile-fail/deref-non-pointer.rs index 5468a46a6a7..8c23b1db2de 100644 --- a/src/test/compile-fail/deref-non-pointer.rs +++ b/src/test/compile-fail/deref-non-pointer.rs @@ -1,6 +1,6 @@ // error-pattern:cannot be dereferenced fn main() { - alt *1 { + match *1 { _ => { fail; } } } \ No newline at end of file diff --git a/src/test/compile-fail/issue-1193.rs b/src/test/compile-fail/issue-1193.rs index 4ac885e5b10..e9a5d91c9d2 100644 --- a/src/test/compile-fail/issue-1193.rs +++ b/src/test/compile-fail/issue-1193.rs @@ -6,7 +6,7 @@ mod foo { const b : t = 1u8; fn bar(v: t) -> bool { - alt v { + match v { a => { return true; } b => { return false; } } diff --git a/src/test/compile-fail/issue-2111.rs b/src/test/compile-fail/issue-2111.rs index f5639a887f0..7c7ec4f5f8f 100644 --- a/src/test/compile-fail/issue-2111.rs +++ b/src/test/compile-fail/issue-2111.rs @@ -1,5 +1,5 @@ fn foo(a: option<uint>, b: option<uint>) { - alt (a,b) { //~ ERROR: non-exhaustive patterns: none not covered + match (a,b) { //~ ERROR: non-exhaustive patterns: none not covered (some(a), some(b)) if a == b => { } (some(_), none) | (none, some(_)) => { } diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index cf7a36224bb..ebda510e879 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -5,7 +5,7 @@ xfailed for now (see Issue #2354) */ fn foo() { //~ ERROR this open brace is not closed - alt some(x) { + match some(x) { some(y) { fail; } none { fail; } } diff --git a/src/test/compile-fail/issue-2848.rs b/src/test/compile-fail/issue-2848.rs index 376426bb82e..c721887e496 100644 --- a/src/test/compile-fail/issue-2848.rs +++ b/src/test/compile-fail/issue-2848.rs @@ -8,7 +8,7 @@ mod bar { fn main() { import bar::{alpha, charlie}; - alt alpha { + match alpha { alpha | beta => {} //~ ERROR: inconsistent number of bindings charlie => {} } diff --git a/src/test/compile-fail/issue-2849.rs b/src/test/compile-fail/issue-2849.rs index 6085fc9fe8f..5e8a9905c2f 100644 --- a/src/test/compile-fail/issue-2849.rs +++ b/src/test/compile-fail/issue-2849.rs @@ -1,7 +1,7 @@ enum foo { alpha, beta(int) } fn main() { - alt alpha { + match alpha { alpha | beta(i) => {} //~ ERROR inconsistent number of bindings } } diff --git a/src/test/compile-fail/issue-3038.rs b/src/test/compile-fail/issue-3038.rs index f5aa30c1416..ec66d3bafe6 100644 --- a/src/test/compile-fail/issue-3038.rs +++ b/src/test/compile-fail/issue-3038.rs @@ -8,17 +8,17 @@ enum k { m(int, int) } fn main() { - let _z = alt g(1, 2) { + let _z = match g(1, 2) { g(x, x) => { log(debug, x + x); } //~^ ERROR Identifier x is bound more than once in the same pattern }; - let _z = alt i(l(1, 2), m(3, 4)) { + let _z = match i(l(1, 2), m(3, 4)) { i(l(x, _), m(_, x)) //~ ERROR Identifier x is bound more than once in the same pattern => { log(error, x + x); } }; - let _z = alt (1, 2) { + let _z = match (1, 2) { (x, x) => { x } //~ ERROR Identifier x is bound more than once in the same pattern }; diff --git a/src/test/compile-fail/liveness-missing-ret2.rs b/src/test/compile-fail/liveness-missing-ret2.rs index e1803b0248a..5f488c4dc5a 100644 --- a/src/test/compile-fail/liveness-missing-ret2.rs +++ b/src/test/compile-fail/liveness-missing-ret2.rs @@ -1,9 +1,9 @@ // error-pattern: not all control paths return a value fn f() -> int { - // Make sure typestate doesn't interpreturn this alt expression + // Make sure typestate doesn't interpreturn this match expression // as the function result - alt check true { true => { } }; + match check true { true => { } }; } fn main() { } diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 4f9e62e0502..c1d4cdb4a57 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -27,7 +27,7 @@ fn f3b() { } fn f4() { - alt some(3) { + match some(3) { some(i) => { } none => {} diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs index dea250a734c..01641f5b9c7 100644 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -5,7 +5,7 @@ enum u { c, d } fn main() { let x = a(c); - alt x { + match x { a(d) => { fail ~"hello"; } b => { fail ~"goodbye"; } } diff --git a/src/test/compile-fail/non-exhaustive-match.rs b/src/test/compile-fail/non-exhaustive-match.rs index e712406ba19..173fd2b4109 100644 --- a/src/test/compile-fail/non-exhaustive-match.rs +++ b/src/test/compile-fail/non-exhaustive-match.rs @@ -2,25 +2,25 @@ enum t { a, b, } fn main() { let x = a; - alt x { b => { } } //~ ERROR non-exhaustive patterns - alt true { //~ ERROR non-exhaustive patterns + match x { b => { } } //~ ERROR non-exhaustive patterns + match true { //~ ERROR non-exhaustive patterns true => {} } - alt @some(10) { //~ ERROR non-exhaustive patterns + match @some(10) { //~ ERROR non-exhaustive patterns @none => {} } - alt (2, 3, 4) { //~ ERROR non-exhaustive patterns + match (2, 3, 4) { //~ ERROR non-exhaustive patterns (_, _, 4) => {} } - alt (a, a) { //~ ERROR non-exhaustive patterns + match (a, a) { //~ ERROR non-exhaustive patterns (a, b) => {} (b, a) => {} } - alt a { //~ ERROR b not covered + match a { //~ ERROR b not covered a => {} } // This is exhaustive, though the algorithm got it wrong at one point - alt (a, b) { + match (a, b) { (a, _) => {} (_, a) => {} (b, b) => {} diff --git a/src/test/compile-fail/occurs-check-3.rs b/src/test/compile-fail/occurs-check-3.rs index 207bbd91cc5..e8c8f32b72f 100644 --- a/src/test/compile-fail/occurs-check-3.rs +++ b/src/test/compile-fail/occurs-check-3.rs @@ -1,4 +1,4 @@ // error-pattern:mismatched types // From Issue #778 enum clam<T> { a(T), } -fn main() { let c; c = a(c); alt c { a::<int>(_) => { } } } +fn main() { let c; c = a(c); match c { a::<int>(_) => { } } } diff --git a/src/test/compile-fail/or-patter-mismatch.rs b/src/test/compile-fail/or-patter-mismatch.rs index 37d194cbd50..f309ead4623 100644 --- a/src/test/compile-fail/or-patter-mismatch.rs +++ b/src/test/compile-fail/or-patter-mismatch.rs @@ -2,4 +2,4 @@ enum blah { a(int, int, uint), b(int, int), } -fn main() { alt a(1, 1, 2u) { a(_, x, y) | b(x, y) => { } } } +fn main() { match a(1, 1, 2u) { a(_, x, y) | b(x, y) => { } } } diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 1dee20e0ef6..f1e8224efc5 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -8,6 +8,6 @@ import option::some; enum bar { t1((), option<~[int]>), t2, } -fn foo(t: bar) -> int { alt t { t1(_, some(x)) => { return x * 3; } _ => { fail; } } } +fn foo(t: bar) -> int { match t { t1(_, some(x)) => { return x * 3; } _ => { fail; } } } fn main() { } diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index 2622dadc040..8b7c065dbf7 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -8,7 +8,7 @@ import option::some; enum bar { t1((), option<~[int]>), t2, } fn foo(t: bar) { - alt t { + match t { t1(_, some::<int>(x)) => { log(debug, x); } diff --git a/src/test/compile-fail/regions-creating-enums.rs b/src/test/compile-fail/regions-creating-enums.rs index 0702618c68c..6cacf49300d 100644 --- a/src/test/compile-fail/regions-creating-enums.rs +++ b/src/test/compile-fail/regions-creating-enums.rs @@ -11,14 +11,14 @@ fn build() { } fn compute(x: &ast) -> uint { - alt *x { + match *x { num(x) => { x } add(x, y) => { compute(x) + compute(y) } } } fn map_nums(x: &ast, f: fn(uint) -> uint) -> &ast { - alt *x { + match *x { num(x) => { return &num(f(x)); //~ ERROR illegal borrow } diff --git a/src/test/compile-fail/restricted-keyword1.rs b/src/test/compile-fail/restricted-keyword1.rs index 2a9f5838c85..c301d8199de 100644 --- a/src/test/compile-fail/restricted-keyword1.rs +++ b/src/test/compile-fail/restricted-keyword1.rs @@ -1,7 +1,7 @@ // error-pattern:found `let` in restricted position fn main() { - alt true { + match true { {let} { } } } diff --git a/src/test/compile-fail/unreachable-arm.rs b/src/test/compile-fail/unreachable-arm.rs index 1865fe6aff9..71875e92a8f 100644 --- a/src/test/compile-fail/unreachable-arm.rs +++ b/src/test/compile-fail/unreachable-arm.rs @@ -2,4 +2,4 @@ enum foo { a(@foo, int), b(uint), } -fn main() { alt b(1u) { b(_) | a(@_, 1) => { } a(_, 1) => { } } } +fn main() { match b(1u) { b(_) | a(@_, 1) => { } a(_, 1) => { } } } diff --git a/src/test/pretty/alt-naked-expr-long.rs b/src/test/pretty/alt-naked-expr-long.rs index 817a4056f10..3e3b4581f62 100644 --- a/src/test/pretty/alt-naked-expr-long.rs +++ b/src/test/pretty/alt-naked-expr-long.rs @@ -6,7 +6,7 @@ fn main() { let x = some(3); let y = - alt x { + match x { some(_) => ~"some" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" + ~"very" + ~"long" + ~"string", diff --git a/src/test/pretty/alt-naked-expr-medium.rs b/src/test/pretty/alt-naked-expr-medium.rs index 70099e46806..9c6e74f4833 100644 --- a/src/test/pretty/alt-naked-expr-medium.rs +++ b/src/test/pretty/alt-naked-expr-medium.rs @@ -3,7 +3,7 @@ fn main() { let x = some(3); let _y = - alt x { + match x { some(_) => ~[~"some(_)", ~"not", ~"SO", ~"long", ~"string"], none => ~[~"none"] }; diff --git a/src/test/pretty/alt-naked-expr.rs b/src/test/pretty/alt-naked-expr.rs index 2df23671857..0ad75ab68f9 100644 --- a/src/test/pretty/alt-naked-expr.rs +++ b/src/test/pretty/alt-naked-expr.rs @@ -2,6 +2,6 @@ fn main() { let x = some(3); - let y = alt x { some(_) => ~"some(_)", none => ~"none" }; + let y = match x { some(_) => ~"some(_)", none => ~"none" }; assert y == ~"some(_)"; } diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 14a8629ab72..357a6d19fe4 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -8,7 +8,7 @@ fn test2() -> int { let val = @0; { } *val } fn test3() { let regs = @{mut eax: 0}; - alt check true { true => { } } + match check true { true => { } } (*regs).eax = 1; } @@ -20,13 +20,13 @@ fn test6() -> bool { { } (true || false) && true } fn test7() -> uint { let regs = @0; - alt check true { true => { } } + match check true { true => { } } (*regs < 2) as uint } fn test8() -> int { let val = @0; - alt check true { + match check true { true => { } } if *val < 1 { @@ -36,11 +36,11 @@ fn test8() -> int { } } -fn test9() { let regs = @mut 0; alt check true { true => { } } *regs += 1; } +fn test9() { let regs = @mut 0; match check true { true => { } } *regs += 1; } fn test10() -> int { let regs = @mut ~[0]; - alt check true { true => { } } + match check true { true => { } } (*regs)[0] } diff --git a/src/test/pretty/unary-op-disambig.rs b/src/test/pretty/unary-op-disambig.rs index 1f9d68cc8a2..1e2c95fa325 100644 --- a/src/test/pretty/unary-op-disambig.rs +++ b/src/test/pretty/unary-op-disambig.rs @@ -10,8 +10,8 @@ fn if_semi() -> int { if true { f() } else { f() }; -1 } fn if_nosemi() -> int { (if true { 0 } else { 0 }) - 1 } -fn alt_semi() -> int { alt check true { true => { f() } }; -1 } +fn alt_semi() -> int { match check true { true => { f() } }; -1 } -fn alt_no_semi() -> int { (alt check true { true => { 0 } }) - 1 } +fn alt_no_semi() -> int { (match check true { true => { 0 } }) - 1 } fn stmt() { { f() }; -1; } diff --git a/src/test/run-fail/alt-bot-fail.rs b/src/test/run-fail/alt-bot-fail.rs index 08320af9775..da4ffdd5afc 100644 --- a/src/test/run-fail/alt-bot-fail.rs +++ b/src/test/run-fail/alt-bot-fail.rs @@ -4,6 +4,6 @@ fn foo(s: ~str) { } fn main() { let i = - alt some::<int>(3) { none::<int> => { fail } some::<int>(_) => { fail } }; + match some::<int>(3) { none::<int> => { fail } some::<int>(_) => { fail } }; foo(i); } diff --git a/src/test/run-fail/alt-disc-bot.rs b/src/test/run-fail/alt-disc-bot.rs index ab444a8273e..e3bc3c16384 100644 --- a/src/test/run-fail/alt-disc-bot.rs +++ b/src/test/run-fail/alt-disc-bot.rs @@ -1,4 +1,4 @@ // error-pattern:quux fn f() -> ! { fail ~"quux" } -fn g() -> int { alt f() { true => { 1 } false => { 0 } } } +fn g() -> int { match f() { true => { 1 } false => { 0 } } } fn main() { g(); } diff --git a/src/test/run-fail/alt-wildcards.rs b/src/test/run-fail/alt-wildcards.rs index 3a3c4c5a0a8..39a381dd3ac 100644 --- a/src/test/run-fail/alt-wildcards.rs +++ b/src/test/run-fail/alt-wildcards.rs @@ -1,6 +1,6 @@ // error-pattern:squirrelcupcake fn cmp() -> int { - alt check (option::some('a'), option::none::<char>) { + match check (option::some('a'), option::none::<char>) { (option::some(_), _) => { fail ~"squirrelcupcake"; } (_, option::some(_)) => { fail; } } diff --git a/src/test/run-fail/expr-alt-fail-fn.rs b/src/test/run-fail/expr-alt-fail-fn.rs index f6d3779b9f0..6c21859baeb 100644 --- a/src/test/run-fail/expr-alt-fail-fn.rs +++ b/src/test/run-fail/expr-alt-fail-fn.rs @@ -4,6 +4,6 @@ // error-pattern:explicit failure fn f() -> ! { fail } -fn g() -> int { let x = alt true { true => { f() } false => { 10 } }; return x; } +fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; } fn main() { g(); } diff --git a/src/test/run-fail/expr-alt-fail.rs b/src/test/run-fail/expr-alt-fail.rs index 3a70b690755..a7f19c6d3ce 100644 --- a/src/test/run-fail/expr-alt-fail.rs +++ b/src/test/run-fail/expr-alt-fail.rs @@ -2,4 +2,4 @@ // error-pattern:explicit failure -fn main() { let x = alt true { false => { 0 } true => { fail } }; } +fn main() { let x = match true { false => { 0 } true => { fail } }; } diff --git a/src/test/run-fail/fail-parens.rs b/src/test/run-fail/fail-parens.rs index 849d4b41d3b..ddbd1200fcf 100644 --- a/src/test/run-fail/fail-parens.rs +++ b/src/test/run-fail/fail-parens.rs @@ -5,7 +5,7 @@ fn bigfail() { do { while (fail) { if (fail) { - alt (fail) { _ { + match (fail) { _ { }} }}} while fail; } diff --git a/src/test/run-fail/issue-2156.rs b/src/test/run-fail/issue-2156.rs index 026af3a2f65..d18c7de3d34 100644 --- a/src/test/run-fail/issue-2156.rs +++ b/src/test/run-fail/issue-2156.rs @@ -5,6 +5,6 @@ import io::{reader, reader_util}; fn main() { do io::with_str_reader(~"") |rdr| { - alt rdr.read_char() { '=' => { } _ => { fail } } + match rdr.read_char() { '=' => { } _ => { fail } } } } diff --git a/src/test/run-fail/unwind-alt.rs b/src/test/run-fail/unwind-alt.rs index d5f013a42b6..579067927ca 100644 --- a/src/test/run-fail/unwind-alt.rs +++ b/src/test/run-fail/unwind-alt.rs @@ -4,7 +4,7 @@ fn test_box() { @0; } fn test_str() { - let res = alt check false { true => { ~"happy" } }; + let res = match check false { true => { ~"happy" } }; assert res == ~"happy"; } fn main() { diff --git a/src/test/run-pass/alt-arrows-blocky-commas.rs b/src/test/run-pass/alt-arrows-blocky-commas.rs index 100ec11cd96..289018013d3 100644 --- a/src/test/run-pass/alt-arrows-blocky-commas.rs +++ b/src/test/run-pass/alt-arrows-blocky-commas.rs @@ -1,6 +1,6 @@ // no-reformat // Testing the presense or absense of commas separating block-structure -// alt arm expressions +// match arm expressions fn fun(_f: fn()) { } @@ -10,13 +10,13 @@ fn it(_f: fn() -> bool) { fn main() { - alt 0 { + match 0 { 00 => { } 01 => if true { } else { } - 03 => alt 0 { + 03 => match 0 { _ => () } 04 => do fun { @@ -36,7 +36,7 @@ fn main() { 11 => if true { } else { }, - 13 => alt 0 { + 13 => match 0 { _ => () }, 14 => do fun { diff --git a/src/test/run-pass/alt-bot-2.rs b/src/test/run-pass/alt-bot-2.rs index cbf1519dc34..8b9f606d8d8 100644 --- a/src/test/run-pass/alt-bot-2.rs +++ b/src/test/run-pass/alt-bot-2.rs @@ -1,3 +1,3 @@ // n.b. This was only ever failing with optimization disabled. -fn a() -> int { alt check return 1 { 2 => 3 } } +fn a() -> int { match check return 1 { 2 => 3 } } fn main() { a(); } diff --git a/src/test/run-pass/alt-bot.rs b/src/test/run-pass/alt-bot.rs index 7162bf69aa5..06b6eca4b83 100644 --- a/src/test/run-pass/alt-bot.rs +++ b/src/test/run-pass/alt-bot.rs @@ -1,6 +1,6 @@ fn main() { let i: int = - alt some::<int>(3) { none::<int> => { fail } some::<int>(_) => { 5 } }; + match some::<int>(3) { none::<int> => { fail } some::<int>(_) => { 5 } }; log(debug, i); } diff --git a/src/test/run-pass/alt-implicit-copy-unique.rs b/src/test/run-pass/alt-implicit-copy-unique.rs index 796a73a0204..eca726e8277 100644 --- a/src/test/run-pass/alt-implicit-copy-unique.rs +++ b/src/test/run-pass/alt-implicit-copy-unique.rs @@ -1,6 +1,6 @@ fn main() { let x = ~{mut a: ~10, b: ~20}; - alt x { + match x { ~{a, b} => { assert *a == 10; (*x).a = ~30; assert *a == 30; } } } diff --git a/src/test/run-pass/alt-implicit-copy.rs b/src/test/run-pass/alt-implicit-copy.rs index 355e678d3a3..f4d14cbc728 100644 --- a/src/test/run-pass/alt-implicit-copy.rs +++ b/src/test/run-pass/alt-implicit-copy.rs @@ -1,6 +1,6 @@ fn main() { let x = @{mut a: @10, b: @20}; - alt x { + match x { @{a, b} => { assert *a == 10; (*x).a = @30; assert *a == 30; } } } diff --git a/src/test/run-pass/alt-join.rs b/src/test/run-pass/alt-join.rs index 2d4078ced04..5c51fd0d34d 100644 --- a/src/test/run-pass/alt-join.rs +++ b/src/test/run-pass/alt-join.rs @@ -10,7 +10,7 @@ fn foo<T>(y: option<T>) { if true { } else { - alt y { + match y { none::<T> => x = 17, _ => x = 42 } diff --git a/src/test/run-pass/alt-naked-record-expr.rs b/src/test/run-pass/alt-naked-record-expr.rs index 2fe2bfefa98..df2e9f5acd8 100644 --- a/src/test/run-pass/alt-naked-record-expr.rs +++ b/src/test/run-pass/alt-naked-record-expr.rs @@ -1,5 +1,5 @@ fn main() { - let x = alt 0 { + let x = match 0 { _ => { x: 0 }.x diff --git a/src/test/run-pass/alt-naked-record.rs b/src/test/run-pass/alt-naked-record.rs index 76cfb4cd11b..042861d0a86 100644 --- a/src/test/run-pass/alt-naked-record.rs +++ b/src/test/run-pass/alt-naked-record.rs @@ -1,5 +1,5 @@ fn main() { - let x = alt 0 { + let x = match 0 { _ => { x: 0 } diff --git a/src/test/run-pass/alt-path.rs b/src/test/run-pass/alt-path.rs index aa9e9f18481..cd8b21fc248 100644 --- a/src/test/run-pass/alt-path.rs +++ b/src/test/run-pass/alt-path.rs @@ -4,6 +4,6 @@ mod m1 { enum foo { foo1, foo2, } } -fn bar(x: m1::foo) { alt x { m1::foo1 => { } m1::foo2 => { } } } +fn bar(x: m1::foo) { match x { m1::foo1 => { } m1::foo2 => { } } } fn main() { } diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs index 92366e54b30..ba8bef7e124 100644 --- a/src/test/run-pass/alt-pattern-drop.rs +++ b/src/test/run-pass/alt-pattern-drop.rs @@ -9,7 +9,7 @@ fn foo(s: @int) { let count = sys::refcount(s); let x: t = make_t(s); // ref up - alt x { + match x { make_t(y) => { log(debug, y); // ref up then down diff --git a/src/test/run-pass/alt-pattern-lit.rs b/src/test/run-pass/alt-pattern-lit.rs index bc1f788abc0..e5f86159421 100644 --- a/src/test/run-pass/alt-pattern-lit.rs +++ b/src/test/run-pass/alt-pattern-lit.rs @@ -1,7 +1,7 @@ fn altlit(f: int) -> int { - alt check f { + match check f { 10 => { debug!{"case 10"}; return 20; } 11 => { debug!{"case 11"}; return 22; } } diff --git a/src/test/run-pass/alt-pattern-no-type-params.rs b/src/test/run-pass/alt-pattern-no-type-params.rs index badad32ce28..447fd417e8d 100644 --- a/src/test/run-pass/alt-pattern-no-type-params.rs +++ b/src/test/run-pass/alt-pattern-no-type-params.rs @@ -1,7 +1,7 @@ enum maybe<T> { nothing, just(T), } fn foo(x: maybe<int>) { - alt x { nothing => { error!{"A"}; } just(a) => { error!{"B"}; } } + match x { nothing => { error!{"A"}; } just(a) => { error!{"B"}; } } } fn main() { } diff --git a/src/test/run-pass/alt-pattern-simple.rs b/src/test/run-pass/alt-pattern-simple.rs index e4ca776bb61..fd31a235ba9 100644 --- a/src/test/run-pass/alt-pattern-simple.rs +++ b/src/test/run-pass/alt-pattern-simple.rs @@ -1,5 +1,5 @@ -fn altsimple(f: int) { alt f { x => () } } +fn altsimple(f: int) { match f { x => () } } fn main() { } diff --git a/src/test/run-pass/alt-phi.rs b/src/test/run-pass/alt-phi.rs index 358b8d64e6c..cea0e1b4533 100644 --- a/src/test/run-pass/alt-phi.rs +++ b/src/test/run-pass/alt-phi.rs @@ -6,7 +6,7 @@ fn foo(it: fn(int)) { it(10); } fn main() { let mut x = true; - alt a { + match a { a => { x = true; foo(|_i| { } ) } b => { x = false; } c => { x = false; } diff --git a/src/test/run-pass/alt-range.rs b/src/test/run-pass/alt-range.rs index 75ca1dd5e52..f3713fabb13 100644 --- a/src/test/run-pass/alt-range.rs +++ b/src/test/run-pass/alt-range.rs @@ -1,29 +1,29 @@ fn main() { - alt 5u { + match 5u { 1u to 5u => {} _ => fail ~"should match range", } - alt 5u { + match 5u { 6u to 7u => fail ~"shouldn't match range", _ => {} } - alt check 5u { + match check 5u { 1u => fail ~"should match non-first range", 2u to 6u => {} } - alt 'c' { + match 'c' { 'a' to 'z' => {} _ => fail ~"should suppport char ranges" } - alt -3 { + match -3 { -7 to 5 => {} _ => fail ~"should match signed range" } - alt 3.0 { + match 3.0 { 1.0 to 5.0 => {} _ => fail ~"should match float range" } - alt -1.5 { + match -1.5 { -3.6 to 3.6 => {} _ => fail ~"should match negative float range" } diff --git a/src/test/run-pass/alt-str.rs b/src/test/run-pass/alt-str.rs index 4693635458d..98754ecf0e2 100644 --- a/src/test/run-pass/alt-str.rs +++ b/src/test/run-pass/alt-str.rs @@ -1,21 +1,21 @@ // Issue #53 fn main() { - alt check ~"test" { ~"not-test" => fail, ~"test" => (), _ => fail } + match check ~"test" { ~"not-test" => fail, ~"test" => (), _ => fail } enum t { tag1(~str), tag2, } - alt tag1(~"test") { + match tag1(~"test") { tag2 => fail, tag1(~"not-test") => fail, tag1(~"test") => (), _ => fail } - let x = alt check ~"a" { ~"a" => 1, ~"b" => 2 }; + let x = match check ~"a" { ~"a" => 1, ~"b" => 2 }; assert (x == 1); - alt check ~"a" { ~"a" => { } ~"b" => { } } + match check ~"a" { ~"a" => { } ~"b" => { } } } diff --git a/src/test/run-pass/alt-tag.rs b/src/test/run-pass/alt-tag.rs index 4b8cdce110e..0c75cafa204 100644 --- a/src/test/run-pass/alt-tag.rs +++ b/src/test/run-pass/alt-tag.rs @@ -10,7 +10,7 @@ enum color { fn process(c: color) -> int { let mut x: int; - alt c { + match c { rgb(r, _, _) => { debug!{"rgb"}; log(debug, r); x = r; } rgba(_, _, _, a) => { debug!{"rgba"}; log(debug, a); x = a; } hsl(_, s, _) => { debug!{"hsl"}; log(debug, s); x = s; } diff --git a/src/test/run-pass/alt-type-simple.rs b/src/test/run-pass/alt-type-simple.rs index 207f718f3aa..4881a6bba4a 100644 --- a/src/test/run-pass/alt-type-simple.rs +++ b/src/test/run-pass/alt-type-simple.rs @@ -2,7 +2,7 @@ // xfail-test fn altsimple(any x) { - alt type (f) { + match type (f) { case (int i) { print("int"); } case (str s) { print("str"); } } diff --git a/src/test/run-pass/alt-unique-bind.rs b/src/test/run-pass/alt-unique-bind.rs index b907afa1e8d..7548d171d1c 100644 --- a/src/test/run-pass/alt-unique-bind.rs +++ b/src/test/run-pass/alt-unique-bind.rs @@ -1,5 +1,5 @@ fn main() { - alt ~100 { + match ~100 { ~x => { debug!{"%?", x}; assert x == 100; diff --git a/src/test/run-pass/alt-with-ret-arm.rs b/src/test/run-pass/alt-with-ret-arm.rs index 50c03e71be2..c07391b691b 100644 --- a/src/test/run-pass/alt-with-ret-arm.rs +++ b/src/test/run-pass/alt-with-ret-arm.rs @@ -2,7 +2,7 @@ fn main() { // sometimes we have had trouble finding // the right type for f, as we unified // bot and u32 here - let f = alt uint::from_str(~"1234") { + let f = match uint::from_str(~"1234") { none => return (), some(num) => num as u32 }; diff --git a/src/test/run-pass/binary-minus-without-space.rs b/src/test/run-pass/binary-minus-without-space.rs index d2df3b2dab3..86bdd52c6af 100644 --- a/src/test/run-pass/binary-minus-without-space.rs +++ b/src/test/run-pass/binary-minus-without-space.rs @@ -1,6 +1,6 @@ // Check that issue #954 stays fixed fn main() { - alt check -1 { -1 => {} } + match check -1 { -1 => {} } assert 1-1 == 0; } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 685f68c61ad..db941d32e11 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -24,11 +24,11 @@ fn main() { if !do vec::any(v) |e| { float::is_positive(e) } { assert false; } - alt do vec::all(v) |e| { float::is_negative(e) } { + match do vec::all(v) |e| { float::is_negative(e) } { true => { fail ~"incorrect answer."; } false => { } } - alt 3 { + match 3 { _ if do vec::any(v) |e| { float::is_negative(e) } => { } _ => { diff --git a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs index bbc2abf51af..5f4804c778b 100644 --- a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs +++ b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs @@ -1,6 +1,6 @@ fn main() { let mut x = none; - alt x { + match x { none => { // It is ok to reassign x here, because there is in // fact no outstanding loan of x! diff --git a/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs b/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs index 87b4fd59e5f..58694e8f135 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs @@ -2,7 +2,7 @@ fn main() { let x: @mut @option<~int> = @mut @none; - alt x { + match x { @@some(y) => { // here, the refcount of `*x` is bumped so // `y` remains valid even if `*x` is modified. diff --git a/src/test/run-pass/borrowck-preserve-box-in-discr.rs b/src/test/run-pass/borrowck-preserve-box-in-discr.rs index 99b446ce315..101f9c787d3 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-discr.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-discr.rs @@ -2,7 +2,7 @@ fn main() { let mut x = @{f: ~3}; - alt *x { + match *x { {f: b_x} => { assert *b_x == 3; assert ptr::addr_of(*x.f) == ptr::addr_of(*b_x); diff --git a/src/test/run-pass/borrowck-preserve-box-in-pat.rs b/src/test/run-pass/borrowck-preserve-box-in-pat.rs index 7a37432db74..c5d5fd96673 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-pat.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-pat.rs @@ -2,7 +2,7 @@ fn main() { let mut x = @mut @{f: ~3}; - alt x { + match x { @@{f: b_x} => { assert *b_x == 3; assert ptr::addr_of(x.f) == ptr::addr_of(b_x); diff --git a/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs b/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs index f8bf02a7703..11bc8e6fa7f 100644 --- a/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs +++ b/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs @@ -2,7 +2,7 @@ fn switcher(x: option<@int>) { let mut x = x; - alt x { + match x { some(@y) => { copy y; x = none; } none => { } } diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index fde259046a7..15f22e7ced8 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -9,7 +9,7 @@ fn main() { let x = @mut 5; let y = @mut newtype(3); - let z = alt *y { + let z = match *y { newtype(b) => { *x += 1; *x * b diff --git a/src/test/run-pass/box-pattern.rs b/src/test/run-pass/box-pattern.rs index faf3ff73b01..90228f3dcf2 100644 --- a/src/test/run-pass/box-pattern.rs +++ b/src/test/run-pass/box-pattern.rs @@ -2,7 +2,7 @@ type foo = {a: int, b: uint}; enum bar { u(@foo), w(int), } fn main() { - assert (alt u(@{a: 10, b: 40u}) { + assert (match u(@{a: 10, b: 40u}) { u(@{a: a, b: b}) => { a + (b as int) } _ => { 66 } } == 50); diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 175c5f9936a..fc85484193c 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -48,7 +48,7 @@ class cat<T: copy> : map<int, T> { fn contains_key(+k: int) -> bool { k <= self.meows } fn contains_key_ref(k: &int) -> bool { self.contains_key(*k) } - fn get(+k:int) -> T { alt self.find(k) { + fn get(+k:int) -> T { match self.find(k) { some(v) => { v } none => { fail ~"epic fail"; } } @@ -61,7 +61,7 @@ class cat<T: copy> : map<int, T> { } fn remove(+k:int) -> option<T> { - alt self.find(k) { + match self.find(k) { some(x) => { self.meows -= k; some(x) } diff --git a/src/test/run-pass/drop-on-empty-block-exit.rs b/src/test/run-pass/drop-on-empty-block-exit.rs index 3b9d41fc82a..4a397970669 100644 --- a/src/test/run-pass/drop-on-empty-block-exit.rs +++ b/src/test/run-pass/drop-on-empty-block-exit.rs @@ -2,4 +2,4 @@ enum t { foo(@int), } -fn main() { let tt = foo(@10); alt tt { foo(z) => { } } } +fn main() { let tt = foo(@10); match tt { foo(z) => { } } } diff --git a/src/test/run-pass/expr-alt-box.rs b/src/test/run-pass/expr-alt-box.rs index 8930f113431..eb49160ce6f 100644 --- a/src/test/run-pass/expr-alt-box.rs +++ b/src/test/run-pass/expr-alt-box.rs @@ -3,14 +3,14 @@ // -*- rust -*- -// Tests for alt as expressions resulting in boxed types +// Tests for match as expressions resulting in boxed types fn test_box() { - let res = alt check true { true => { @100 } }; + let res = match check true { true => { @100 } }; assert (*res == 100); } fn test_str() { - let res = alt check true { true => { ~"happy" } }; + let res = match check true { true => { ~"happy" } }; assert (res == ~"happy"); } diff --git a/src/test/run-pass/expr-alt-fail-all.rs b/src/test/run-pass/expr-alt-fail-all.rs index a38464f6d0a..bd55f4d663e 100644 --- a/src/test/run-pass/expr-alt-fail-all.rs +++ b/src/test/run-pass/expr-alt-fail-all.rs @@ -1,12 +1,12 @@ -// When all branches of an alt expression result in fail, the entire -// alt expression results in fail. +// When all branches of an match expression result in fail, the entire +// match expression results in fail. fn main() { let x = - alt true { + match true { true => { 10 } - false => { alt true { true => { fail } false => { fail } } } + false => { match true { true => { fail } false => { fail } } } }; } diff --git a/src/test/run-pass/expr-alt-fail.rs b/src/test/run-pass/expr-alt-fail.rs index 5635a660f42..a490aac5c95 100644 --- a/src/test/run-pass/expr-alt-fail.rs +++ b/src/test/run-pass/expr-alt-fail.rs @@ -1,10 +1,10 @@ fn test_simple() { - let r = alt true { true => { true } false => { fail } }; + let r = match true { true => { true } false => { fail } }; assert (r == true); } fn test_box() { - let r = alt true { true => { ~[10] } false => { fail } }; + let r = match true { true => { ~[10] } false => { fail } }; assert (r[0] == 10); } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index f3f9dee2ff4..40121de92db 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -5,7 +5,7 @@ type compare<T> = fn@(@T, @T) -> bool; fn test_generic<T>(expected: @T, eq: compare<T>) { - let actual: @T = alt check true { true => { expected } }; + let actual: @T = match check true { true => { expected } }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index e03c196c289..73c6a4b68b4 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -5,7 +5,7 @@ type compare<T> = fn@(T, T) -> bool; fn test_generic<T: copy>(expected: T, eq: compare<T>) { - let actual: T = alt check true { true => { expected } }; + let actual: T = match check true { true => { expected } }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index 5168fd5ca80..420cb030134 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -4,7 +4,7 @@ type compare<T> = fn@(~T, ~T) -> bool; fn test_generic<T: copy>(expected: ~T, eq: compare<T>) { - let actual: ~T = alt check true { true => { expected } }; + let actual: ~T = match check true { true => { expected } }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index e1475373dc2..c425bedcef9 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -5,7 +5,7 @@ type compare<T> = fn@(T, T) -> bool; fn test_generic<T: copy>(expected: T, eq: compare<T>) { - let actual: T = alt check true { true => { expected } }; + let actual: T = match check true { true => { expected } }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index 98536b1afe1..6f947402a13 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -5,7 +5,7 @@ type compare<T> = fn@(T, T) -> bool; fn test_generic<T: copy>(expected: T, eq: compare<T>) { - let actual: T = alt check true { true => { expected } }; + let actual: T = match check true { true => { expected } }; assert (eq(expected, actual)); } diff --git a/src/test/run-pass/expr-alt-struct.rs b/src/test/run-pass/expr-alt-struct.rs index 2bfef283f9d..c0be37942a5 100644 --- a/src/test/run-pass/expr-alt-struct.rs +++ b/src/test/run-pass/expr-alt-struct.rs @@ -3,15 +3,15 @@ // -*- rust -*- -// Tests for alt as expressions resulting in structural types +// Tests for match as expressions resulting in structural types fn test_rec() { - let rs = alt check true { true => { {i: 100} } }; + let rs = match check true { true => { {i: 100} } }; assert (rs == {i: 100}); } fn test_tag() { enum mood { happy, sad, } - let rs = alt true { true => { happy } false => { sad } }; + let rs = match true { true => { happy } false => { sad } }; assert (rs == happy); } diff --git a/src/test/run-pass/expr-alt-unique.rs b/src/test/run-pass/expr-alt-unique.rs index 58a88bee1d3..6e261899123 100644 --- a/src/test/run-pass/expr-alt-unique.rs +++ b/src/test/run-pass/expr-alt-unique.rs @@ -3,9 +3,9 @@ // -*- rust -*- -// Tests for alt as expressions resulting in boxed types +// Tests for match as expressions resulting in boxed types fn test_box() { - let res = alt check true { true => { ~100 } }; + let res = match check true { true => { ~100 } }; assert (*res == 100); } diff --git a/src/test/run-pass/expr-alt.rs b/src/test/run-pass/expr-alt.rs index 2e855ce36fa..f744193e7dc 100644 --- a/src/test/run-pass/expr-alt.rs +++ b/src/test/run-pass/expr-alt.rs @@ -3,16 +3,16 @@ // -*- rust -*- -// Tests for using alt as an expression +// Tests for using match as an expression fn test_basic() { - let mut rs: bool = alt true { true => { true } false => { false } }; + let mut rs: bool = match true { true => { true } false => { false } }; assert (rs); - rs = alt false { true => { false } false => { true } }; + rs = match false { true => { false } false => { true } }; assert (rs); } fn test_inferrence() { - let mut rs = alt true { true => { true } false => { false } }; + let mut rs = match true { true => { true } false => { false } }; assert (rs); } @@ -20,7 +20,7 @@ fn test_alt_as_alt_head() { // Yeah, this is kind of confusing ... let rs = - alt alt false { true => { true } false => { false } } { + match match false { true => { true } false => { false } } { true => { false } false => { true } }; @@ -29,9 +29,9 @@ fn test_alt_as_alt_head() { fn test_alt_as_block_result() { let rs = - alt false { + match false { true => { false } - false => { alt true { true => { true } false => { false } } } + false => { match true { true => { true } false => { false } } } }; assert (rs); } diff --git a/src/test/run-pass/expr-empty-ret.rs b/src/test/run-pass/expr-empty-ret.rs index 1148d145ba0..42bf4bd973b 100644 --- a/src/test/run-pass/expr-empty-ret.rs +++ b/src/test/run-pass/expr-empty-ret.rs @@ -1,5 +1,5 @@ // Issue #521 -fn f() { let x = alt true { true => { 10 } false => { return } }; } +fn f() { let x = match true { true => { 10 } false => { return } }; } fn main() { } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index 8d38e5d2941..f181b3f3261 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -14,7 +14,7 @@ fn test_generic() { } fn test_alt() { - fn f() -> int { alt true { false => { 10 } true => { 20 } } } + fn f() -> int { match true { false => { 10 } true => { 20 } } } assert (f() == 20); } diff --git a/src/test/run-pass/fat-arrow-alt.rs b/src/test/run-pass/fat-arrow-alt.rs index a117039946d..5c80ebfae23 100644 --- a/src/test/run-pass/fat-arrow-alt.rs +++ b/src/test/run-pass/fat-arrow-alt.rs @@ -8,7 +8,7 @@ enum color { } fn main() { - log(error, alt red { + log(error, match red { red => { 1 } green => { 2 } blue => { 3 } diff --git a/src/test/run-pass/generic-tag-alt.rs b/src/test/run-pass/generic-tag-alt.rs index 68013a41072..fab82aaf7ae 100644 --- a/src/test/run-pass/generic-tag-alt.rs +++ b/src/test/run-pass/generic-tag-alt.rs @@ -4,7 +4,7 @@ enum foo<T> { arm(T), } fn altfoo<T>(f: foo<T>) { let mut hit = false; - alt f { arm::<T>(x) => { debug!{"in arm"}; hit = true; } } + match f { arm::<T>(x) => { debug!{"in arm"}; hit = true; } } assert (hit); } diff --git a/src/test/run-pass/generic-tag-values.rs b/src/test/run-pass/generic-tag-values.rs index 237c8c7f844..db18b4681e6 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -6,9 +6,9 @@ enum noption<T> { some(T), } fn main() { let nop: noption<int> = some::<int>(5); - alt nop { some::<int>(n) => { log(debug, n); assert (n == 5); } } + match nop { some::<int>(n) => { log(debug, n); assert (n == 5); } } let nop2: noption<{x: int, y: int}> = some({x: 17, y: 42}); - alt nop2 { + match nop2 { some(t) => { log(debug, t.x); log(debug, t.y); diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index a34fa14860d..07ea8088431 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -1,10 +1,10 @@ fn main() { let a = - alt 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; + match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; assert (a == 2); let b = - alt {x: 10, y: 20} { + match {x: 10, y: 20} { x if x.x < 5 && x.y < 5 => { 1 } {x: x, y: y} if x == 10 && y == 20 => { 2 } {x: x, y: y} => { 3 } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index e4fc8c1650f..d0098dd8afe 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -45,7 +45,7 @@ mod map_reduce { fn emit(im: map::hashmap<~str, int>, ctrl: chan<ctrl_proto>, key: ~str, val: ~str) { let mut c; - alt im.find(key) { + match im.find(key) { some(_c) => { c = _c } none => { let p = port(); @@ -78,11 +78,11 @@ mod map_reduce { let mut num_mappers = vec::len(inputs) as int; while num_mappers > 0 { - alt recv(ctrl) { + match recv(ctrl) { mapper_done => { num_mappers -= 1; } find_reducer(k, cc) => { let mut c; - alt reducers.find(str::from_bytes(k)) { + match reducers.find(str::from_bytes(k)) { some(_c) => { c = _c; } none => { c = 0; } } diff --git a/src/test/run-pass/inferred-suffix-in-pattern-range.rs b/src/test/run-pass/inferred-suffix-in-pattern-range.rs index ae9c27d7880..17f08a3ce27 100644 --- a/src/test/run-pass/inferred-suffix-in-pattern-range.rs +++ b/src/test/run-pass/inferred-suffix-in-pattern-range.rs @@ -1,20 +1,20 @@ fn main() { let x = 2; - let x_message = alt x { + let x_message = match x { 0 to 1 => { ~"not many" } _ => { ~"lots" } }; assert x_message == ~"lots"; let y = 2i; - let y_message = alt y { + let y_message = match y { 0 to 1 => { ~"not many" } _ => { ~"lots" } }; assert y_message == ~"lots"; let z = 1u64; - let z_message = alt z { + let z_message = match z { 0 to 1 => { ~"not many" } _ => { ~"lots" } }; diff --git a/src/test/run-pass/issue-1701.rs b/src/test/run-pass/issue-1701.rs index 4c1f703733d..7b411128dac 100644 --- a/src/test/run-pass/issue-1701.rs +++ b/src/test/run-pass/issue-1701.rs @@ -5,7 +5,7 @@ enum ear_kind { lop, upright } enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger } fn noise(a: animal) -> option<~str> { - alt a { + match a { cat(*) => { some(~"meow") } dog(*) => { some(~"woof") } rabbit(*) => { none } diff --git a/src/test/run-pass/issue-2101.rs b/src/test/run-pass/issue-2101.rs index 6309e967db2..8017d9da15f 100644 --- a/src/test/run-pass/issue-2101.rs +++ b/src/test/run-pass/issue-2101.rs @@ -12,7 +12,7 @@ fn init(ar: &a.arena::arena, str: str) -> &a.hold { fn main(args: ~[str]) { let ar = arena::arena(); let leak = init(&ar, args[0]); - alt *leak { + match *leak { s(astr) { io::println(fmt!{"%?", astr}); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 8fb85a7d11e..315c334f472 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -58,7 +58,7 @@ mod pipes { assert (*p).payload == none; (*p).payload <- some(payload); let old_state = swap_state_rel((*p).state, full); - alt old_state { + match old_state { empty => { // Yay, fastpath. @@ -84,7 +84,7 @@ mod pipes { loop { let old_state = swap_state_acq((*p).state, blocked); - alt old_state { + match old_state { empty | blocked => { task::yield(); } full => { let mut payload = none; @@ -101,7 +101,7 @@ mod pipes { fn sender_terminate<T: send>(p: *packet<T>) { let p = unsafe { uniquify(p) }; - alt swap_state_rel((*p).state, terminated) { + match swap_state_rel((*p).state, terminated) { empty | blocked => { // The receiver will eventually clean up. unsafe { forget(p) } @@ -118,7 +118,7 @@ mod pipes { fn receiver_terminate<T: send>(p: *packet<T>) { let p = unsafe { uniquify(p) }; - alt swap_state_rel((*p).state, terminated) { + match swap_state_rel((*p).state, terminated) { empty => { // the sender will clean up unsafe { forget(p) } @@ -178,7 +178,7 @@ mod pingpong { enum pong = pipes::send_packet<ping>; fn liberate_ping(-p: ping) -> pipes::send_packet<pong> unsafe { - let addr : *pipes::send_packet<pong> = alt p { + let addr : *pipes::send_packet<pong> = match p { ping(x) => { unsafe::reinterpret_cast(ptr::addr_of(x)) } }; let liberated_value <- *addr; @@ -187,7 +187,7 @@ mod pingpong { } fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe { - let addr : *pipes::send_packet<ping> = alt p { + let addr : *pipes::send_packet<ping> = match p { pong(x) => { unsafe::reinterpret_cast(ptr::addr_of(x)) } }; let liberated_value <- *addr; diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index dbaa37abacd..5066ff573b9 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -11,7 +11,7 @@ enum object fn lookup(table: std::map::hashmap<~str, std::json::json>, key: ~str, default: ~str) -> ~str { - alt table.find(key) + match table.find(key) { option::some(std::json::string(s)) => { @@ -31,7 +31,7 @@ fn lookup(table: std::map::hashmap<~str, std::json::json>, key: ~str, default: ~ fn add_interface(store: int, managed_ip: ~str, data: std::json::json) -> (~str, object) { - alt data + match data { std::json::dict(interface) => { @@ -50,7 +50,7 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::json) -> (~str, fn add_interfaces(store: int, managed_ip: ~str, device: std::map::hashmap<~str, std::json::json>) -> ~[(~str, object)] { - alt device[~"interfaces"] + match device[~"interfaces"] { std::json::list(interfaces) => { diff --git a/src/test/run-pass/issue-2869.rs b/src/test/run-pass/issue-2869.rs index 67d993504d1..f37322938ec 100644 --- a/src/test/run-pass/issue-2869.rs +++ b/src/test/run-pass/issue-2869.rs @@ -4,7 +4,7 @@ enum pat { pat_ident(option<uint>) } fn f(pat: pat) -> bool { true } fn num_bindings(pat: pat) -> uint { - alt pat { + match pat { pat_ident(_) if f(pat) { 0 } pat_ident(none) { 1 } pat_ident(some(sub)) { sub } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index a7ae3a55000..de1819f9577 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -17,7 +17,7 @@ enum square { impl of to_str::to_str for square { fn to_str() -> ~str { - alt self { + match self { bot => { ~"R" } wall => { ~"#" } rock => { ~"*" } @@ -31,7 +31,7 @@ impl of to_str::to_str for square { } fn square_from_char(c: char) -> square { - alt c { + match c { 'R' => { bot } '#' => { wall } '*' => { rock } diff --git a/src/test/run-pass/issue-3037.rs b/src/test/run-pass/issue-3037.rs index 92e18bde012..3907c2a796b 100644 --- a/src/test/run-pass/issue-3037.rs +++ b/src/test/run-pass/issue-3037.rs @@ -2,7 +2,7 @@ enum what { } fn what_to_str(x: what) -> ~str { - alt x { + match x { } } diff --git a/src/test/run-pass/issue-687.rs b/src/test/run-pass/issue-687.rs index a314bf4856b..f8f983d767f 100644 --- a/src/test/run-pass/issue-687.rs +++ b/src/test/run-pass/issue-687.rs @@ -48,7 +48,7 @@ fn main() { loop { let msg = recv(p); - alt msg { + match msg { closed => { debug!{"Got close message"}; break; } received(data) => { debug!{"Got data. Length is:"}; diff --git a/src/test/run-pass/keyword-changes-2012-07-31.rs b/src/test/run-pass/keyword-changes-2012-07-31.rs index c7d48d95108..95ac37c66b7 100644 --- a/src/test/run-pass/keyword-changes-2012-07-31.rs +++ b/src/test/run-pass/keyword-changes-2012-07-31.rs @@ -1,6 +1,6 @@ // return -> return // mod -> module -// alt -> match +// match -> match fn main() { } diff --git a/src/test/run-pass/leaky_comm.rs b/src/test/run-pass/leaky_comm.rs index 3a3bfa4f515..fcdafc6d8c1 100644 --- a/src/test/run-pass/leaky_comm.rs +++ b/src/test/run-pass/leaky_comm.rs @@ -6,7 +6,7 @@ use test_comm; fn main() { let p = test_comm::port(); - alt none::<int> { + match none::<int> { none => {} some(_) =>{ if test_comm::recv(p) == 0 { diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index cbaa9182dc5..a138fa1e18f 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -3,7 +3,7 @@ macro_rules! overly_complicated { {$fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path} => { fn $fnname($arg: $ty) -> option<$ty> $body - alt $fnname($val) { + match $fnname($val) { some($pat) => { $res } diff --git a/src/test/run-pass/module-polymorphism4-files/cat.rs b/src/test/run-pass/module-polymorphism4-files/cat.rs index 832cca5c4f1..f19b72ed181 100644 --- a/src/test/run-pass/module-polymorphism4-files/cat.rs +++ b/src/test/run-pass/module-polymorphism4-files/cat.rs @@ -7,7 +7,7 @@ enum cat { fn animal() -> ~str { ~"cat" } fn talk(c: cat) -> ~str { - alt c { + match c { howlycat => { ~"howl" } meowlycat => { ~"meow" } } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 1e611804f9f..59ea633f218 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -16,7 +16,7 @@ trait option_monad<A> { impl monad<A> of option_monad<A> for option<A> { fn bind<B>(f: fn(A) -> option<B>) -> option<B> { - alt self { + match self { some(a) => { f(a) } none => { none } } diff --git a/src/test/run-pass/negative.rs b/src/test/run-pass/negative.rs index 38661bb84b2..2284728f181 100644 --- a/src/test/run-pass/negative.rs +++ b/src/test/run-pass/negative.rs @@ -1,5 +1,5 @@ fn main() { - alt -5 { + match -5 { -5 => {} _ => { fail } } diff --git a/src/test/run-pass/nested-alts.rs b/src/test/run-pass/nested-alts.rs index ff0f0228a63..795a42f9790 100644 --- a/src/test/run-pass/nested-alts.rs +++ b/src/test/run-pass/nested-alts.rs @@ -2,10 +2,10 @@ fn baz() -> ! { fail; } fn foo() { - alt some::<int>(5) { + match some::<int>(5) { some::<int>(x) => { let mut bar; - alt none::<int> { none::<int> => { bar = 5; } _ => { baz(); } } + match none::<int> { none::<int> => { bar = 5; } _ => { baz(); } } log(debug, bar); } none::<int> => { debug!{"hello"}; } diff --git a/src/test/run-pass/nested-exhaustive-alt.rs b/src/test/run-pass/nested-exhaustive-alt.rs index 51d7b7d4538..4cfd1eaea12 100644 --- a/src/test/run-pass/nested-exhaustive-alt.rs +++ b/src/test/run-pass/nested-exhaustive-alt.rs @@ -1,5 +1,5 @@ fn main() { - alt @{foo: true, bar: some(10), baz: 20} { + match @{foo: true, bar: some(10), baz: 20} { @{foo: true, bar: some(_), _} => {} @{foo: false, bar: none, _} => {} @{foo: true, bar: none, _} => {} diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs index ae901d1f9f1..a79b0844934 100644 --- a/src/test/run-pass/nested-pattern.rs +++ b/src/test/run-pass/nested-pattern.rs @@ -9,7 +9,7 @@ import option::none; enum t { foo(int, uint), bar(int, option<int>), } fn nested(o: t) { - alt o { + match o { bar(i, some::<int>(_)) => { error!{"wrong pattern matched"}; fail; } _ => { error!{"succeeded"}; } } diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index 0b93154b566..1066b5c8aef 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -1,5 +1,5 @@ fn main() { - alt {a: 10, b: @20} { + match {a: 10, b: @20} { x@{a, b: @20} => { assert x.a == 10; assert a == 10; } {b, _} => { fail; } } diff --git a/src/test/run-pass/nil-pattern.rs b/src/test/run-pass/nil-pattern.rs index c1ef9c5970e..7261cf4e2da 100644 --- a/src/test/run-pass/nil-pattern.rs +++ b/src/test/run-pass/nil-pattern.rs @@ -1 +1 @@ -fn main() { let x = (); alt x { () => { } } } +fn main() { let x = (); match x { () => { } } } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index a338fd39101..5a86d54c77f 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -3,7 +3,7 @@ use std; import std::list::*; pure fn pure_length_go<T: copy>(ls: @list<T>, acc: uint) -> uint { - alt *ls { nil => { acc } cons(_, tl) => { pure_length_go(tl, acc + 1u) } } + match *ls { nil => { acc } cons(_, tl) => { pure_length_go(tl, acc + 1u) } } } pure fn pure_length<T: copy>(ls: @list<T>) -> uint { pure_length_go(ls, 0u) } diff --git a/src/test/run-pass/nullary-or-pattern.rs b/src/test/run-pass/nullary-or-pattern.rs index a856eb3e61b..a73c98bfa4e 100644 --- a/src/test/run-pass/nullary-or-pattern.rs +++ b/src/test/run-pass/nullary-or-pattern.rs @@ -1,7 +1,7 @@ enum blah { a, b, } fn or_alt(q: blah) -> int { - alt q { a | b => { 42 } } + match q { a | b => { 42 } } } fn main() { diff --git a/src/test/run-pass/or-pattern.rs b/src/test/run-pass/or-pattern.rs index 979bf5522e9..d1316e7c0ce 100644 --- a/src/test/run-pass/or-pattern.rs +++ b/src/test/run-pass/or-pattern.rs @@ -1,7 +1,7 @@ enum blah { a(int, int, uint), b(int, int), c, } fn or_alt(q: blah) -> int { - alt q { a(x, y, _) | b(x, y) => { return x + y; } c => { return 0; } } + match q { a(x, y, _) | b(x, y) => { return x + y; } c => { return 0; } } } fn main() { diff --git a/src/test/run-pass/paren-free.rs b/src/test/run-pass/paren-free.rs index 5e115abb0dc..b9ea40b2b52 100644 --- a/src/test/run-pass/paren-free.rs +++ b/src/test/run-pass/paren-free.rs @@ -1,5 +1,5 @@ fn main() { let x = true; if x { let mut i = 10; while i > 0 { i -= 1; } } - alt x { true => { debug!{"right"}; } false => { debug!{"wrong"}; } } + match x { true => { debug!{"right"}; } false => { debug!{"wrong"}; } } } diff --git a/src/test/run-pass/pattern-bound-var-in-for-each.rs b/src/test/run-pass/pattern-bound-var-in-for-each.rs index ae753296a2f..ca049e1718c 100644 --- a/src/test/run-pass/pattern-bound-var-in-for-each.rs +++ b/src/test/run-pass/pattern-bound-var-in-for-each.rs @@ -4,7 +4,7 @@ fn foo(src: uint) { - alt some(src) { + match some(src) { some(src_id) => { for uint::range(0u, 10u) |i| { let yyy = src_id; diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index 81e33bbbebb..a3383a688cb 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -47,7 +47,7 @@ macro_rules! follow { { $($message:path($($x: ident),+) => $next:ident $e:expr)+ } => ( - |m| alt move_it(m) { + |m| match move_it(m) { $(some($message($($x,)* next)) { let $next = move_it!{next}; $e })+ @@ -58,7 +58,7 @@ macro_rules! follow { { $($message:path => $next:ident $e:expr)+ } => ( - |m| alt move_it(m) { + |m| match move_it(m) { $(some($message(next)) { let $next = move_it!{next}; $e })+ @@ -91,7 +91,7 @@ fn client_follow(+bank: bank::client::login) { let bank = client::deposit(bank, 100.00); let bank = client::withdrawal(bank, 50.00); - alt try_recv(bank) { + match try_recv(bank) { some(money(m, _)) { io::println(~"Yay! I got money!"); } @@ -109,7 +109,7 @@ fn bank_client(+bank: bank::client::login) { import bank::*; let bank = client::login(bank, ~"theincredibleholk", ~"1234"); - let bank = alt try_recv(bank) { + let bank = match try_recv(bank) { some(ok(connected)) => { move_it!{connected} } @@ -119,7 +119,7 @@ fn bank_client(+bank: bank::client::login) { let bank = client::deposit(bank, 100.00); let bank = client::withdrawal(bank, 50.00); - alt try_recv(bank) { + match try_recv(bank) { some(money(m, _)) => { io::println(~"Yay! I got money!"); } diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs index b68be9cb23c..9c99f1dce02 100644 --- a/src/test/run-pass/pipe-detect-term.rs +++ b/src/test/run-pass/pipe-detect-term.rs @@ -19,7 +19,7 @@ fn main() { let iotask = uv::global_loop::get(); pipes::spawn_service(oneshot::init, |p| { - alt try_recv(p) { + match try_recv(p) { some(*) => { fail } none => { } } diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 856bb3fe5cc..6c315123f53 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -78,7 +78,7 @@ fn test_select2() { stream::client::send(ac, 42); - alt pipes::select2(ap, bp) { + match pipes::select2(ap, bp) { either::left(*) => { } either::right(*) => { fail } } @@ -92,7 +92,7 @@ fn test_select2() { stream::client::send(bc, ~"abc"); - alt pipes::select2(ap, bp) { + match pipes::select2(ap, bp) { either::left(*) => { fail } either::right(*) => { } } diff --git a/src/test/run-pass/record-pat.rs b/src/test/run-pass/record-pat.rs index 9ccdf58c4f1..0507b84d7af 100644 --- a/src/test/run-pass/record-pat.rs +++ b/src/test/run-pass/record-pat.rs @@ -3,7 +3,7 @@ type t2 = {x: t1, y: int}; enum t3 { c(t2, uint), } fn m(in: t3) -> int { - alt in { + match in { c({x: a(m), _}, _) => { return m; } c({x: b(m), y: y}, z) => { return ((m + z) as int) + y; } } diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs index dccdc6ce384..d380f624ee3 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs @@ -7,7 +7,7 @@ fn main() { // below. note that it would it you // naively borrowed &x for the lifetime // of the variable x, as we once did - alt i { + match i { i => { let y = &x; assert i < *y; diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs index bd03a2ff6e7..9f1588e9b2b 100644 --- a/src/test/run-pass/regions-self-in-enums.rs +++ b/src/test/run-pass/regions-self-in-enums.rs @@ -6,7 +6,7 @@ fn main() { let x = 3; let y = int_wrapper_ctor(&x); let mut z : ∫ - alt y { + match y { int_wrapper_ctor(zz) => { z = zz; } } log(debug, *z); diff --git a/src/test/run-pass/shadow.rs b/src/test/run-pass/shadow.rs index 96b018e6a3b..c01cc550260 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -4,7 +4,7 @@ fn foo(c: ~[int]) { let mut b: ~[int] = ~[]; - alt none::<int> { + match none::<int> { some::<int>(_) => { for c.each |i| { log(debug, a); diff --git a/src/test/run-pass/simple-alt-generic-tag.rs b/src/test/run-pass/simple-alt-generic-tag.rs index ef5bd284a0d..0fa6e4568d4 100644 --- a/src/test/run-pass/simple-alt-generic-tag.rs +++ b/src/test/run-pass/simple-alt-generic-tag.rs @@ -4,5 +4,5 @@ enum opt<T> { none, } fn main() { let x = none::<int>; - alt x { none::<int> => { debug!{"hello world"}; } } + match x { none::<int> => { debug!{"hello world"}; } } } diff --git a/src/test/run-pass/simple-generic-alt.rs b/src/test/run-pass/simple-generic-alt.rs index 2bf60273c54..0503e9b69bd 100644 --- a/src/test/run-pass/simple-generic-alt.rs +++ b/src/test/run-pass/simple-generic-alt.rs @@ -2,4 +2,4 @@ enum clam<T> { a(T), } -fn main() { let c = a(2); alt c { a::<int>(_) => { } } } +fn main() { let c = a(2); match c { a::<int>(_) => { } } } diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index 5c325e25f48..5403d79f4f9 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -5,7 +5,7 @@ enum clam<T> { a(T, int), b, } fn uhoh<T>(v: ~[clam<T>]) { - alt v[1] { + match v[1] { a::<T>(t, u) => { debug!{"incorrect"}; log(debug, u); fail; } b::<T> => { debug!{"correct"}; } } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 9ceede21207..1c0a7ccbc01 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -22,7 +22,7 @@ fn is_aligned<A>(amnt: uint, &&u: A) -> bool { } fn variant_data_is_aligned<A,B>(amnt: uint, &&u: a_tag<A,B>) -> bool { - alt u { + match u { varA(a) { is_aligned(amnt, a) } varB(b) { is_aligned(amnt, b) } } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index 2b43cb7061f..95a84a30055 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -29,7 +29,7 @@ fn test_color(color: color, val: int, name: ~str) unsafe { } fn get_color_alt(color: color) -> ~str { - alt color { + match color { red => {~"red"} green => {~"green"} blue => {~"blue"} diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index a56061a8ff5..dc097c515ca 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -13,7 +13,7 @@ trait to_str { impl <T: to_str> of to_str for option<T> { fn to_str() -> ~str { - alt self { + match self { none => { ~"none" } some(t) => { ~"some(" + t.to_str() + ~")" } } diff --git a/src/test/run-pass/typestate-cfg-nesting.rs b/src/test/run-pass/typestate-cfg-nesting.rs index a1825737a4e..53d0ab7db0e 100644 --- a/src/test/run-pass/typestate-cfg-nesting.rs +++ b/src/test/run-pass/typestate-cfg-nesting.rs @@ -2,7 +2,7 @@ fn f() { let x = 10; let mut y = 11; - if true { alt x { _ => { y = x; } } } else { } + if true { match x { _ => { y = x; } } } else { } } fn main() { diff --git a/src/test/run-pass/unique-alt-discrim.rs b/src/test/run-pass/unique-alt-discrim.rs index 2f155ef00e7..6dc3b616182 100644 --- a/src/test/run-pass/unique-alt-discrim.rs +++ b/src/test/run-pass/unique-alt-discrim.rs @@ -1,7 +1,7 @@ // Issue #961 fn altsimple() { - alt ~true { + match ~true { _ => { } } } diff --git a/src/test/run-pass/unique-in-tag.rs b/src/test/run-pass/unique-in-tag.rs index aaba73c72d0..8fe2671684f 100644 --- a/src/test/run-pass/unique-in-tag.rs +++ b/src/test/run-pass/unique-in-tag.rs @@ -2,7 +2,7 @@ fn test1() { enum bar { u(~int), w(int), } let x = u(~10); - assert alt x { + assert match x { u(a) => { log(error, a); *a diff --git a/src/test/run-pass/unique-pat-2.rs b/src/test/run-pass/unique-pat-2.rs index 241ff4b1d3a..c383b490578 100644 --- a/src/test/run-pass/unique-pat-2.rs +++ b/src/test/run-pass/unique-pat-2.rs @@ -3,7 +3,7 @@ type foo = {a: int, b: uint}; enum bar { u(~foo), w(int), } fn main() { - assert (alt u(~{a: 10, b: 40u}) { + assert (match u(~{a: 10, b: 40u}) { u(~{a: a, b: b}) => { a + (b as int) } _ => { 66 } } == 50); diff --git a/src/test/run-pass/unique-pat-3.rs b/src/test/run-pass/unique-pat-3.rs index edc5be4d159..29553fadc00 100644 --- a/src/test/run-pass/unique-pat-3.rs +++ b/src/test/run-pass/unique-pat-3.rs @@ -2,7 +2,7 @@ enum bar { u(~int), w(int), } fn main() { - assert alt u(~10) { + assert match u(~10) { u(a) => { log(error, a); *a diff --git a/src/test/run-pass/unique-pat.rs b/src/test/run-pass/unique-pat.rs index 81c1e6ccbd6..5f38a46ec86 100644 --- a/src/test/run-pass/unique-pat.rs +++ b/src/test/run-pass/unique-pat.rs @@ -1,5 +1,5 @@ fn simple() { - alt ~true { + match ~true { ~true => { } _ => { fail; } } diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index e48056d68c0..81c4586d76c 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -22,7 +22,7 @@ fn log_again() { loop { log(error, again); } } fn ret_ret() -> int { return (return 2) + 3; } fn ret_guard() { - alt 2 { + match 2 { x if (return) => { x; } _ => {} } diff --git a/src/test/run-pass/use-uninit-alt.rs b/src/test/run-pass/use-uninit-alt.rs index 21b1c1d66da..477416c7efd 100644 --- a/src/test/run-pass/use-uninit-alt.rs +++ b/src/test/run-pass/use-uninit-alt.rs @@ -2,7 +2,7 @@ fn foo<T>(o: myoption<T>) -> int { let mut x: int = 5; - alt o { none::<T> => { } some::<T>(t) => { x += 1; } } + match o { none::<T> => { } some::<T>(t) => { x += 1; } } return x; } diff --git a/src/test/run-pass/use-uninit-alt2.rs b/src/test/run-pass/use-uninit-alt2.rs index b06d2035644..63705a759cd 100644 --- a/src/test/run-pass/use-uninit-alt2.rs +++ b/src/test/run-pass/use-uninit-alt2.rs @@ -2,7 +2,7 @@ fn foo<T>(o: myoption<T>) -> int { let mut x: int; - alt o { none::<T> => { fail; } some::<T>(t) => { x = 5; } } + match o { none::<T> => { fail; } some::<T>(t) => { x = 5; } } return x; } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 5e7fe0b0524..cbd16d00a8f 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -19,7 +19,7 @@ fn zombiejesus() { loop { while (return) { if (return) { - alt (return) { + match (return) { 1 => { if (return) { return @@ -59,7 +59,7 @@ fn canttouchthis() -> uint { fn angrydome() { loop { if break { } } let mut i = 0; - loop { i += 1; if i == 1 { alt check again { 1 => { } } } break; } + loop { i += 1; if i == 1 { match check again { 1 => { } } } break; } } fn evil_lincoln() { let evil <- debug!{"lincoln"}; } |
