diff options
Diffstat (limited to 'src')
454 files changed, 3831 insertions, 3752 deletions
diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index e7c661734f4..ab1ee6c052e 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -125,7 +125,7 @@ fn is_uuid(id: ~str) -> bool { } if !part.all(is_hex_digit) { - ret false; + return false; } alt i { @@ -148,10 +148,10 @@ fn is_uuid(id: ~str) -> bool { } } if correct >= 5u { - ret true; + return true; } } - ret false; + return false; } #[test] @@ -207,10 +207,10 @@ fn is_git_url(url: ~str) -> bool { fn assume_source_method(url: ~str) -> ~str { if is_git_url(url) { - ret ~"git"; + return ~"git"; } if str::starts_with(url, ~"file://") || os::path_exists(url) { - ret ~"file"; + return ~"file"; } ~"curl" @@ -350,7 +350,7 @@ fn load_crate(filename: ~str) -> option<crate> { crate_type: crate_type, deps: deps }) } - _ { ret none; } + _ { return none; } } } @@ -367,7 +367,7 @@ fn rest(s: ~str, start: uint) -> ~str { } fn need_dir(s: ~str) { - if os::path_is_dir(s) { ret; } + if os::path_is_dir(s) { return; } if !os::make_dir(s, 493_i32 /* oct: 755 */) { fail fmt!{"can't make_dir %s", s}; } @@ -419,7 +419,7 @@ fn parse_source(name: ~str, j: json::json) -> source { if method == ~"file" { url = os::make_absolute(url); } - ret @{ + return @{ name: name, mut url: url, mut method: method, @@ -432,7 +432,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) { ret; } + if !os::path_exists(filename) { return; } let c = io::read_whole_file_str(filename); alt json::from_str(result::get(c)) { ok(json::dict(j)) { @@ -454,13 +454,13 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { + src.name + ~", '" + *n + ~"'"+ ~" is an invalid name (alphanumeric, underscores and" + ~" dashes only)"); - ret; + return; } *n } _ { warn(~"malformed source json: " + src.name + ~" (missing name)"); - ret; + return; } }; @@ -470,13 +470,13 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { warn(~"malformed source json: " + src.name + ~", '" + *n + ~"'"+ ~" is an invalid uuid"); - ret; + return; } *n } _ { warn(~"malformed source json: " + src.name + ~" (missing uuid)"); - ret; + return; } }; @@ -484,7 +484,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { some(json::string(n)) { *n } _ { warn(~"malformed source json: " + src.name + ~" (missing url)"); - ret; + return; } }; @@ -493,7 +493,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { _ { warn(~"malformed source json: " + src.name + ~" (missing method)"); - ret; + return; } }; @@ -520,7 +520,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { _ { warn(~"malformed source json: " + src.name + ~" (missing description)"); - ret; + return; } }; @@ -551,7 +551,7 @@ fn load_one_source_package(src: source, p: map::hashmap<~str, json::json>) { fn load_source_info(c: cargo, src: source) { let dir = path::connect(c.sourcedir, src.name); let srcfile = path::connect(dir, ~"source.json"); - if !os::path_exists(srcfile) { ret; } + if !os::path_exists(srcfile) { return; } let srcstr = io::read_whole_file_str(srcfile); alt json::from_str(result::get(srcstr)) { ok(json::dict(s)) { @@ -573,7 +573,7 @@ fn load_source_packages(c: cargo, src: source) { log(debug, ~"loading source: " + src.name); let dir = path::connect(c.sourcedir, src.name); let pkgfile = path::connect(dir, ~"packages.json"); - if !os::path_exists(pkgfile) { ret; } + if !os::path_exists(pkgfile) { return; } let pkgstr = io::read_whole_file_str(pkgfile); alt json::from_str(result::get(pkgstr)) { ok(json::list(js)) { @@ -718,7 +718,7 @@ fn run_in_buildpath(what: ~str, path: ~str, subdir: ~str, cf: ~str, ~[~"--out-dir", buildpath, cf] + extra_flags); if p.status != 0 { error(fmt!{"rustc failed: %d\n%s\n%s", p.status, p.err, p.out}); - ret none; + return none; } some(buildpath) } @@ -726,7 +726,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, ~[ ~"--test"]) { - none { ret; } + none { return; } some(bp) { bp } }; run_programs(buildpath); @@ -735,7 +735,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, ~"/build", cf, ~[]) { - none { ret; } + none { return; } some(bp) { bp } }; let newv = os::list_dir_path(buildpath); @@ -867,7 +867,7 @@ fn cargo_suggestion(c: cargo, fallback: fn()) if c.sources.size() == 0u { error(~"no sources defined - you may wish to run " + ~"`cargo init`"); - ret; + return; } fallback(); } @@ -882,12 +882,12 @@ fn install_uuid(c: cargo, wd: ~str, uuid: ~str) { if vec::len(ps) == 1u { let (sname, p) = copy ps[0]; install_package(c, sname, wd, p); - ret; + return; } else if vec::len(ps) == 0u { cargo_suggestion(c, || { error(~"can't find package: " + uuid); }); - ret; + return; } error(~"found multiple packages:"); for ps.each |elt| { @@ -906,12 +906,12 @@ fn install_named(c: cargo, wd: ~str, name: ~str) { if vec::len(ps) == 1u { let (sname, p) = copy ps[0]; install_package(c, sname, wd, p); - ret; + return; } else if vec::len(ps) == 0u { cargo_suggestion(c, || { error(~"can't find package: " + name); }); - ret; + return; } error(~"found multiple packages:"); for ps.each |elt| { @@ -929,7 +929,7 @@ fn install_uuid_specific(c: cargo, wd: ~str, src: ~str, uuid: ~str) { install_package(c, src, wd, p); true } else { false } - }) { ret; } + }) { return; } } _ { } } @@ -945,7 +945,7 @@ fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) { install_package(c, src, wd, p); true } else { false } - }) { ret; } + }) { return; } } _ { } } @@ -955,7 +955,7 @@ fn install_named_specific(c: cargo, wd: ~str, src: ~str, name: ~str) { fn cmd_uninstall(c: cargo) { if vec::len(c.opts.free) < 3u { cmd_usage(); - ret; + return; } let lib = c.libdir; @@ -976,7 +976,7 @@ fn cmd_uninstall(c: cargo) { } else { error(~"could not uninstall: '" + full + ~"'"); } - ret; + return; } none { again; } } @@ -994,7 +994,7 @@ fn cmd_uninstall(c: cargo) { } else { error(~"could not uninstall: '" + full + ~"'"); } - ret; + return; } none { again; } } @@ -1008,7 +1008,7 @@ fn cmd_uninstall(c: cargo) { } else { error(~"could not uninstall: '" + full + ~"'"); } - ret; + return; } none { again; } } @@ -1022,7 +1022,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) { alt c.dep_cache.find(target) { some(inst) { if inst { - ret; + return; } } none {} @@ -1032,7 +1032,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) { if is_archive_path(target) { install_file(c, wd, target); - ret; + return; } else if is_git_url(target) { let reference = if c.opts.free.len() >= 4u { some(c.opts.free[3u]) @@ -1042,7 +1042,7 @@ fn install_query(c: cargo, wd: ~str, target: ~str) { install_git(c, wd, target, reference); } else if !valid_pkg_name(target) && has_archive_extension(target) { install_curl(c, wd, target); - ret; + return; } else { let mut ps = copy target; @@ -1094,7 +1094,7 @@ fn cmd_install(c: cargo) unsafe { } install_source(c, wd); - ret; + return; } sync(c); @@ -1127,7 +1127,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { if !os::copy_file(path::connect(url, ~"packages.json"), pkgfile) { error(fmt!{"fetch for source %s (url %s) failed", name, url}); - ret false; + return false; } if os::copy_file(path::connect(url, ~"source.json"), srcfile) { @@ -1143,7 +1143,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { ~[~"-f", ~"-s", ~"-o", keyfile, u]); if p.status != 0 { error(fmt!{"fetch for source %s (key %s) failed", name, u}); - ret false; + return false; } pgp::add(c.root, keyfile); } @@ -1156,7 +1156,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { if !r { error(fmt!{"signature verification failed for source %s", name}); - ret false; + return false; } if has_src_file { @@ -1165,7 +1165,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { if !e { error(fmt!{"signature verification failed for source %s", name}); - ret false; + return false; } } } @@ -1186,7 +1186,7 @@ fn sync_one_file(c: cargo, dir: ~str, src: source) -> bool { info(fmt!{"synced source: %s", name}); - ret true; + return true; } fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { @@ -1227,20 +1227,20 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { if p.status != 0 { error(fmt!{"fetch for source %s (url %s) failed", name, url}); - ret false; + return false; } } else { if !os::change_dir(dir) { error(fmt!{"fetch for source %s (url %s) failed", name, url}); - ret false; + return false; } let p = run::program_output(~"git", ~[~"pull"]); if p.status != 0 { error(fmt!{"fetch for source %s (url %s) failed", name, url}); - ret false; + return false; } } @@ -1253,7 +1253,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { if p.status != 0 { error(fmt!{"fetch for source %s (key %s) failed", name, u}); rollback(name, dir, false); - ret false; + return false; } pgp::add(c.root, keyfile); } @@ -1267,7 +1267,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { error(fmt!{"signature verification failed for source %s", name}); rollback(name, dir, false); - ret false; + return false; } if has_src_file { @@ -1277,7 +1277,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { error(fmt!{"signature verification failed for source %s", name}); rollback(name, dir, false); - ret false; + return false; } } } @@ -1288,7 +1288,7 @@ fn sync_one_git(c: cargo, dir: ~str, src: source) -> bool { info(fmt!{"synced source: %s", name}); - ret true; + return true; } fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { @@ -1313,7 +1313,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { if p.status != 0 { error(fmt!{"fetch for source %s (url %s) failed", name, url}); - ret false; + return false; } if smart { url = src.url + ~"/source.json"; @@ -1332,7 +1332,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { ~[~"-f", ~"-s", ~"-o", keyfile, u]); if p.status != 0 { error(fmt!{"fetch for source %s (key %s) failed", name, u}); - ret false; + return false; } pgp::add(c.root, keyfile); } @@ -1351,7 +1351,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { sigfile, url]); if p.status != 0 { error(fmt!{"fetch for source %s (sig %s) failed", name, url}); - ret false; + return false; } let r = pgp::verify(c.root, pkgfile, sigfile, f); @@ -1359,7 +1359,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { if !r { error(fmt!{"signature verification failed for source %s", name}); - ret false; + return false; } if smart && has_src_file { @@ -1371,7 +1371,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { if p.status != 0 { error(fmt!{"fetch for source %s (sig %s) failed", name, url}); - ret false; + return false; } let e = pgp::verify(c.root, srcfile, srcsigfile, f); @@ -1379,7 +1379,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { if !e { error(~"signature verification failed for " + ~"source " + name); - ret false; + return false; } } } @@ -1400,7 +1400,7 @@ fn sync_one_curl(c: cargo, dir: ~str, src: source) -> bool { info(fmt!{"synced source: %s", name}); - ret true; + return true; } fn sync_one(c: cargo, src: source) { @@ -1435,20 +1435,20 @@ fn cmd_init(c: cargo) { run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", srcfile, srcurl]); if p.status != 0 { error(fmt!{"fetch of sources.json failed: %s", p.out}); - ret; + return; } let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", sigfile, sigurl]); if p.status != 0 { error(fmt!{"fetch of sources.json.sig failed: %s", p.out}); - ret; + return; } let r = pgp::verify(c.root, srcfile, sigfile, pgp::signing_key_fp()); if !r { error(fmt!{"signature verification failed for '%s'", srcfile}); - ret; + return; } copy_warn(srcfile, destsrcfile); @@ -1518,7 +1518,7 @@ fn cmd_list(c: cargo) { fn cmd_search(c: cargo) { if vec::len(c.opts.free) < 3u { cmd_usage(); - ret; + return; } sync(c); @@ -1559,7 +1559,7 @@ fn dump_cache(c: cargo) { } fn dump_sources(c: cargo) { if c.sources.size() < 1u { - ret; + return; } need_dir(c.root); @@ -1618,7 +1618,7 @@ fn cmd_sources(c: cargo) { info(fmt!{"%s (%s) via %s", v.name, v.url, v.method}); } - ret; + return; } let action = c.opts.free[2u]; @@ -1634,7 +1634,7 @@ fn cmd_sources(c: cargo) { ~"add" { if vec::len(c.opts.free) < 5u { cmd_usage(); - ret; + return; } let name = c.opts.free[3u]; @@ -1642,7 +1642,7 @@ fn cmd_sources(c: cargo) { if !valid_pkg_name(name) { error(fmt!{"'%s' is an invalid source name", name}); - ret; + return; } alt c.sources.find(name) { @@ -1665,14 +1665,14 @@ fn cmd_sources(c: cargo) { ~"remove" { if vec::len(c.opts.free) < 4u { cmd_usage(); - ret; + return; } let name = c.opts.free[3u]; if !valid_pkg_name(name) { error(fmt!{"'%s' is an invalid source name", name}); - ret; + return; } alt c.sources.find(name) { @@ -1688,7 +1688,7 @@ fn cmd_sources(c: cargo) { ~"set-url" { if vec::len(c.opts.free) < 5u { cmd_usage(); - ret; + return; } let name = c.opts.free[3u]; @@ -1696,7 +1696,7 @@ fn cmd_sources(c: cargo) { if !valid_pkg_name(name) { error(fmt!{"'%s' is an invalid source name", name}); - ret; + return; } alt c.sources.find(name) { @@ -1719,7 +1719,7 @@ fn cmd_sources(c: cargo) { ~"set-method" { if vec::len(c.opts.free) < 5u { cmd_usage(); - ret; + return; } let name = c.opts.free[3u]; @@ -1727,7 +1727,7 @@ fn cmd_sources(c: cargo) { if !valid_pkg_name(name) { error(fmt!{"'%s' is an invalid source name", name}); - ret; + return; } alt c.sources.find(name) { @@ -1753,7 +1753,7 @@ fn cmd_sources(c: cargo) { ~"rename" { if vec::len(c.opts.free) < 5u { cmd_usage(); - ret; + return; } let name = c.opts.free[3u]; @@ -1761,11 +1761,11 @@ fn cmd_sources(c: cargo) { if !valid_pkg_name(name) { error(fmt!{"'%s' is an invalid source name", name}); - ret; + return; } if !valid_pkg_name(newn) { error(fmt!{"'%s' is an invalid source name", newn}); - ret; + return; } alt c.sources.find(name) { @@ -1879,7 +1879,7 @@ fn main(argv: ~[~str]) { if vec::len(o.free) < 2u { cmd_usage(); - ret; + return; } if o.help { alt o.free[1] { @@ -1891,11 +1891,11 @@ fn main(argv: ~[~str]) { ~"sources" { cmd_usage_sources(); } _ { cmd_usage(); } } - ret; + return; } if o.free[1] == ~"usage" { cmd_usage(); - ret; + return; } let mut c = configure(o); diff --git a/src/cargo/pgp.rs b/src/cargo/pgp.rs index 6977cdf0256..c79d7f3bcf3 100644 --- a/src/cargo/pgp.rs +++ b/src/cargo/pgp.rs @@ -1,5 +1,5 @@ fn gpg(args: ~[~str]) -> { status: int, out: ~str, err: ~str } { - ret run::program_output(~"gpg", args); + return run::program_output(~"gpg", args); } fn signing_key() -> ~str { @@ -91,7 +91,7 @@ fn verify(root: ~str, data: ~str, sig: ~str, keyfp: ~str) -> bool { data]); let res = ~"Primary key fingerprint: " + keyfp; for str::split_char(p.err, '\n').each |line| { - if line == res { ret true; } + if line == res { return true; } } - ret false; + return false; } diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 42d69566152..4fc88009bc6 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -47,7 +47,7 @@ fn parse_config(args: ~[~str]) -> config { err(f) { fail getopts::fail_str(f) } }; - ret {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"), + return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"), run_lib_path: getopts::opt_str(matches, ~"run-lib-path"), rustc_path: getopts::opt_str(matches, ~"rustc-path"), src_base: getopts::opt_str(matches, ~"src-base"), @@ -143,7 +143,7 @@ fn make_tests(config: config) -> ~[test::test_desc] { vec::push(tests, make_test(config, file)) } } - ret tests; + return tests; } fn is_test(config: config, testfile: ~str) -> bool { @@ -163,7 +163,7 @@ fn is_test(config: config, testfile: ~str) -> bool { if str::starts_with(name, pre) { valid = false; } } - ret valid; + return valid; } fn make_test(config: config, testfile: ~str) -> diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index e44c80e79b9..431843d9268 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -17,14 +17,14 @@ fn load_errors(testfile: ~str) -> ~[expected_error] { error_patterns += parse_expected(line_num, ln); line_num += 1u; } - ret error_patterns; + return error_patterns; } fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe { let error_tag = ~"//~"; let mut idx; alt str::find_str(line, error_tag) { - option::none { ret ~[]; } + option::none { return ~[]; } option::some(nn) { idx = (nn as uint) + str::len(error_tag); } } @@ -49,5 +49,5 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe { debug!{"line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg}; - ret ~[{line: line_num - adjust_line, kind: kind, msg: msg}]; + return ~[{line: line_num - adjust_line, kind: kind, msg: msg}]; } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index c5101174424..ec214f5b586 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -51,7 +51,7 @@ fn load_props(testfile: ~str) -> test_props { vec::push(exec_env, ee); } }; - ret { + return { error_patterns: error_patterns, compile_flags: compile_flags, pp_exact: pp_exact, @@ -63,12 +63,12 @@ fn load_props(testfile: ~str) -> test_props { fn is_test_ignored(config: config, testfile: ~str) -> bool { let mut found = false; for iter_header(testfile) |ln| { - if parse_name_directive(ln, ~"xfail-test") { ret true; } - if parse_name_directive(ln, xfail_target()) { ret true; } + if parse_name_directive(ln, ~"xfail-test") { return true; } + if parse_name_directive(ln, xfail_target()) { return true; } if config.mode == common::mode_pretty && - parse_name_directive(ln, ~"xfail-pretty") { ret true; } + parse_name_directive(ln, ~"xfail-pretty") { return true; } }; - ret found; + return found; fn xfail_target() -> ~str { ~"xfail-" + os::sysname() @@ -85,10 +85,10 @@ fn iter_header(testfile: ~str, it: fn(~str) -> bool) -> bool { // with a warm page cache. Maybe with a cold one. if str::starts_with(ln, ~"fn") || str::starts_with(ln, ~"mod") { - ret false; - } else { if !(it(ln)) { ret false; } } + return false; + } else { if !(it(ln)) { return false; } } } - ret true; + return true; } fn parse_error_pattern(line: ~str) -> option<~str> { diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 35da5d2bc6d..1a642915cd5 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -21,7 +21,7 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] { if str::ends_with(prog, ~"rustc.exe") { vec::push(env, (~"RUST_THREADS", ~"1")); } - ret env; + return env; } #[cfg(target_os = "linux")] @@ -84,7 +84,7 @@ fn run(lib_path: ~str, }; count -= 1; }; - ret {status: status, out: outs, err: errs}; + return {status: status, out: outs, err: errs}; } fn writeclose(fd: c_int, s: option<~str>) { @@ -106,5 +106,5 @@ fn readclose(fd: c_int) -> ~str { buf += str::from_bytes(bytes); } os::fclose(file); - ret buf; + return buf; } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index e708af2d6a3..ac5c3161c47 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -134,7 +134,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) { fatal_procres(~"pretty-printed source does not typecheck", procres); } - ret; + return; fn print_source(config: config, testfile: ~str, src: ~str) -> procres { compose_and_run(config, testfile, make_pp_args(config, testfile), @@ -144,7 +144,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: ~str) { fn make_pp_args(config: config, _testfile: ~str) -> procargs { let prog = config.rustc_path; let args = ~[~"-", ~"--pretty", ~"normal"]; - ret {prog: prog, args: args}; + return {prog: prog, args: args}; } fn compare_source(expected: ~str, actual: ~str) { @@ -181,7 +181,7 @@ actual:\n\ ~"--no-trans", ~"--lib", ~"-L", config.build_base, ~"-L", aux_output_dir_name(config, testfile)]; args += split_maybe_args(config.rustcflags); - ret {prog: prog, args: args}; + return {prog: prog, args: args}; } } @@ -211,7 +211,7 @@ fn check_error_patterns(props: test_props, next_err_pat = props.error_patterns[next_err_idx]; } } - if done { ret; } + if done { return; } let missing_patterns = vec::slice(props.error_patterns, next_err_idx, @@ -340,7 +340,7 @@ fn compose_and_run_compiler( } fn ensure_dir(path: path) { - if os::path_is_dir(path) { ret; } + if os::path_is_dir(path) { return; } if !os::make_dir(path, 0x1c0i32) { fail fmt!{"can't make dir %s", path}; } @@ -351,7 +351,7 @@ fn compose_and_run(config: config, testfile: ~str, procenv: ~[(~str, ~str)], lib_path: ~str, input: option<~str>) -> procres { - ret program_output(config, testfile, lib_path, + return program_output(config, testfile, lib_path, procargs.prog, procargs.args, procenv, input); } @@ -363,7 +363,7 @@ fn make_compile_args(config: config, props: test_props, extras: ~[~str], ~"-L", config.build_base] + extras; args += split_maybe_args(config.rustcflags); args += split_maybe_args(props.compile_flags); - ret {prog: prog, args: args}; + return {prog: prog, args: args}; } fn make_lib_name(config: config, auxfile: ~str, testfile: ~str) -> ~str { @@ -391,7 +391,7 @@ fn make_run_args(config: config, _props: test_props, testfile: ~str) -> }; let args = toolargs + ~[make_exe_name(config, testfile)]; - ret {prog: args[0], args: vec::slice(args, 1u, vec::len(args))}; + return {prog: args[0], args: vec::slice(args, 1u, vec::len(args))}; } fn split_maybe_args(argstr: option<~str>) -> ~[~str] { @@ -419,7 +419,7 @@ fn program_output(config: config, testfile: ~str, lib_path: ~str, prog: ~str, }; let res = procsrv::run(lib_path, prog, args, env, input); dump_output(config, testfile, res.out, res.err); - ret {status: res.status, + return {status: res.status, stdout: res.out, stderr: res.err, cmdline: cmdline}; diff --git a/src/fuzzer/ast_match.rs b/src/fuzzer/ast_match.rs index abfcac55534..dc063438e04 100644 --- a/src/fuzzer/ast_match.rs +++ b/src/fuzzer/ast_match.rs @@ -5,17 +5,17 @@ fn vec_equal<T>(v: ~[T], u: ~[T], element_equality_test: fn@(&&T, &&T) -> bool) -> bool { let Lv = vec::len(v); - if Lv != vec::len(u) { ret false; } + if Lv != vec::len(u) { return false; } let i = 0u; while i < Lv { - if !element_equality_test(v[i], u[i]) { ret false; } + if !element_equality_test(v[i], u[i]) { return false; } i += 1u; } - ret true; + return true; } -pure fn builtin_equal<T>(&&a: T, &&b: T) -> bool { ret a == b; } -pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { ret a == b; } +pure fn builtin_equal<T>(&&a: T, &&b: T) -> bool { return a == b; } +pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { return a == b; } fn main() { assert (builtin_equal(5, 5)); diff --git a/src/fuzzer/cycles.rs b/src/fuzzer/cycles.rs index dbb4ecdbaef..f0e2d7df348 100644 --- a/src/fuzzer/cycles.rs +++ b/src/fuzzer/cycles.rs @@ -39,7 +39,7 @@ type pointy = { // To add: objects; traits; anything type-parameterized? fn empty_pointy() -> @pointy { - ret @{ + return @{ mut a : none, mut b : ~none, mut c : @none, diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index ea10ff58049..39f33b732d8 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -450,7 +450,7 @@ fn has_raw_pointers(c: ast::crate) -> bool { visit::mk_simple_visitor(@{visit_ty: |a| visit_ty(has_rp, a) with *visit::default_simple_visitor()}); visit::visit_crate(c, (), v); - ret *has_rp; + return *has_rp; } fn content_is_dangerous_to_run(code: ~str) -> bool { @@ -461,16 +461,16 @@ fn content_is_dangerous_to_run(code: ~str) -> bool { ~"unsafe", ~"log"]; // python --> rust pipe deadlock? - for dangerous_patterns.each |p| { if contains(code, p) { ret true; } } - ret false; + for dangerous_patterns.each |p| { if contains(code, p) { return true; } } + return false; } fn content_is_dangerous_to_compile(code: ~str) -> bool { let dangerous_patterns = ~[~"xfail-test"]; - for dangerous_patterns.each |p| { if contains(code, p) { ret true; } } - ret false; + for dangerous_patterns.each |p| { if contains(code, p) { return true; } } + return false; } fn content_might_not_converge(code: ~str) -> bool { @@ -485,8 +485,8 @@ fn content_might_not_converge(code: ~str) -> bool { ~"\n\n\n\n\n" // https://github.com/mozilla/rust/issues/850 ]; - for confusing_patterns.each |p| { if contains(code, p) { ret true; } } - ret false; + for confusing_patterns.each |p| { if contains(code, p) { return true; } } + return false; } fn file_might_not_converge(filename: ~str) -> bool { @@ -499,9 +499,9 @@ fn file_might_not_converge(filename: ~str) -> bool { ]; - for confusing_files.each |f| { if contains(filename, f) { ret true; } } + for confusing_files.each |f| { if contains(filename, f) { return true; } } - ret false; + return false; } fn check_roundtrip_convergence(code: @~str, maxIters: uint) { @@ -512,7 +512,7 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) { while i < maxIters { oldv = newv; - if content_might_not_converge(*oldv) { ret; } + if content_might_not_converge(*oldv) { return; } newv = @parse_and_print(oldv); if oldv == newv { break; } i += 1u; @@ -592,7 +592,7 @@ fn check_variants(files: ~[~str], cx: context) { fn main(args: ~[~str]) { if vec::len(args) != 2u { error!{"usage: %s <testdir>", args[0]}; - ret; + return; } let mut files = ~[]; let root = args[1]; diff --git a/src/fuzzer/ivec_fuzz.rs b/src/fuzzer/ivec_fuzz.rs index 002654b6f6e..709f2e10c31 100644 --- a/src/fuzzer/ivec_fuzz.rs +++ b/src/fuzzer/ivec_fuzz.rs @@ -91,7 +91,7 @@ fn vec_to_str(v: ~[int]) -> str { if i + 1u < len(v) { s += ", "; } i += 1u; } - ret s + "]"; + return s + "]"; } fn show_edits(a: ~[int], xs: ~[int]) { diff --git a/src/fuzzer/rand_util.rs b/src/fuzzer/rand_util.rs index ab3c4185e0a..035b2a5e448 100644 --- a/src/fuzzer/rand_util.rs +++ b/src/fuzzer/rand_util.rs @@ -51,7 +51,7 @@ fn weighted_choice<T: copy>(r : rand::rng, v : ~[weighted<T>]) -> T { for {weight: weight, item: item} in v { so_far += weight; if so_far > chosen { - ret item; + return item; } } core::unreachable(); diff --git a/src/libcore/arc.rs b/src/libcore/arc.rs index 6a27c0b7ade..30bed71aa95 100644 --- a/src/libcore/arc.rs +++ b/src/libcore/arc.rs @@ -61,7 +61,7 @@ fn get<T: const send>(rc: &arc<T>) -> &T { // Cast us back into the correct region let r = unsafe::reinterpret_cast(&ptr.data); unsafe::forget(ptr); - ret r; + return r; } } diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 95b7c1c830e..b5d6e655e4a 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -60,7 +60,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] { <fn(push: pure fn(+A)), fn(push: fn(+A))> (builder)(|+x| unsafe::push(vec, x)); } - ret vec; + return vec; } /** diff --git a/src/libcore/char.rs b/src/libcore/char.rs index af65c3f4b96..5849d19d8c1 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -51,7 +51,7 @@ import is_XID_continue = unicode::derived_property::XID_Continue; * in terms of the Unicode General Category 'Ll' */ pure fn is_lowercase(c: char) -> bool { - ret unicode::general_category::Ll(c); + return unicode::general_category::Ll(c); } /** @@ -59,7 +59,7 @@ pure fn is_lowercase(c: char) -> bool { * in terms of the Unicode General Category 'Lu'. */ pure fn is_uppercase(c: char) -> bool { - ret unicode::general_category::Lu(c); + return unicode::general_category::Lu(c); } /** @@ -68,7 +68,7 @@ pure fn is_uppercase(c: char) -> bool { * additional 'Cc'-category control codes in the range [0x09, 0x0d] */ pure fn is_whitespace(c: char) -> bool { - ret ('\x09' <= c && c <= '\x0d') + return ('\x09' <= c && c <= '\x0d') || unicode::general_category::Zs(c) || unicode::general_category::Zl(c) || unicode::general_category::Zp(c); @@ -80,7 +80,7 @@ pure fn is_whitespace(c: char) -> bool { * 'Nl', 'No' and the Derived Core Property 'Alphabetic'. */ pure fn is_alphanumeric(c: char) -> bool { - ret unicode::derived_property::Alphabetic(c) || + return unicode::derived_property::Alphabetic(c) || unicode::general_category::Nd(c) || unicode::general_category::Nl(c) || unicode::general_category::No(c); @@ -93,7 +93,7 @@ pure fn is_ascii(c: char) -> bool { /// Indicates whether the character is numeric (Nd, Nl, or No) pure fn is_digit(c: char) -> bool { - ret unicode::general_category::Nd(c) || + return unicode::general_category::Nd(c) || unicode::general_category::Nl(c) || unicode::general_category::No(c); } @@ -117,7 +117,7 @@ pure fn to_digit(c: char, radix: uint) -> option<uint> { '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) } - _ { ret none; } + _ { return none; } }; if val < radix { some(val) } else { none } @@ -142,7 +142,7 @@ fn escape_unicode(c: char) -> ~str { str::push_str(out, str::from_char(c)); for uint::range(str::len(s), pad) |_i| { str::push_str(out, ~"0"); } str::push_str(out, s); - ret out; + return out; } /** @@ -178,7 +178,7 @@ fn escape_default(c: char) -> ~str { * -1 if a < b, 0 if a == b, +1 if a > b */ pure fn cmp(a: char, b: char) -> int { - ret if b > a { -1 } + return if b > a { -1 } else if b < a { 1 } else { 0 } } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index a4bd25e5b9d..fd1067241a8 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -207,7 +207,7 @@ fn recv_<T: send>(p: *rust_port) -> T { // this is a good place to yield task::yield(); } - ret res; + return res; } fn peek_(p: *rust_port) -> bool { diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 9db3d0bc2c4..4f1e02d674d 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -72,7 +72,7 @@ fn from_vec<A>(+v: ~[mut A]) -> dvec<A> { /// Consumes the vector and returns its contents fn unwrap<A>(-d: dvec<A>) -> ~[mut A] { let dvec_({data: v}) <- d; - ret v; + return v; } impl private_methods<A> for dvec<A> { @@ -92,7 +92,7 @@ impl private_methods<A> for dvec<A> { data <-> self.data; let data_ptr: *() = unsafe::reinterpret_cast(data); if data_ptr.is_null() { fail ~"Recursive use of dvec"; } - ret f(data); + return f(data); } } @@ -263,7 +263,7 @@ impl extensions<A:copy> for dvec<A> { #[inline(always)] pure fn get_elt(idx: uint) -> A { self.check_not_borrowed(); - ret self.data[idx]; + return self.data[idx]; } /// Overwrites the contents of the element at `idx` with `a` @@ -295,7 +295,7 @@ impl extensions<A:copy> for dvec<A> { fail ~"attempt to retrieve the last element of an empty vector"; } - ret self.data[length - 1u]; + return self.data[length - 1u]; } /// Iterates over the elements in reverse order diff --git a/src/libcore/either.rs b/src/libcore/either.rs index d1ea214ef0a..64a7abd0f35 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -28,7 +28,7 @@ fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] { for vec::each(eithers) |elt| { alt elt { left(l) { vec::push(result, l); } _ {/* fallthrough */ } } } - ret result; + return result; } fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] { @@ -38,7 +38,7 @@ fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] { for vec::each(eithers) |elt| { alt elt { right(r) { vec::push(result, r); } _ {/* fallthrough */ } } } - ret result; + return result; } fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) @@ -58,7 +58,7 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) right(r) { vec::push(rights, r); } } } - ret {lefts: lefts, rights: rights}; + return {lefts: lefts, rights: rights}; } pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> { diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 7eec13c1b1a..a4e3b2144c9 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -90,7 +90,7 @@ mod ct { let piece = piece_string(buf); vec::push(pieces, piece); } - ret ~""; + return ~""; } let mut i = 0u; while i < lim { @@ -114,15 +114,15 @@ mod ct { } else { buf += curr; i += size; } } flush_buf(buf, pieces); - ret pieces; + return pieces; } fn peek_num(s: ~str, i: uint, lim: uint) -> option<{num: uint, next: uint}> { - if i >= lim { ret none; } + if i >= lim { return none; } let c = s[i]; - if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; } + if !('0' as u8 <= c && c <= '9' as u8) { return option::none; } let n = (c - ('0' as u8)) as uint; - ret alt peek_num(s, i + 1u, lim) { + return alt peek_num(s, i + 1u, lim) { none { some({num: n, next: i + 1u}) } some(next) { let m = next.num; @@ -138,7 +138,7 @@ mod ct { let width = parse_count(s, flags.next, lim); let prec = parse_precision(s, width.next, lim); let ty = parse_type(s, prec.next, lim, error); - ret {piece: + return {piece: piece_conv({param: parm.param, flags: flags.flags, width: width.count, @@ -148,9 +148,9 @@ mod ct { } fn parse_parameter(s: ~str, i: uint, lim: uint) -> {param: option<int>, next: uint} { - if i >= lim { ret {param: none, next: i}; } + if i >= lim { return {param: none, next: i}; } let num = peek_num(s, i, lim); - ret alt num { + return alt num { none { {param: none, next: i} } some(t) { let n = t.num; @@ -164,7 +164,7 @@ mod ct { fn parse_flags(s: ~str, i: uint, lim: uint) -> {flags: ~[flag], next: uint} { let noflags: ~[flag] = ~[]; - if i >= lim { ret {flags: noflags, next: i}; } + if i >= lim { return {flags: noflags, next: i}; } fn more_(f: flag, s: ~str, i: uint, lim: uint) -> {flags: ~[flag], next: uint} { @@ -172,11 +172,11 @@ mod ct { let rest = next.flags; let j = next.next; let curr: ~[flag] = ~[f]; - ret {flags: vec::append(curr, rest), next: j}; + return {flags: vec::append(curr, rest), next: j}; } let more = |x| more_(x, s, i, lim); let f = s[i]; - ret if f == '-' as u8 { + return if f == '-' as u8 { more(flag_left_justify) } else if f == '0' as u8 { more(flag_left_zero_pad) @@ -190,7 +190,7 @@ mod ct { } fn parse_count(s: ~str, i: uint, lim: uint) -> {count: count, next: uint} { - ret if i >= lim { + return if i >= lim { {count: count_implied, next: i} } else if s[i] == '*' as u8 { let param = parse_parameter(s, i + 1u, lim); @@ -211,7 +211,7 @@ mod ct { } fn parse_precision(s: ~str, i: uint, lim: uint) -> {count: count, next: uint} { - ret if i >= lim { + return if i >= lim { {count: count_implied, next: i} } else if s[i] == '.' as u8 { let count = parse_count(s, i + 1u, lim); @@ -255,7 +255,7 @@ mod ct { } else if str::eq(tstr, ~"?") { ty_poly } else { error(~"unknown type in conversion: " + tstr) }; - ret {ty: t, next: i + 1u}; + return {ty: t, next: i + 1u}; } } @@ -288,7 +288,7 @@ mod rt { unchecked { str::unshift_char(s, ' ') }; } } - ret unchecked { pad(cv, s, pad_signed) }; + return unchecked { pad(cv, s, pad_signed) }; } pure fn conv_uint(cv: conv, u: uint) -> ~str { let prec = get_int_precision(cv); @@ -300,17 +300,17 @@ mod rt { ty_bits { uint_to_str_prec(u, 2u, prec) } ty_octal { uint_to_str_prec(u, 8u, prec) } }; - ret unchecked { pad(cv, rs, pad_unsigned) }; + return unchecked { pad(cv, rs, pad_unsigned) }; } pure fn conv_bool(cv: conv, b: bool) -> ~str { let s = if b { ~"true" } else { ~"false" }; // run the boolean conversion through the string conversion logic, // giving it the same rules for precision, etc. - ret conv_str(cv, s); + return conv_str(cv, s); } pure fn conv_char(cv: conv, c: char) -> ~str { let mut s = str::from_char(c); - ret unchecked { pad(cv, s, pad_nozero) }; + return unchecked { pad(cv, s, pad_nozero) }; } pure fn conv_str(cv: conv, s: &str) -> ~str { // For strings, precision is the maximum characters @@ -323,7 +323,7 @@ mod rt { } else { s.to_unique() } } }; - ret unchecked { pad(cv, unpadded, pad_nozero) }; + return unchecked { pad(cv, unpadded, pad_nozero) }; } pure fn conv_float(cv: conv, f: float) -> ~str { let (to_str, digits) = alt cv.precision { @@ -338,17 +338,17 @@ mod rt { s = ~" " + s; } } - ret unchecked { pad(cv, s, pad_float) }; + return unchecked { pad(cv, s, pad_float) }; } pure fn conv_poly<T>(cv: conv, v: T) -> ~str { let s = sys::log_str(v); - ret conv_str(cv, s); + return conv_str(cv, s); } // Convert an int to string with minimum number of digits. If precision is // 0 and num is 0 then the result is the empty string. pure fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str { - ret if num < 0 { + return if num < 0 { ~"-" + uint_to_str_prec(-num as uint, radix, prec) } else { uint_to_str_prec(num as uint, radix, prec) }; } @@ -357,7 +357,7 @@ mod rt { // is 0 and num is 0 then the result is the empty string. Could move this // to uint: but it doesn't seem all that useful. pure fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str { - ret if prec == 0u && num == 0u { + return if prec == 0u && num == 0u { ~"" } else { let s = uint::to_str(num, radix); @@ -370,7 +370,7 @@ mod rt { }; } pure fn get_int_precision(cv: conv) -> uint { - ret alt cv.precision { + return alt cv.precision { count_is(c) { c as uint } count_implied { 1u } }; @@ -378,19 +378,19 @@ mod rt { enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float } fn pad(cv: conv, &s: ~str, mode: pad_mode) -> ~str { let uwidth : uint = alt cv.width { - count_implied { ret s; } + count_implied { return s; } count_is(width) { // FIXME: width should probably be uint (see Issue #1996) width as uint } }; let strlen = str::char_len(s); - if uwidth <= strlen { ret s; } + if uwidth <= strlen { return s; } let mut padchar = ' '; let diff = uwidth - strlen; if have_flag(cv.flags, flag_left_justify) { let padstr = str::from_chars(vec::from_elem(diff, padchar)); - ret s + padstr; + return s + padstr; } let {might_zero_pad, signed} = alt mode { pad_nozero { {might_zero_pad:false, signed:false} } @@ -399,7 +399,7 @@ mod rt { pad_unsigned { {might_zero_pad:true, signed:false} } }; pure fn have_precision(cv: conv) -> bool { - ret alt cv.precision { count_implied { false } _ { true } }; + return alt cv.precision { count_implied { false } _ { true } }; } let zero_padding = { if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) && @@ -420,13 +420,13 @@ mod rt { let head = str::shift_char(s); if head == '+' || head == '-' || head == ' ' { let headstr = str::from_chars(vec::from_elem(1u, head)); - ret headstr + padstr + s; + return headstr + padstr + s; } else { str::unshift_char(s, head); } } - ret padstr + s; + return padstr + s; } pure fn have_flag(flags: u32, f: u32) -> bool { flags & f != 0 diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs index 3e7bc0097f7..c9852eb67b6 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/f32.rs @@ -31,38 +31,38 @@ const neg_infinity: f32 = -1.0_f32/0.0_f32; pure fn is_NaN(f: f32) -> bool { f != f } -pure fn add(x: f32, y: f32) -> f32 { ret x + y; } +pure fn add(x: f32, y: f32) -> f32 { return x + y; } -pure fn sub(x: f32, y: f32) -> f32 { ret x - y; } +pure fn sub(x: f32, y: f32) -> f32 { return x - y; } -pure fn mul(x: f32, y: f32) -> f32 { ret x * y; } +pure fn mul(x: f32, y: f32) -> f32 { return x * y; } -pure fn div(x: f32, y: f32) -> f32 { ret x / y; } +pure fn div(x: f32, y: f32) -> f32 { return x / y; } -pure fn rem(x: f32, y: f32) -> f32 { ret x % y; } +pure fn rem(x: f32, y: f32) -> f32 { return x % y; } -pure fn lt(x: f32, y: f32) -> bool { ret x < y; } +pure fn lt(x: f32, y: f32) -> bool { return x < y; } -pure fn le(x: f32, y: f32) -> bool { ret x <= y; } +pure fn le(x: f32, y: f32) -> bool { return x <= y; } -pure fn eq(x: f32, y: f32) -> bool { ret x == y; } +pure fn eq(x: f32, y: f32) -> bool { return x == y; } -pure fn ne(x: f32, y: f32) -> bool { ret x != y; } +pure fn ne(x: f32, y: f32) -> bool { return x != y; } -pure fn ge(x: f32, y: f32) -> bool { ret x >= y; } +pure fn ge(x: f32, y: f32) -> bool { return x >= y; } -pure fn gt(x: f32, y: f32) -> bool { ret x > y; } +pure fn gt(x: f32, y: f32) -> bool { return x > y; } // FIXME (#1999): replace the predicates below with llvm intrinsics or // calls to the libmath macros in the rust runtime for performance. /// Returns true if `x` is a positive number, including +0.0f320 and +Infinity pure fn is_positive(x: f32) -> bool - { ret x > 0.0f32 || (1.0f32/x) == infinity; } + { return x > 0.0f32 || (1.0f32/x) == infinity; } /// Returns true if `x` is a negative number, including -0.0f320 and -Infinity pure fn is_negative(x: f32) -> bool - { ret x < 0.0f32 || (1.0f32/x) == neg_infinity; } + { return x < 0.0f32 || (1.0f32/x) == neg_infinity; } /** * Returns true if `x` is a negative number, including -0.0f320 and -Infinity @@ -70,7 +70,7 @@ pure fn is_negative(x: f32) -> bool * This is the same as `f32::is_negative`. */ pure fn is_nonpositive(x: f32) -> bool { - ret x < 0.0f32 || (1.0f32/x) == neg_infinity; + return x < 0.0f32 || (1.0f32/x) == neg_infinity; } /** @@ -79,22 +79,22 @@ pure fn is_nonpositive(x: f32) -> bool { * This is the same as `f32::is_positive`.) */ pure fn is_nonnegative(x: f32) -> bool { - ret x > 0.0f32 || (1.0f32/x) == infinity; + return x > 0.0f32 || (1.0f32/x) == infinity; } /// Returns true if `x` is a zero number (positive or negative zero) pure fn is_zero(x: f32) -> bool { - ret x == 0.0f32 || x == -0.0f32; + return x == 0.0f32 || x == -0.0f32; } /// Returns true if `x`is an infinite number pure fn is_infinite(x: f32) -> bool { - ret x == infinity || x == neg_infinity; + return x == infinity || x == neg_infinity; } /// Returns true if `x`is a finite number pure fn is_finite(x: f32) -> bool { - ret !(is_NaN(x) || is_infinite(x)); + return !(is_NaN(x) || is_infinite(x)); } // FIXME (#1999): add is_normal, is_subnormal, and fpclassify. @@ -145,38 +145,38 @@ mod consts { } pure fn signbit(x: f32) -> int { - if is_negative(x) { ret 1; } else { ret 0; } + if is_negative(x) { return 1; } else { return 0; } } #[cfg(target_os="linux")] #[cfg(target_os="macos")] #[cfg(target_os="win32")] pure fn logarithm(n: f32, b: f32) -> f32 { - ret log2(n) / log2(b); + return log2(n) / log2(b); } #[cfg(target_os="freebsd")] pure fn logarithm(n: f32, b: f32) -> f32 { // FIXME (#2000): check if it is good to use log2 instead of ln here; // in theory should be faster since the radix is 2 - ret ln(n) / ln(b); + return ln(n) / ln(b); } #[cfg(target_os="freebsd")] pure fn log2(n: f32) -> f32 { - ret ln(n) / consts::ln_2; + return ln(n) / consts::ln_2; } impl num of num::num for f32 { - pure fn add(&&other: f32) -> f32 { ret self + other; } - pure fn sub(&&other: f32) -> f32 { ret self - other; } - pure fn mul(&&other: f32) -> f32 { ret self * other; } - pure fn div(&&other: f32) -> f32 { ret self / other; } - pure fn modulo(&&other: f32) -> f32 { ret self % other; } - pure fn neg() -> f32 { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> f32 { ret n as f32; } + pure fn add(&&other: f32) -> f32 { return self + other; } + pure fn sub(&&other: f32) -> f32 { return self - other; } + pure fn mul(&&other: f32) -> f32 { return self * other; } + pure fn div(&&other: f32) -> f32 { return self / other; } + pure fn modulo(&&other: f32) -> f32 { return self % other; } + pure fn neg() -> f32 { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> f32 { return n as f32; } } // diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs index 9e84c432bad..550ed568be4 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/f64.rs @@ -57,27 +57,27 @@ const neg_infinity: f64 = -1.0_f64/0.0_f64; pure fn is_NaN(f: f64) -> bool { f != f } -pure fn add(x: f64, y: f64) -> f64 { ret x + y; } +pure fn add(x: f64, y: f64) -> f64 { return x + y; } -pure fn sub(x: f64, y: f64) -> f64 { ret x - y; } +pure fn sub(x: f64, y: f64) -> f64 { return x - y; } -pure fn mul(x: f64, y: f64) -> f64 { ret x * y; } +pure fn mul(x: f64, y: f64) -> f64 { return x * y; } -pure fn div(x: f64, y: f64) -> f64 { ret x / y; } +pure fn div(x: f64, y: f64) -> f64 { return x / y; } -pure fn rem(x: f64, y: f64) -> f64 { ret x % y; } +pure fn rem(x: f64, y: f64) -> f64 { return x % y; } -pure fn lt(x: f64, y: f64) -> bool { ret x < y; } +pure fn lt(x: f64, y: f64) -> bool { return x < y; } -pure fn le(x: f64, y: f64) -> bool { ret x <= y; } +pure fn le(x: f64, y: f64) -> bool { return x <= y; } -pure fn eq(x: f64, y: f64) -> bool { ret x == y; } +pure fn eq(x: f64, y: f64) -> bool { return x == y; } -pure fn ne(x: f64, y: f64) -> bool { ret x != y; } +pure fn ne(x: f64, y: f64) -> bool { return x != y; } -pure fn ge(x: f64, y: f64) -> bool { ret x >= y; } +pure fn ge(x: f64, y: f64) -> bool { return x >= y; } -pure fn gt(x: f64, y: f64) -> bool { ret x > y; } +pure fn gt(x: f64, y: f64) -> bool { return x > y; } pure fn sqrt(x: f64) -> f64 { cmath::c_double::sqrt(x as libc::c_double) as f64 @@ -85,11 +85,11 @@ pure fn sqrt(x: f64) -> f64 { /// Returns true if `x` is a positive number, including +0.0f640 and +Infinity pure fn is_positive(x: f64) -> bool - { ret x > 0.0f64 || (1.0f64/x) == infinity; } + { return x > 0.0f64 || (1.0f64/x) == infinity; } /// Returns true if `x` is a negative number, including -0.0f640 and -Infinity pure fn is_negative(x: f64) -> bool - { ret x < 0.0f64 || (1.0f64/x) == neg_infinity; } + { return x < 0.0f64 || (1.0f64/x) == neg_infinity; } /** * Returns true if `x` is a negative number, including -0.0f640 and -Infinity @@ -97,7 +97,7 @@ pure fn is_negative(x: f64) -> bool * This is the same as `f64::is_negative`. */ pure fn is_nonpositive(x: f64) -> bool { - ret x < 0.0f64 || (1.0f64/x) == neg_infinity; + return x < 0.0f64 || (1.0f64/x) == neg_infinity; } /** @@ -106,22 +106,22 @@ pure fn is_nonpositive(x: f64) -> bool { * This is the same as `f64::positive`. */ pure fn is_nonnegative(x: f64) -> bool { - ret x > 0.0f64 || (1.0f64/x) == infinity; + return x > 0.0f64 || (1.0f64/x) == infinity; } /// Returns true if `x` is a zero number (positive or negative zero) pure fn is_zero(x: f64) -> bool { - ret x == 0.0f64 || x == -0.0f64; + return x == 0.0f64 || x == -0.0f64; } /// Returns true if `x`is an infinite number pure fn is_infinite(x: f64) -> bool { - ret x == infinity || x == neg_infinity; + return x == infinity || x == neg_infinity; } /// Returns true if `x`is a finite number pure fn is_finite(x: f64) -> bool { - ret !(is_NaN(x) || is_infinite(x)); + return !(is_NaN(x) || is_infinite(x)); } // FIXME (#1999): add is_normal, is_subnormal, and fpclassify @@ -172,38 +172,38 @@ mod consts { } pure fn signbit(x: f64) -> int { - if is_negative(x) { ret 1; } else { ret 0; } + if is_negative(x) { return 1; } else { return 0; } } #[cfg(target_os="linux")] #[cfg(target_os="macos")] #[cfg(target_os="win32")] pure fn logarithm(n: f64, b: f64) -> f64 { - ret log2(n) / log2(b); + return log2(n) / log2(b); } #[cfg(target_os="freebsd")] pure fn logarithm(n: f64, b: f64) -> f64 { // FIXME (#2000): check if it is good to use log2 instead of ln here; in // theory should be faster since the radix is 2 - ret ln(n) / ln(b); + return ln(n) / ln(b); } #[cfg(target_os="freebsd")] pure fn log2(n: f64) -> f64 { - ret ln(n) / consts::ln_2; + return ln(n) / consts::ln_2; } impl num of num::num for f64 { - pure fn add(&&other: f64) -> f64 { ret self + other; } - pure fn sub(&&other: f64) -> f64 { ret self - other; } - pure fn mul(&&other: f64) -> f64 { ret self * other; } - pure fn div(&&other: f64) -> f64 { ret self / other; } - pure fn modulo(&&other: f64) -> f64 { ret self % other; } - pure fn neg() -> f64 { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> f64 { ret n as f64; } + pure fn add(&&other: f64) -> f64 { return self + other; } + pure fn sub(&&other: f64) -> f64 { return self - other; } + pure fn mul(&&other: f64) -> f64 { return self * other; } + pure fn div(&&other: f64) -> f64 { return self / other; } + pure fn modulo(&&other: f64) -> f64 { return self % other; } + pure fn neg() -> f64 { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> f64 { return n as f64; } } // diff --git a/src/libcore/float.rs b/src/libcore/float.rs index d2efba51131..e9dd26d23ce 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -103,9 +103,9 @@ mod consts { * * exact - Whether to enforce the exact number of significant digits */ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { - if is_NaN(num) { ret ~"NaN"; } - if num == infinity { ret ~"inf"; } - if num == neg_infinity { ret ~"-inf"; } + if is_NaN(num) { return ~"NaN"; } + if num == infinity { return ~"inf"; } + if num == neg_infinity { return ~"-inf"; } let mut (num, sign) = if num < 0.0 { (-num, ~"-") } else { (num, ~"") }; @@ -122,7 +122,7 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { // This used to return right away without rounding, as "~[-]num", // but given epsilon like in f64.rs, I don't see how the comparison // to epsilon did much when only used there. - // if (frac < epsilon && !exact) || digits == 0u { ret accum; } + // if (frac < epsilon && !exact) || digits == 0u { return accum; } // // With something better, possibly weird results like this can be avoided: // assert "3.14158999999999988262" == my_to_str_exact(3.14159, 20u); @@ -176,7 +176,7 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { acc = sign + ones + ~"." + racc; } - ret acc; + return acc; } /** @@ -240,25 +240,25 @@ fn to_str(num: float, digits: uint) -> ~str { */ fn from_str(num: ~str) -> option<float> { if num == ~"inf" { - ret some(infinity as float); + return some(infinity as float); } else if num == ~"-inf" { - ret some(neg_infinity as float); + return some(neg_infinity as float); } else if num == ~"NaN" { - ret some(NaN as float); + return some(NaN as float); } let mut pos = 0u; //Current byte position in the string. //Used to walk the string in O(n). let len = str::len(num); //Length of the string, in bytes. - if len == 0u { ret none; } + if len == 0u { return none; } let mut total = 0f; //Accumulated result let mut c = 'z'; //Latest char. //The string must start with one of the following characters. alt str::char_at(num, 0u) { '-' | '+' | '0' to '9' | '.' {} - _ { ret none; } + _ { return none; } } //Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly. @@ -288,7 +288,7 @@ fn from_str(num: ~str) -> option<float> { break; } _ { - ret none; + return none; } } } @@ -308,7 +308,7 @@ fn from_str(num: ~str) -> option<float> { break; } _ { - ret none; + return none; } } } @@ -353,17 +353,17 @@ fn from_str(num: ~str) -> option<float> { total = total * multiplier; } } else { - ret none; + return none; } } if(pos < len) { - ret none; + return none; } else { if(neg) { total *= -1f; } - ret some(total); + return some(total); } } @@ -386,9 +386,9 @@ fn from_str(num: ~str) -> option<float> { fn pow_with_uint(base: uint, pow: uint) -> float { if base == 0u { if pow == 0u { - ret NaN as float; + return NaN as float; } - ret 0.; + return 0.; } let mut my_pow = pow; let mut total = 1f; @@ -400,7 +400,7 @@ fn pow_with_uint(base: uint, pow: uint) -> float { my_pow /= 2u; multiplier *= multiplier; } - ret total; + return total; } pure fn is_positive(x: float) -> bool { f64::is_positive(x as f64) } @@ -420,15 +420,15 @@ pure fn cos(x: float) -> float { f64::cos(x as f64) as float } pure fn tan(x: float) -> float { f64::tan(x as f64) as float } impl num of num::num for float { - pure fn add(&&other: float) -> float { ret self + other; } - pure fn sub(&&other: float) -> float { ret self - other; } - pure fn mul(&&other: float) -> float { ret self * other; } - pure fn div(&&other: float) -> float { ret self / other; } - pure fn modulo(&&other: float) -> float { ret self % other; } - pure fn neg() -> float { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> float { ret n as float; } + pure fn add(&&other: float) -> float { return self + other; } + pure fn sub(&&other: float) -> float { return self - other; } + pure fn mul(&&other: float) -> float { return self * other; } + pure fn div(&&other: float) -> float { return self / other; } + pure fn modulo(&&other: float) -> float { return self % other; } + pure fn neg() -> float { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> float { return n as float; } } #[test] diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 8f8f7dd40ed..1b2a933c67f 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -10,7 +10,7 @@ */ pure fn hash_bytes(buf: &[const u8]) -> u64 { - ret hash_bytes_keyed(buf, 0u64, 0u64); + return hash_bytes_keyed(buf, 0u64, 0u64); } pure fn hash_u64(val: u64) -> u64 { @@ -113,7 +113,7 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 { compress!{v0,v1,v2,v3}; compress!{v0,v1,v2,v3}; - ret v0 ^ v1 ^ v2 ^ v3; + return v0 ^ v1 ^ v2 ^ v3; } @@ -156,7 +156,7 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { } st.ntail += length; - ret; + return; } let mut t = 0; @@ -229,7 +229,7 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { let h = v0 ^ v1 ^ v2 ^ v3; - ret ~[ + return ~[ (h >> 0) as u8, (h >> 8) as u8, (h >> 16) as u8, @@ -252,12 +252,12 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { } fn input(msg: ~[u8]) { add_input(self, msg); } fn input_str(msg: ~str) { add_input(self, str::bytes(msg)); } - fn result() -> ~[u8] { ret mk_result(self); } + fn result() -> ~[u8] { return mk_result(self); } fn result_str() -> ~str { let r = mk_result(self); let mut s = ~""; for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); } - ret s; + return s; } } @@ -275,7 +275,7 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { let sh = st as streaming; sh.reset(); - ret sh; + return sh; } #[test] @@ -357,7 +357,7 @@ fn test_siphash() { fn to_hex_str(r:[u8]/8) -> ~str { let mut s = ~""; for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); } - ret s; + return s; } while t < 64 { diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index b58e00d2e9c..46413517a5b 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -67,7 +67,7 @@ pure fn abs(i: T) -> T { * * radix - The base of the number */ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { - if vec::len(buf) == 0u { ret none; } + if vec::len(buf) == 0u { return none; } let mut i = vec::len(buf) - 1u; let mut start = 0u; let mut power = 1 as T; @@ -80,10 +80,10 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { loop { alt char::to_digit(buf[i] as char, radix) { some(d) { n += (d as T) * power; } - none { ret none; } + none { return none; } } power *= radix as T; - if i <= start { ret some(n); } + if i <= start { return some(n); } i -= 1u; }; } @@ -109,30 +109,30 @@ fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { } /// Convert to a string -fn str(i: T) -> ~str { ret to_str(i, 10u); } +fn str(i: T) -> ~str { return to_str(i, 10u); } impl ord of ord for T { pure fn lt(&&other: T) -> bool { - ret self < other; + return self < other; } } impl eq of eq for T { pure fn eq(&&other: T) -> bool { - ret self == other; + return self == other; } } impl num of num::num for T { - pure fn add(&&other: T) -> T { ret self + other; } - pure fn sub(&&other: T) -> T { ret self - other; } - pure fn mul(&&other: T) -> T { ret self * other; } - pure fn div(&&other: T) -> T { ret self / other; } - pure fn modulo(&&other: T) -> T { ret self % other; } - pure fn neg() -> T { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> T { ret n as T; } + pure fn add(&&other: T) -> T { return self + other; } + pure fn sub(&&other: T) -> T { return self - other; } + pure fn mul(&&other: T) -> T { return self * other; } + pure fn div(&&other: T) -> T { return self / other; } + pure fn modulo(&&other: T) -> T { return self % other; } + pure fn neg() -> T { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> T { return n as T; } } impl times of iter::times for T { diff --git a/src/libcore/int-template/int.rs b/src/libcore/int-template/int.rs index 07acb4be8ce..500316de2f7 100644 --- a/src/libcore/int-template/int.rs +++ b/src/libcore/int-template/int.rs @@ -7,12 +7,12 @@ const bits: T = 32 as T; const bits: T = 64 as T; /// Produce a uint suitable for use in a hash table -pure fn hash(&&x: int) -> uint { ret x as uint; } +pure fn hash(&&x: int) -> uint { return x as uint; } /// Returns `base` raised to the power of `exponent` fn pow(base: int, exponent: uint) -> int { - if exponent == 0u { ret 1; } //Not mathemtically true if ~[base == 0] - if base == 0 { ret 0; } + if exponent == 0u { return 1; } //Not mathemtically true if ~[base == 0] + if base == 0 { return 0; } let mut my_pow = exponent; let mut acc = 1; let mut multiplier = base; @@ -23,7 +23,7 @@ fn pow(base: int, exponent: uint) -> int { my_pow /= 2u; multiplier *= multiplier; } - ret acc; + return acc; } #[test] diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 510be3f89b9..1831938496a 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -69,7 +69,7 @@ impl reader_util for reader { } // can't satisfy this char with the existing data if end > vec::len(buf) { - ret (i - 1u, end - vec::len(buf)); + return (i - 1u, end - vec::len(buf)); } let mut val = 0u; while i < end { @@ -85,7 +85,7 @@ impl reader_util for reader { << (w - 1u) * 6u - w - 1u; vec::push(chars, val as char ); } - ret (i, 0u); + return (i, 0u); } let mut buf: ~[u8] = ~[]; let mut chars: ~[char] = ~[]; @@ -115,10 +115,10 @@ impl reader_util for reader { fn read_char() -> char { let c = self.read_chars(1u); if vec::len(c) == 0u { - ret -1 as char; // FIXME will this stay valid? // #2004 + return -1 as char; // FIXME will this stay valid? // #2004 } assert(vec::len(c) == 1u); - ret c[0]; + return c[0]; } fn read_line() -> ~str { @@ -196,7 +196,7 @@ impl reader_util for reader { // Reader implementations fn convert_whence(whence: seek_style) -> i32 { - ret alt whence { + return alt whence { seek_set { 0i32 } seek_cur { 1i32 } seek_end { 2i32 } @@ -214,14 +214,14 @@ impl of reader for *libc::FILE { count as uint } } - fn read_byte() -> int { ret libc::fgetc(self) as int; } + fn read_byte() -> int { return libc::fgetc(self) as int; } fn unread_byte(byte: int) { libc::ungetc(byte as c_int, self); } - fn eof() -> bool { ret libc::feof(self) != 0 as c_int; } + fn eof() -> bool { return libc::feof(self) != 0 as c_int; } fn seek(offset: int, whence: seek_style) { assert libc::fseek(self, offset as c_long, convert_whence(whence)) == 0 as c_int; } - fn tell() -> uint { ret libc::ftell(self) as uint; } + fn tell() -> uint { return libc::ftell(self) as uint; } } // A forwarding impl of reader that also holds on to a resource for the @@ -262,7 +262,7 @@ fn file_reader(path: ~str) -> result<reader, ~str> { libc::fopen(pathbuf, modebuf) ) }); - ret if f as uint == 0u { result::err(~"error opening " + path) } + return if f as uint == 0u { result::err(~"error opening " + path) } else { result::ok(FILE_reader(f, true)) } @@ -285,10 +285,10 @@ impl of reader for byte_buf { count } fn read_byte() -> int { - if self.pos == self.len { ret -1; } + if self.pos == self.len { return -1; } let b = self.buf[self.pos]; self.pos += 1u; - ret b as int; + return b as int; } // FIXME (#2738): implement this fn unread_byte(_byte: int) { error!{"Unimplemented: unread_byte"}; fail; } @@ -530,7 +530,7 @@ fn u64_from_be_bytes(data: ~[u8], start: uint, size: uint) -> u64 { val += (data[pos] as u64) << ((sz * 8u) as u64); pos += 1u; } - ret val; + return val; } impl writer_util for writer { @@ -616,7 +616,7 @@ fn buffered_file_writer(path: ~str) -> result<writer, ~str> { libc::fopen(pathbuf, modebuf) } }; - ret if f as uint == 0u { result::err(~"error opening " + path) } + return if f as uint == 0u { result::err(~"error opening " + path) } else { result::ok(FILE_writer(f, true)) } } @@ -639,7 +639,7 @@ impl of writer for mem_buffer { if self.pos == buf_len { self.buf.push_all(v); self.pos += vlen; - ret; + return; } // FIXME #2004--use memcpy here? @@ -696,7 +696,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> seek_end { bpos = blen + offset; } } if bpos < 0 { bpos = 0; } else if bpos > blen { bpos = blen; } - ret bpos as uint; + return bpos as uint; } fn read_whole_file_str(file: ~str) -> result<~str, ~str> { @@ -764,7 +764,7 @@ mod fsync { blk(res({ val: file.f, opt_level: opt_level, fsync_fn: fn@(&&file: *libc::FILE, l: level) -> int { - ret os::fsync_fd(libc::fileno(file), l) as int; + return os::fsync_fd(libc::fileno(file), l) as int; } })); } @@ -775,7 +775,7 @@ mod fsync { blk(res({ val: fd.fd, opt_level: opt_level, fsync_fn: fn@(&&fd: fd_t, l: level) -> int { - ret os::fsync_fd(fd, l) as int; + return os::fsync_fd(fd, l) as int; } })); } @@ -787,7 +787,7 @@ mod fsync { fn obj_sync(&&o: t, opt_level: option<level>, blk: fn(&&res<t>)) { blk(res({ val: o, opt_level: opt_level, - fsync_fn: fn@(&&o: t, l: level) -> int { ret o.fsync(l); } + fsync_fn: fn@(&&o: t, l: level) -> int { return o.fsync(l); } })); } } diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index e31824d066d..a7ba67ec1bd 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -41,8 +41,8 @@ impl extensions<A:copy> of iter::copyable_iter<A> for IMPL_T<A> { fn find(p: fn(A) -> bool) -> option<A> { for self.each |i| { - if p(i) { ret some(i) } + if p(i) { return some(i) } } - ret none; + return none; } } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 092f69cd47a..0e635eeb002 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -39,16 +39,16 @@ fn eachi<A,IA:base_iter<A>>(self: IA, blk: fn(uint, A) -> bool) { fn all<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool { for self.each |a| { - if !blk(a) { ret false; } + if !blk(a) { return false; } } - ret true; + return true; } fn any<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool { for self.each |a| { - if blk(a) { ret true; } + if blk(a) { return true; } } - ret false; + return false; } fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA, @@ -58,7 +58,7 @@ fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA, for self.each |a| { if prd(a) { vec::push(result, a); } } - ret result; + return result; } fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] { @@ -67,7 +67,7 @@ fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] { for self.each |a| { vec::push(result, op(a)); } - ret result; + return result; } fn flat_map_to_vec<A:copy,B:copy,IA:base_iter<A>,IB:base_iter<B>>( @@ -79,7 +79,7 @@ fn flat_map_to_vec<A:copy,B:copy,IA:base_iter<A>,IB:base_iter<B>>( vec::push(result, b); } } - ret result; + return result; } fn foldl<A,B,IA:base_iter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { @@ -87,7 +87,7 @@ fn foldl<A,B,IA:base_iter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { for self.each |a| { b = blk(b, a); } - ret b; + return b; } fn to_vec<A:copy,IA:base_iter<A>>(self: IA) -> ~[A] { @@ -96,9 +96,9 @@ fn to_vec<A:copy,IA:base_iter<A>>(self: IA) -> ~[A] { fn contains<A,IA:base_iter<A>>(self: IA, x: A) -> bool { for self.each |a| { - if a == x { ret true; } + if a == x { return true; } } - ret false; + return false; } fn count<A,IA:base_iter<A>>(self: IA, x: A) -> uint { @@ -115,10 +115,10 @@ fn position<A,IA:base_iter<A>>(self: IA, f: fn(A) -> bool) -> option<uint> { let mut i = 0; for self.each |a| { - if f(a) { ret some(i); } + if f(a) { return some(i); } i += 1; } - ret none; + return none; } // note: 'rposition' would only make sense to provide with a bidirectional @@ -191,7 +191,7 @@ fn test_map_directly_on_vec() { #[test] fn test_filter_on_int_range() { fn is_even(&&i: int) -> bool { - ret (i % 2) == 0; + return (i % 2) == 0; } let l = to_vec(bind filter(bind int::range(0, 10, _), is_even, _)); @@ -201,7 +201,7 @@ fn test_filter_on_int_range() { #[test] fn test_filter_on_uint_range() { fn is_even(&&i: uint) -> bool { - ret (i % 2u) == 0u; + return (i % 2u) == 0u; } let l = to_vec(bind filter(bind uint::range(0u, 10u, _), is_even, _)); diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 074dd086926..84fa8ec3544 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 { some(x) { ret x; } none { fail ~"option none"; } } + alt opt { some(x) { return x; } none { fail ~"option none"; } } } pure fn expect<T: copy>(opt: option<T>, reason: ~str) -> T { @@ -116,7 +116,7 @@ pure fn unwrap<T>(-opt: option<T>) -> T { }; let liberated_value = unsafe::reinterpret_cast(*addr); unsafe::forget(opt); - ret liberated_value; + return liberated_value; } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 4edf5af5f80..f758c1b62cb 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -100,7 +100,7 @@ mod win32 { } } } - ret res; + return res; } fn as_utf16_p<T>(s: ~str, f: fn(*u16) -> T) -> T { @@ -209,14 +209,14 @@ mod global_env { assert vec::len(vs) == 2u; vec::push(pairs, (vs[0], vs[1])); } - ret pairs; + return pairs; } #[cfg(unix)] fn getenv(n: ~str) -> option<~str> { unsafe { let s = str::as_c_str(n, libc::getenv); - ret if unsafe::reinterpret_cast(s) == 0 { + return if unsafe::reinterpret_cast(s) == 0 { option::none::<~str> } else { let s = unsafe::reinterpret_cast(s); @@ -267,7 +267,7 @@ mod global_env { } fn fdopen(fd: c_int) -> *FILE { - ret do as_c_charp(~"r") |modebuf| { + return do as_c_charp(~"r") |modebuf| { libc::fdopen(fd, modebuf) }; } @@ -278,7 +278,7 @@ fn fdopen(fd: c_int) -> *FILE { #[cfg(windows)] fn fsync_fd(fd: c_int, _level: io::fsync::level) -> c_int { import libc::funcs::extra::msvcrt::*; - ret commit(fd); + return commit(fd); } #[cfg(target_os = "linux")] @@ -286,8 +286,8 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::funcs::posix01::unistd::*; alt level { io::fsync::fsync - | io::fsync::fullfsync { ret fsync(fd); } - io::fsync::fdatasync { ret fdatasync(fd); } + | io::fsync::fullfsync { return fsync(fd); } + io::fsync::fdatasync { return fdatasync(fd); } } } @@ -297,13 +297,13 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::funcs::posix88::fcntl::*; import libc::funcs::posix01::unistd::*; alt level { - io::fsync::fsync { ret fsync(fd); } + io::fsync::fsync { return fsync(fd); } _ { // According to man fnctl, the ok retval is only specified to be !=-1 if (fcntl(F_FULLFSYNC as c_int, fd) == -1 as c_int) - { ret -1 as c_int; } + { return -1 as c_int; } else - { ret 0 as c_int; } + { return 0 as c_int; } } } } @@ -311,13 +311,13 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { #[cfg(target_os = "freebsd")] fn fsync_fd(fd: c_int, _l: io::fsync::level) -> c_int { import libc::funcs::posix01::unistd::*; - ret fsync(fd); + return fsync(fd); } #[cfg(windows)] fn waitpid(pid: pid_t) -> c_int { - ret rustrt::rust_process_wait(pid); + return rustrt::rust_process_wait(pid); } #[cfg(unix)] @@ -327,7 +327,7 @@ fn waitpid(pid: pid_t) -> c_int { assert (waitpid(pid, ptr::mut_addr_of(status), 0 as c_int) != (-1 as c_int)); - ret status; + return status; } @@ -336,7 +336,7 @@ fn pipe() -> {in: c_int, out: c_int} { let fds = {mut in: 0 as c_int, mut out: 0 as c_int }; assert (libc::pipe(ptr::mut_addr_of(fds.in)) == (0 as c_int)); - ret {in: fds.in, out: fds.out}; + return {in: fds.in, out: fds.out}; } @@ -358,12 +358,12 @@ fn pipe() -> {in: c_int, out: c_int} { assert (res == 0 as c_int); assert (fds.in != -1 as c_int && fds.in != 0 as c_int); assert (fds.out != -1 as c_int && fds.in != 0 as c_int); - ret {in: fds.in, out: fds.out}; + return {in: fds.in, out: fds.out}; } fn dll_filename(base: ~str) -> ~str { - ret pre() + base + dll_suffix(); + return pre() + base + dll_suffix(); #[cfg(unix)] fn pre() -> ~str { ~"lib" } @@ -442,7 +442,7 @@ fn self_exe_path() -> option<path> { * Otherwise, homedir returns option::none. */ fn homedir() -> option<path> { - ret alt getenv(~"HOME") { + return alt getenv(~"HOME") { some(p) { if !str::is_empty(p) { some(p) @@ -497,7 +497,7 @@ fn walk_dir(p: path, f: fn(path) -> bool) { } } } - ret keepgoing; + return keepgoing; } } @@ -538,7 +538,7 @@ fn make_absolute(p: path) -> path { /// Creates a directory at the specified path fn make_dir(p: path, mode: c_int) -> bool { - ret mkdir(p, mode); + return mkdir(p, mode); #[cfg(windows)] fn mkdir(p: path, _mode: c_int) -> bool { @@ -600,7 +600,7 @@ fn list_dir_path(p: path) -> ~[~str] { /// Removes a directory at the specified path fn remove_dir(p: path) -> bool { - ret rmdir(p); + return rmdir(p); #[cfg(windows)] fn rmdir(p: path) -> bool { @@ -608,21 +608,21 @@ fn remove_dir(p: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(p) |buf| { + return do as_utf16_p(p) |buf| { RemoveDirectoryW(buf) != (0 as BOOL) }; } #[cfg(unix)] fn rmdir(p: path) -> bool { - ret do as_c_charp(p) |buf| { + return do as_c_charp(p) |buf| { libc::rmdir(buf) == (0 as c_int) }; } } fn change_dir(p: path) -> bool { - ret chdir(p); + return chdir(p); #[cfg(windows)] fn chdir(p: path) -> bool { @@ -630,14 +630,14 @@ fn change_dir(p: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(p) |buf| { + return do as_utf16_p(p) |buf| { SetCurrentDirectoryW(buf) != (0 as BOOL) }; } #[cfg(unix)] fn chdir(p: path) -> bool { - ret do as_c_charp(p) |buf| { + return do as_c_charp(p) |buf| { libc::chdir(buf) == (0 as c_int) }; } @@ -645,7 +645,7 @@ fn change_dir(p: path) -> bool { /// Copies a file from one location to another fn copy_file(from: path, to: path) -> bool { - ret do_copy_file(from, to); + return do_copy_file(from, to); #[cfg(windows)] fn do_copy_file(from: path, to: path) -> bool { @@ -653,7 +653,7 @@ fn copy_file(from: path, to: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(from) |fromp| { + return do as_utf16_p(from) |fromp| { do as_utf16_p(to) |top| { CopyFileW(fromp, top, (0 as BOOL)) != (0 as BOOL) } @@ -668,7 +668,7 @@ fn copy_file(from: path, to: path) -> bool { } }; if istream as uint == 0u { - ret false; + return false; } let ostream = do as_c_charp(to) |top| { do as_c_charp(~"w+b") |modebuf| { @@ -677,7 +677,7 @@ fn copy_file(from: path, to: path) -> bool { }; if ostream as uint == 0u { fclose(istream); - ret false; + return false; } let mut buf : ~[mut u8] = ~[mut]; let bufsize = 8192u; @@ -702,13 +702,13 @@ fn copy_file(from: path, to: path) -> bool { } fclose(istream); fclose(ostream); - ret ok; + return ok; } } /// Deletes an existing file fn remove_file(p: path) -> bool { - ret unlink(p); + return unlink(p); #[cfg(windows)] fn unlink(p: path) -> bool { @@ -717,14 +717,14 @@ fn remove_file(p: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(p) |buf| { + return do as_utf16_p(p) |buf| { DeleteFileW(buf) != (0 as BOOL) }; } #[cfg(unix)] fn unlink(p: path) -> bool { - ret do as_c_charp(p) |buf| { + return do as_c_charp(p) |buf| { libc::unlink(buf) == (0 as c_int) }; } diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 8331284bf10..beccdcf0538 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -51,14 +51,14 @@ fn path_is_absolute(p: path) -> bool { #[cfg(windows)] fn path_is_absolute(p: ~str) -> bool { - ret str::char_at(p, 0u) == '/' || + return str::char_at(p, 0u) == '/' || str::char_at(p, 1u) == ':' && (str::char_at(p, 2u) == consts::path_sep || str::char_at(p, 2u) == consts::alt_path_sep); } /// Get the default path separator for the host platform -fn path_sep() -> ~str { ret str::from_char(consts::path_sep); } +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| @@ -82,7 +82,7 @@ fn split_dirname_basename (pp: path) -> {dirname: ~str, basename: ~str} { * If the path is not prefixed with a directory, then "." is returned. */ fn dirname(pp: path) -> path { - ret split_dirname_basename(pp).dirname; + return split_dirname_basename(pp).dirname; } /** @@ -95,7 +95,7 @@ fn dirname(pp: path) -> path { * with a path separator then an empty path is returned. */ fn basename(pp: path) -> path { - ret split_dirname_basename(pp).basename; + return split_dirname_basename(pp).basename; } /** @@ -119,7 +119,7 @@ fn connect(pre: path, post: path) -> path { str::unsafe::shift_byte(post_); } } - ret pre_ + path_sep() + post_; + return pre_ + path_sep() + post_; } /** @@ -128,7 +128,7 @@ fn connect(pre: path, post: path) -> path { * Inserts path separators as needed. */ fn connect_many(paths: ~[path]) -> path { - ret if vec::len(paths) == 1u { + return if vec::len(paths) == 1u { paths[0] } else { let rest = vec::slice(paths, 1u, vec::len(paths)); @@ -231,7 +231,7 @@ fn normalize(p: path) -> path { s }; - ret s; + return s; fn strip_dots(s: ~[path]) -> ~[path] { vec::filter_map(s, |elem| @@ -244,7 +244,7 @@ fn normalize(p: path) -> path { fn rollup_doubledots(s: ~[path]) -> ~[path] { if vec::is_empty(s) { - ret ~[]; + return ~[]; } let mut t = ~[]; @@ -267,7 +267,7 @@ fn normalize(p: path) -> path { vec::push(t, ~".."); skip -= 1; } - ret t; + return t; } #[cfg(unix)] @@ -292,9 +292,9 @@ fn normalize(p: path) -> path { let last = orig[str::len(orig) - 1u]; if last == consts::path_sep as u8 || last == consts::path_sep as u8 { - ret newp + path_sep(); + return newp + path_sep(); } else { - ret newp; + return newp; } } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 429651616a7..bc8785b45ac 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -390,11 +390,11 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) let mut payload = none; payload <-> p.payload; p.header.state = empty; - ret some(option::unwrap(payload)) + return some(option::unwrap(payload)) } terminated { assert old_state == terminated; - ret none; + return none; } } first = false; @@ -906,7 +906,7 @@ struct port_set<T: send> : recv<T> { // It'd be nice to use self.port.each, but that version isn't // pure. for vec::each(self.ports) |p| { - if p.peek() { ret true } + if p.peek() { return true } } false } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index cc60d18af21..d82c46832fe 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -79,7 +79,7 @@ unsafe fn buf_len<T>(buf: **T) -> uint { unsafe fn position<T>(buf: *T, f: fn(T) -> bool) -> uint { let mut i = 0u; loop { - if f(*offset(buf, i)) { ret i; } + if f(*offset(buf, i)) { return i; } else { i += 1u; } } } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index cda205a98b5..82a88e6718f 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -110,7 +110,7 @@ impl extensions for rng { let u2 = self.next() as f64; let u3 = self.next() as f64; const scale : f64 = (u32::max_value as f64) + 1.0f64; - ret ((u1 / scale + u2) / scale + u3) / scale; + return ((u1 / scale + u2) / scale + u3) / scale; } /// Return a random char @@ -195,14 +195,14 @@ impl extensions for rng { total += item.weight; } if total == 0u { - ret none; + return none; } let chosen = self.gen_uint_range(0u, total); let mut so_far = 0u; for v.each |item| { so_far += item.weight; if so_far > chosen { - ret some(item.item); + return some(item.item); } } unreachable(); @@ -226,7 +226,7 @@ impl extensions for rng { fn shuffle<T:copy>(values: ~[T]) -> ~[T] { let mut m = vec::to_mut(values); self.shuffle_mut(m); - ret vec::from_mut(m); + return vec::from_mut(m); } /// Shuffle a mutable vec in place @@ -249,7 +249,7 @@ class rand_res { } impl of rng for @rand_res { - fn next() -> u32 { ret rustrt::rand_next((*self).c); } + fn next() -> u32 { return rustrt::rand_next((*self).c); } } /// Create a new random seed for seeded_rng diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 2e9fd977536..58a4c558050 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -244,8 +244,8 @@ impl extensions<T:copy, E:copy> for result<T,E> { * checking for overflow: * * fn inc_conditionally(x: uint) -> result<uint,str> { - * if x == uint::max_value { ret err("overflow"); } - * else { ret ok(x+1u); } + * if x == uint::max_value { return err("overflow"); } + * else { return ok(x+1u); } * } * map(~[1u, 2u, 3u], inc_conditionally).chain {|incd| * assert incd == ~[2u, 3u, 4u]; @@ -259,10 +259,10 @@ fn map_vec<T,U:copy,V:copy>( for vec::each(ts) |t| { alt op(t) { ok(v) { vec::push(vs, v); } - err(u) { ret err(u); } + err(u) { return err(u); } } } - ret ok(vs); + return ok(vs); } fn map_opt<T,U:copy,V:copy>( @@ -299,11 +299,11 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T], while i < n { alt op(ss[i],ts[i]) { ok(v) { vec::push(vs, v); } - err(u) { ret err(u); } + err(u) { return err(u); } } i += 1u; } - ret ok(vs); + return ok(vs); } /** @@ -320,11 +320,11 @@ fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T], while i < n { alt op(ss[i],ts[i]) { ok(()) { } - err(u) { ret err(u); } + err(u) { return err(u); } } i += 1u; } - ret ok(()); + return ok(()); } /// Unwraps a result, assuming it is an `ok(T)` @@ -336,7 +336,7 @@ fn unwrap<T, U>(-res: result<T, U>) -> T { }; let liberated_value = unsafe::reinterpret_cast(*addr); unsafe::forget(res); - ret liberated_value; + return liberated_value; } } diff --git a/src/libcore/rt.rs b/src/libcore/rt.rs index 8990891112d..0b4038656ef 100644 --- a/src/libcore/rt.rs +++ b/src/libcore/rt.rs @@ -34,7 +34,7 @@ fn rt_fail(expr: *c_char, file: *c_char, line: size_t) { #[rt(exchange_malloc)] fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { - ret rustrt::rust_upcall_exchange_malloc(td, size); + return rustrt::rust_upcall_exchange_malloc(td, size); } // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from @@ -47,7 +47,7 @@ fn rt_exchange_free(ptr: *c_char) { #[rt(malloc)] fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char { - ret rustrt::rust_upcall_malloc(td, size); + return rustrt::rust_upcall_malloc(td, size); } // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 09dbf2c37c3..bb604d7748a 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -169,7 +169,7 @@ fn run_program(prog: ~str, args: ~[~str]) -> int { let pid = spawn_process(prog, args, none, none, 0i32, 0i32, 0i32); if pid == -1 as pid_t { fail; } - ret waitpid(pid); + return waitpid(pid); } /** @@ -216,10 +216,10 @@ fn start_program(prog: ~str, args: ~[~str]) -> program { } } fn finish_repr(r: prog_repr) -> int { - if r.finished { ret 0; } + if r.finished { return 0; } r.finished = true; close_repr_input(r); - ret waitpid(r.pid); + return waitpid(r.pid); } fn destroy_repr(r: prog_repr) { finish_repr(r); @@ -233,7 +233,7 @@ fn start_program(prog: ~str, args: ~[~str]) -> program { } impl of program for prog_res { - fn get_id() -> pid_t { ret self.r.pid; } + fn get_id() -> pid_t { return self.r.pid; } fn input() -> io::writer { io::fd_writer(self.r.in_fd, false) } fn output() -> io::reader { io::FILE_reader(self.r.out_file, false) } fn err() -> io::reader { io::FILE_reader(self.r.err_file, false) } @@ -246,7 +246,7 @@ fn start_program(prog: ~str, args: ~[~str]) -> program { out_file: os::fdopen(pipe_output.in), err_file: os::fdopen(pipe_err.in), mut finished: false}; - ret prog_res(repr) as program; + return prog_res(repr) as program; } fn read_all(rd: io::reader) -> ~str { @@ -255,7 +255,7 @@ fn read_all(rd: io::reader) -> ~str { let bytes = rd.read_bytes(4096u); buf += str::from_bytes(bytes); } - ret buf; + return buf; } /** @@ -323,7 +323,7 @@ fn program_output(prog: ~str, args: ~[~str]) -> }; count -= 1; }; - ret {status: status, out: outs, err: errs}; + return {status: status, out: outs, err: errs}; } fn writeclose(fd: c_int, s: ~str) { @@ -345,12 +345,12 @@ fn readclose(fd: c_int) -> ~str { buf += str::from_bytes(bytes); } os::fclose(file); - ret buf; + return buf; } /// Waits for a process to exit and returns the exit code fn waitpid(pid: pid_t) -> int { - ret waitpid_os(pid); + return waitpid_os(pid); #[cfg(windows)] fn waitpid_os(pid: pid_t) -> int { @@ -382,7 +382,7 @@ fn waitpid(pid: pid_t) -> int { } let status = os::waitpid(pid); - ret if WIFEXITED(status) { + return if WIFEXITED(status) { WEXITSTATUS(status) as int } else { 1 diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 40eae90e96b..df019f57397 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -80,7 +80,7 @@ mod linear { unsafe{ // argh. log not considered pure. debug!{"next_bucket(%?, %?) = %?", idx, len_buckets, n}; } - ret n; + return n; } #[inline(always)] @@ -90,11 +90,11 @@ mod linear { let mut idx = start_idx; loop { if !op(idx) { - ret idx; + return idx; } idx = self.next_bucket(idx, len_buckets); if idx == start_idx { - ret start_idx; + return start_idx; } } } @@ -118,15 +118,15 @@ mod linear { alt buckets[i] { some(bkt) { if bkt.hash == hash && self.eqfn(k, &bkt.key) { - ret found_entry(i); + return found_entry(i); } } none => { - ret found_hole(i); + return found_hole(i); } } }; - ret table_full; + return table_full; } } @@ -167,13 +167,13 @@ mod linear { k, v, idx, hash}; self.buckets[idx] = some({hash: hash, key: k, value: v}); self.size += 1; - ret true; + return true; } found_entry(idx) => { debug!{"insert overwrite (%?->%?) at idx %?, hash %?", k, v, idx, hash}; self.buckets[idx] = some({hash: hash, key: k, value: v}); - ret false; + return false; } } } @@ -213,7 +213,7 @@ mod linear { let mut idx = alt self.bucket_for_key(self.buckets, k) { table_full | found_hole(_) => { - ret false; + return false; } found_entry(idx) => { idx @@ -230,7 +230,7 @@ mod linear { idx = self.next_bucket(idx, len_buckets); } self.size -= 1; - ret true; + return true; } } @@ -339,7 +339,7 @@ mod test { pure fn uint_eq(x: &uint, y: &uint) -> bool { *x == *y } fn int_linear_map<V>() -> linear_map<uint,V> { - ret linear_map(uint_hash, uint_eq); + return linear_map(uint_hash, uint_eq); } #[test] diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 3539f411006..939cdfade82 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -51,7 +51,7 @@ fn test_simple() { #[test] fn test_simple_deep() { fn run(i: int) { - if i == 0 { ret } + if i == 0 { return } for walk_stack |_frame| { unsafe { diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 6c443dc294a..cdc3a826b67 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -128,7 +128,7 @@ Section: Creating a string */ pure fn from_bytes(vv: &[const u8]) -> ~str { assert is_utf8(vv); - ret unsafe { unsafe::from_bytes(vv) }; + return unsafe { unsafe::from_bytes(vv) }; } /// Copy a slice into a new unique str @@ -229,7 +229,7 @@ fn push_char(&s: ~str, ch: char) { pure fn from_char(ch: char) -> ~str { let mut buf = ~""; unchecked { push_char(buf, ch); } - ret buf; + return buf; } /// Convert a vector of chars to a string @@ -239,7 +239,7 @@ pure fn from_chars(chs: &[char]) -> ~str { reserve(buf, chs.len()); for vec::each(chs) |ch| { push_char(buf, ch); } } - ret buf; + return buf; } /// Appends a string slice to the back of a string, without overallocating @@ -282,7 +282,7 @@ pure fn append(+lhs: ~str, rhs: &str) -> ~str { unchecked { push_str_no_overallocate(v, rhs); } - ret v; + return v; } @@ -290,7 +290,7 @@ pure fn append(+lhs: ~str, rhs: &str) -> ~str { pure fn concat(v: &[~str]) -> ~str { let mut s: ~str = ~""; for vec::each(v) |ss| { unchecked { push_str(s, ss) }; } - ret s; + return s; } /// Concatenate a vector of strings, placing a given separator between each @@ -300,7 +300,7 @@ pure fn connect(v: &[~str], sep: &str) -> ~str { if first { first = false; } else { unchecked { push_str(s, sep); } } unchecked { push_str(s, ss) }; } - ret s; + return s; } /* @@ -319,7 +319,7 @@ fn pop_char(&s: ~str) -> char { assert end > 0u; let {ch, prev} = char_range_at_reverse(s, end); unsafe { unsafe::set_len(s, prev); } - ret ch; + return ch; } /** @@ -332,7 +332,7 @@ fn pop_char(&s: ~str) -> char { fn shift_char(&s: ~str) -> char { let {ch, next} = char_range_at(s, 0u); s = unsafe { unsafe::slice_bytes(s, next, len(s)) }; - ret ch; + return ch; } /// Prepend a char to a string @@ -376,7 +376,7 @@ pure fn bytes(s: &str) -> ~[u8] { let mut s_copy = from_slice(s); let mut v: ~[u8] = ::unsafe::transmute(s_copy); vec::unsafe::set_len(v, len(s)); - ret v; + return v; } } @@ -397,7 +397,7 @@ pure fn chars(s: &str) -> ~[char] { unchecked { vec::push(buf, ch); } i = next; } - ret buf; + return buf; } /** @@ -643,16 +643,16 @@ pure fn eq(&&a: ~str, &&b: ~str) -> bool { // shape code. let a_len = a.len(); let b_len = b.len(); - if a_len != b_len { ret false; } + if a_len != b_len { return false; } let mut end = uint::min(a_len, b_len); let mut i = 0u; while i < end { - if a[i] != b[i] { ret false; } + if a[i] != b[i] { return false; } i += 1u; } - ret true; + return true; } /// Bytewise less than or equal @@ -663,7 +663,7 @@ pure fn hash(&&s: ~str) -> uint { let x = do as_bytes(s) |bytes| { hash::hash_bytes(bytes) }; - ret x as uint; + return x as uint; } /* @@ -855,10 +855,10 @@ pure fn find_char_between(s: &str, c: char, start: uint, end: uint) let mut i = start; let b = c as u8; while i < end { - if s[i] == b { ret some(i); } + if s[i] == b { return some(i); } i += 1u; } - ret none; + return none; } else { find_between(s, start, end, |x| x == c) } @@ -935,9 +935,9 @@ pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) let b = c as u8; while i > end { i -= 1u; - if s[i] == b { ret some(i); } + if s[i] == b { return some(i); } } - ret none; + return none; } else { rfind_between(s, start, end, |x| x == c) } @@ -1016,10 +1016,10 @@ pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) let mut i = start; while i < end { let {ch, next} = char_range_at(s, i); - if f(ch) { ret some(i); } + if f(ch) { return some(i); } i = next; } - ret none; + return none; } /** @@ -1095,17 +1095,17 @@ pure fn rfind_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) let mut i = start; while i > end { let {ch, prev} = char_range_at_reverse(s, i); - if f(ch) { ret some(prev); } + if f(ch) { return some(prev); } i = prev; } - ret none; + return none; } // Utility used by various searching functions pure fn match_at(haystack: &a/str, needle: &b/str, at: uint) -> bool { let mut i = at; - for each(needle) |c| { if haystack[i] != c { ret false; } i += 1u; } - ret true; + for each(needle) |c| { if haystack[i] != c { return false; } i += 1u; } + return true; } /** @@ -1175,16 +1175,16 @@ pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint, // See Issue #1932 for why this is a naive search assert end <= len(haystack); let needle_len = len(needle); - if needle_len == 0u { ret some(start); } - if needle_len > end { ret none; } + if needle_len == 0u { return some(start); } + if needle_len > end { return none; } let mut i = start; let e = end - needle_len; while i <= e { - if match_at(haystack, needle, i) { ret some(i); } + if match_at(haystack, needle, i) { return some(i); } i += 1u; } - ret none; + return none; } /** @@ -1248,8 +1248,8 @@ Section: String properties /// Determines if a string contains only ASCII characters pure fn is_ascii(s: &str) -> bool { let mut i: uint = len(s); - while i > 0u { i -= 1u; if !u8::is_ascii(s[i]) { ret false; } } - ret true; + while i > 0u { i -= 1u; if !u8::is_ascii(s[i]) { return false; } } + return true; } /// Returns true if the string has length 0 @@ -1264,7 +1264,7 @@ pure fn is_not_empty(s: &str) -> bool { !is_empty(s) } * Whitespace characters are determined by `char::is_whitespace` */ pure fn is_whitespace(s: &str) -> bool { - ret all(s, char::is_whitespace); + return all(s, char::is_whitespace); } /** @@ -1273,7 +1273,7 @@ pure fn is_whitespace(s: &str) -> bool { * Alphanumeric characters are determined by `char::is_alphanumeric` */ fn is_alphanumeric(s: &str) -> bool { - ret all(s, char::is_alphanumeric); + return all(s, char::is_alphanumeric); } /// Returns the string length/size in bytes not counting the null terminator @@ -1294,16 +1294,16 @@ pure fn is_utf8(v: &[const u8]) -> bool { let total = vec::len::<u8>(v); while i < total { let mut chsize = utf8_char_width(v[i]); - if chsize == 0u { ret false; } - if i + chsize > total { ret false; } + if chsize == 0u { return false; } + if i + chsize > total { return false; } i += 1u; while chsize > 1u { - if v[i] & 192u8 != tag_cont_u8 { ret false; } + if v[i] & 192u8 != tag_cont_u8 { return false; } i += 1u; chsize -= 1u; } } - ret true; + return true; } /// Determines if a vector of `u16` contains valid UTF-16 @@ -1317,14 +1317,14 @@ pure fn is_utf16(v: &[u16]) -> bool { i += 1u; } else { - if i+1u < len { ret false; } + if i+1u < len { return false; } let u2 = v[i+1u]; - if u < 0xD7FF_u16 || u > 0xDBFF_u16 { ret false; } - if u2 < 0xDC00_u16 || u2 > 0xDFFF_u16 { ret false; } + if u < 0xD7FF_u16 || u > 0xDBFF_u16 { return false; } + if u2 < 0xDC00_u16 || u2 > 0xDFFF_u16 { return false; } i += 2u; } } - ret true; + return true; } /// Converts to a vector of `u16` encoded as UTF-16 @@ -1347,7 +1347,7 @@ pure fn to_utf16(s: &str) -> ~[u16] { vec::push_all(u, ~[w1, w2]) } } - ret u; + return u; } pure fn utf16_chars(v: &[u16], f: fn(char)) { @@ -1381,7 +1381,7 @@ pure fn from_utf16(v: &[u16]) -> ~str { reserve(buf, vec::len(v)); utf16_chars(v, |ch| push_char(buf, ch)); } - ret buf; + return buf; } @@ -1407,7 +1407,7 @@ pure fn count_chars(s: &str, start: uint, end: uint) -> uint { len += 1u; i = next; } - ret len; + return len; } /// Counts the number of bytes taken by the `n` in `s` starting from `start`. @@ -1427,14 +1427,14 @@ pure fn count_bytes(s: &b/str, start: uint, n: uint) -> uint { /// Given a first byte, determine how many bytes are in this UTF-8 character pure fn utf8_char_width(b: u8) -> uint { let byte: uint = b as uint; - if byte < 128u { ret 1u; } + if byte < 128u { return 1u; } // Not a valid start byte - if byte < 192u { ret 0u; } - if byte < 224u { ret 2u; } - if byte < 240u { ret 3u; } - if byte < 248u { ret 4u; } - if byte < 252u { ret 5u; } - ret 6u; + if byte < 192u { return 0u; } + if byte < 224u { return 2u; } + if byte < 240u { return 3u; } + if byte < 248u { return 4u; } + if byte < 252u { return 5u; } + return 6u; } /** @@ -1442,9 +1442,9 @@ pure fn utf8_char_width(b: u8) -> uint { * character sequence. */ pure fn is_char_boundary(s: &str, index: uint) -> bool { - if index == len(s) { ret true; } + if index == len(s) { return true; } let b = s[index]; - ret b < 128u8 || b >= 192u8; + return b < 128u8 || b >= 192u8; } /** @@ -1500,7 +1500,7 @@ pure fn char_range_at(s: &str, i: uint) -> {ch: char, next: uint} { let b0 = s[i]; let w = utf8_char_width(b0); assert (w != 0u); - if w == 1u { ret {ch: b0 as char, next: i + 1u}; } + if w == 1u { return {ch: b0 as char, next: i + 1u}; } let mut val = 0u; let end = i + w; let mut i = i + 1u; @@ -1515,11 +1515,11 @@ pure fn char_range_at(s: &str, i: uint) -> {ch: char, next: uint} { // the first to clip off the marker bits at the left of the byte, and then // a second (as uint) to get it to the right position. val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u); - ret {ch: val as char, next: i}; + return {ch: val as char, next: i}; } /// Pluck a character out of a string -pure fn char_at(s: &str, i: uint) -> char { ret char_range_at(s, i).ch; } +pure fn char_at(s: &str, i: uint) -> char { return char_range_at(s, i).ch; } /** * Given a byte position and a str, return the previous char and its position @@ -1540,7 +1540,7 @@ pure fn char_range_at_reverse(ss: &str, start: uint) prev -= 1u; let ch = char_at(ss, prev); - ret {ch:ch, prev:prev}; + return {ch:ch, prev:prev}; } /** @@ -1571,10 +1571,10 @@ pure fn all_between(s: &str, start: uint, end: uint, let mut i = start; while i < end { let {ch, next} = char_range_at(s, i); - if !it(ch) { ret false; } + if !it(ch) { return false; } i = next; } - ret true; + return true; } /** @@ -1747,7 +1747,7 @@ pure fn escape_default(s: &str) -> ~str { reserve_at_least(out, str::len(s)); chars_iter(s, |c| push_str(out, char::escape_default(c))); } - ret out; + return out; } /// Escape each char in `s` with char::escape_unicode. @@ -1757,7 +1757,7 @@ pure fn escape_unicode(s: &str) -> ~str { reserve_at_least(out, str::len(s)); chars_iter(s, |c| push_str(out, char::escape_unicode(c))); } - ret out; + return out; } /// Unsafe operations @@ -1781,7 +1781,7 @@ mod unsafe { i += 1u; curr = ptr::offset(buf, i); } - ret from_buf_len(buf, i); + return from_buf_len(buf, i); } /// Create a Rust string from a *u8 buffer of the given length @@ -1793,7 +1793,7 @@ mod unsafe { vec::push(v, 0u8); assert is_utf8(v); - ret ::unsafe::transmute(v); + return ::unsafe::transmute(v); } /// Create a Rust string from a null-terminated C string @@ -1861,7 +1861,7 @@ mod unsafe { assert (len > 0u); let b = s[len - 1u]; unsafe { set_len(s, len - 1u) }; - ret b; + return b; } /// Removes the first byte from a string and returns it. (Not UTF-8 safe). @@ -1870,7 +1870,7 @@ mod unsafe { assert (len > 0u); let b = s[0]; s = unsafe { unsafe::slice_bytes(s, 1u, len) }; - ret b; + return b; } /// Sets the length of the string and adds the null terminator @@ -2405,13 +2405,13 @@ mod tests { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"aaaaaaaaaa"); i += 1; } - ret rs; + return rs; } fn half_a_million_letter_a() -> ~str { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"aaaaa"); i += 1; } - ret rs; + return rs; } assert eq(half_a_million_letter_a(), unsafe::slice_bytes(a_million_letter_a(), @@ -2516,13 +2516,13 @@ mod tests { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"华华华华华华华华华华"); i += 1; } - ret rs; + return rs; } fn half_a_million_letter_X() -> ~str { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"华华华华华"); i += 1; } - ret rs; + return rs; } assert eq(half_a_million_letter_X(), slice(a_million_letter_X(), 0u, 3u * 500000u)); diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 6b356819340..b39f384ae0a 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -833,7 +833,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) { // if parent_group { // if !enlist_in_group(parent_group) { // leave_group(child_group); // Roll back - // ret; // Parent group failed. Don't run child's f(). + // return; // Parent group failed. Don't run child's f(). // } // } // stash_taskgroup_data_in_TLS(child_group, parent_group); @@ -1024,7 +1024,7 @@ unsafe fn local_get_helper<T: owned>( do_pop: bool) -> option<@T> { let map = get_task_local_map(task); - // Interpret our findings from the map + // Interpreturn our findings from the map do local_data_lookup(map, key).map |result| { // A reference count magically appears on 'data' out of thin air. It // was referenced in the local_data box, though, not here, so before @@ -1743,7 +1743,7 @@ fn test_child_doesnt_ref_parent() { // climbing the task tree to dereference each ancestor. (See #1789) const generations: uint = 128; fn child_no(x: uint) -> fn~() { - ret || { + return || { if x < generations { task::spawn(child_no(x+1)); } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 681d94c475b..a92ca63dd8b 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -11,19 +11,19 @@ impl extensions <T:copy, U:copy> of tuple_ops<T,U> for (T, U) { /// Return the first element of self pure fn first() -> T { let (t, _) = self; - ret t; + return t; } /// Return the second element of self pure fn second() -> U { let (_, u) = self; - ret u; + return u; } /// Return the results of swapping the two elements of self pure fn swap() -> (U, T) { let (t, u) = self; - ret (u, t); + return (u, t); } } diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 3a420d103a3..13746df2621 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -54,26 +54,26 @@ pure fn compl(i: T) -> T { impl ord of ord for T { pure fn lt(&&other: T) -> bool { - ret self < other; + return self < other; } } impl eq of eq for T { pure fn eq(&&other: T) -> bool { - ret self == other; + return self == other; } } impl num of num::num for T { - pure fn add(&&other: T) -> T { ret self + other; } - pure fn sub(&&other: T) -> T { ret self - other; } - pure fn mul(&&other: T) -> T { ret self * other; } - pure fn div(&&other: T) -> T { ret self / other; } - pure fn modulo(&&other: T) -> T { ret self % other; } - pure fn neg() -> T { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> T { ret n as T; } + pure fn add(&&other: T) -> T { return self + other; } + pure fn sub(&&other: T) -> T { return self - other; } + pure fn mul(&&other: T) -> T { return self * other; } + pure fn div(&&other: T) -> T { return self / other; } + pure fn modulo(&&other: T) -> T { return self % other; } + pure fn neg() -> T { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> T { return n as T; } } /** @@ -89,17 +89,17 @@ impl num of num::num for T { * `buf` must not be empty */ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { - if vec::len(buf) == 0u { ret none; } + if vec::len(buf) == 0u { return none; } let mut i = vec::len(buf) - 1u; let mut power = 1u as T; let mut n = 0u as T; loop { alt char::to_digit(buf[i] as char, radix) { some(d) { n += d as T * power; } - none { ret none; } + none { return none; } } power *= radix as T; - if i == 0u { ret some(n); } + if i == 0u { return some(n); } i -= 1u; }; } @@ -138,16 +138,16 @@ fn from_str(s: ~str) -> option<T> { parse_buf(str::bytes(s), 10u) } /// Parse a string as an unsigned integer. fn from_str_radix(buf: ~str, radix: u64) -> option<u64> { - if str::len(buf) == 0u { ret none; } + if str::len(buf) == 0u { return none; } 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) { some(d) { n += d as u64 * power; } - none { ret none; } + none { return none; } } power *= radix; - if i == 0u { ret some(n); } + if i == 0u { return some(n); } i -= 1u; }; } @@ -233,7 +233,7 @@ pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint, } /// Convert to a string -fn str(i: T) -> ~str { ret to_str(i, 10u); } +fn str(i: T) -> ~str { return to_str(i, 10u); } #[test] fn test_to_str() { diff --git a/src/libcore/uint-template/u8.rs b/src/libcore/uint-template/u8.rs index bc73536c4a4..96b2dd6d9c3 100644 --- a/src/libcore/uint-template/u8.rs +++ b/src/libcore/uint-template/u8.rs @@ -3,4 +3,4 @@ type T = u8; // Type-specific functions here. These must be reexported by the // parent module so that they appear in core::u8 and not core::u8::u8; -pure fn is_ascii(x: T) -> bool { ret 0 as T == x & 128 as T; } +pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/uint-template/uint.rs index 10d91d73e75..401cb8c04c4 100644 --- a/src/libcore/uint-template/uint.rs +++ b/src/libcore/uint-template/uint.rs @@ -14,8 +14,8 @@ type T = uint; */ pure fn div_ceil(x: uint, y: uint) -> uint { let div = div(x, y); - if x % y == 0u { ret div;} - else { ret div + 1u; } + if x % y == 0u { return div;} + else { return div + 1u; } } /** @@ -32,8 +32,8 @@ pure fn div_ceil(x: uint, y: uint) -> uint { */ pure fn div_round(x: uint, y: uint) -> uint { let div = div(x, y); - if x % y * 2u < y { ret div;} - else { ret div + 1u; } + if x % y * 2u < y { return div;} + else { return div + 1u; } } /** @@ -51,10 +51,10 @@ pure fn div_round(x: uint, y: uint) -> uint { * The smallest integer `q` such that `x/y <= q`. This * is either `x/y` or `x/y + 1`. */ -pure fn div_floor(x: uint, y: uint) -> uint { ret x / y; } +pure fn div_floor(x: uint, y: uint) -> uint { return x / y; } /// Produce a uint suitable for use in a hash table -pure fn hash(&&x: uint) -> uint { ret x; } +pure fn hash(&&x: uint) -> uint { return x; } /** * Iterate over the range [`lo`..`hi`), or stop when requested @@ -74,10 +74,10 @@ pure fn hash(&&x: uint) -> uint { ret x; } pure fn iterate(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { - if (!it(i)) { ret false; } + if (!it(i)) { return false; } i += 1u; } - ret true; + return true; } /// Returns the smallest power of 2 greater than or equal to `n` @@ -87,7 +87,7 @@ fn next_power_of_two(n: uint) -> uint { let mut tmp: uint = n - 1u; let mut shift: uint = 1u; while shift <= halfbits { tmp |= tmp >> shift; shift <<= 1u; } - ret tmp + 1u; + return tmp + 1u; } #[test] diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 716a59f8ea9..61fd8d40f23 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -1,6 +1,6 @@ mod general_category { pure fn Cc(c: char) -> bool { - ret alt c { + return alt c { '\x00' to '\x1f' | '\x7f' to '\x9f' { true } @@ -9,7 +9,7 @@ mod general_category { } pure fn Cf(c: char) -> bool { - ret alt c { + return alt c { '\xad' | '\u0600' to '\u0603' | '\u06dd' @@ -29,7 +29,7 @@ mod general_category { } pure fn Co(c: char) -> bool { - ret alt c { + return alt c { '\ue000' to '\uf8ff' { true } _ { false } @@ -37,7 +37,7 @@ mod general_category { } pure fn Cs(c: char) -> bool { - ret alt c { + return alt c { '\ud800' to '\udfff' { true } _ { false } @@ -45,7 +45,7 @@ mod general_category { } pure fn Ll(c: char) -> bool { - ret alt c { + return alt c { '\x61' to '\x7a' | '\xaa' | '\xb5' @@ -650,7 +650,7 @@ mod general_category { } pure fn Lm(c: char) -> bool { - ret alt c { + return alt c { '\u02b0' to '\u02c1' | '\u02c6' to '\u02d1' | '\u02e0' to '\u02e4' @@ -706,7 +706,7 @@ mod general_category { } pure fn Lo(c: char) -> bool { - ret alt c { + return alt c { '\u01bb' | '\u01c0' to '\u01c3' | '\u0294' @@ -892,7 +892,7 @@ mod general_category { } pure fn Lt(c: char) -> bool { - ret alt c { + return alt c { '\u01c5' | '\u01c8' | '\u01cb' @@ -909,7 +909,7 @@ mod general_category { } pure fn Lu(c: char) -> bool { - ret alt c { + return alt c { '\x41' to '\x5a' | '\xc0' to '\xd6' | '\xd8' to '\xde' @@ -1501,7 +1501,7 @@ mod general_category { } pure fn Mc(c: char) -> bool { - ret alt c { + return alt c { '\u0903' | '\u093b' | '\u093e' to '\u0940' @@ -1612,7 +1612,7 @@ mod general_category { } pure fn Me(c: char) -> bool { - ret alt c { + return alt c { '\u0488' to '\u0489' | '\u20dd' to '\u20e0' | '\u20e2' to '\u20e4' @@ -1623,7 +1623,7 @@ mod general_category { } pure fn Mn(c: char) -> bool { - ret alt c { + return alt c { '\u0300' to '\u036f' | '\u0483' to '\u0487' | '\u0591' to '\u05bd' @@ -1816,7 +1816,7 @@ mod general_category { } pure fn Nd(c: char) -> bool { - ret alt c { + return alt c { '\x30' to '\x39' | '\u0660' to '\u0669' | '\u06f0' to '\u06f9' @@ -1860,7 +1860,7 @@ mod general_category { } pure fn Nl(c: char) -> bool { - ret alt c { + return alt c { '\u16ee' to '\u16f0' | '\u2160' to '\u2182' | '\u2185' to '\u2188' @@ -1879,7 +1879,7 @@ mod general_category { } pure fn No(c: char) -> bool { - ret alt c { + return alt c { '\xb2' to '\xb3' | '\xb9' | '\xbc' to '\xbe' @@ -1927,7 +1927,7 @@ mod general_category { } pure fn Pc(c: char) -> bool { - ret alt c { + return alt c { '\x5f' | '\u203f' to '\u2040' | '\u2054' @@ -1940,7 +1940,7 @@ mod general_category { } pure fn Pd(c: char) -> bool { - ret alt c { + return alt c { '\x2d' | '\u058a' | '\u05be' @@ -1962,7 +1962,7 @@ mod general_category { } pure fn Pe(c: char) -> bool { - ret alt c { + return alt c { '\x29' | '\x5d' | '\x7d' @@ -2039,7 +2039,7 @@ mod general_category { } pure fn Pf(c: char) -> bool { - ret alt c { + return alt c { '\xbb' | '\u2019' | '\u201d' @@ -2056,7 +2056,7 @@ mod general_category { } pure fn Pi(c: char) -> bool { - ret alt c { + return alt c { '\xab' | '\u2018' | '\u201b' to '\u201c' @@ -2074,7 +2074,7 @@ mod general_category { } pure fn Po(c: char) -> bool { - ret alt c { + return alt c { '\x21' to '\x23' | '\x25' to '\x27' | '\x2a' @@ -2207,7 +2207,7 @@ mod general_category { } pure fn Ps(c: char) -> bool { - ret alt c { + return alt c { '\x28' | '\x5b' | '\x7b' @@ -2286,7 +2286,7 @@ mod general_category { } pure fn Sc(c: char) -> bool { - ret alt c { + return alt c { '\x24' | '\xa2' to '\xa5' | '\u060b' @@ -2309,7 +2309,7 @@ mod general_category { } pure fn Sk(c: char) -> bool { - ret alt c { + return alt c { '\x5e' | '\x60' | '\xa8' @@ -2343,7 +2343,7 @@ mod general_category { } pure fn Sm(c: char) -> bool { - ret alt c { + return alt c { '\x2b' | '\x3c' to '\x3e' | '\x7c' @@ -2414,7 +2414,7 @@ mod general_category { } pure fn So(c: char) -> bool { - ret alt c { + return alt c { '\xa6' to '\xa7' | '\xa9' | '\xae' @@ -2533,7 +2533,7 @@ mod general_category { } pure fn Zl(c: char) -> bool { - ret alt c { + return alt c { '\u2028' { true } _ { false } @@ -2541,7 +2541,7 @@ mod general_category { } pure fn Zp(c: char) -> bool { - ret alt c { + return alt c { '\u2029' { true } _ { false } @@ -2549,7 +2549,7 @@ mod general_category { } pure fn Zs(c: char) -> bool { - ret alt c { + return alt c { '\x20' | '\xa0' | '\u1680' @@ -2567,7 +2567,7 @@ mod general_category { mod derived_property { /// Check if a character has the alphabetic unicode property pure fn Alphabetic(c: char) -> bool { - ret alt c { + return alt c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' @@ -3305,7 +3305,7 @@ mod derived_property { } pure fn XID_Continue(c: char) -> bool { - ret alt c { + return alt c { '\x30' to '\x39' | '\x41' to '\x5a' | '\x5f' @@ -4176,7 +4176,7 @@ mod derived_property { } pure fn XID_Start(c: char) -> bool { - ret alt c { + return alt c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs index 343fca55813..e56900876fc 100644 --- a/src/libcore/unsafe.rs +++ b/src/libcore/unsafe.rs @@ -44,7 +44,7 @@ unsafe fn bump_box_refcount<T>(+t: @T) { forget(t); } unsafe fn transmute<L, G>(-thing: L) -> G { let newthing = reinterpret_cast(thing); forget(thing); - ret newthing; + return newthing; } #[cfg(test)] diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index d0cd011ff12..670df1bd00b 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -191,7 +191,7 @@ pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> ~[T] { let mut i: uint = 0u; while i < n_elts unsafe { unsafe::set(v, i, op(i)); i += 1u; } unsafe { unsafe::set_len(v, n_elts); } - ret v; + return v; } /** @@ -208,7 +208,7 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> ~[T] { while i < n_elts { unsafe::set(v, i, t); i += 1u; } unsafe { unsafe::set_len(v, n_elts); } } - ret v; + return v; } /** @@ -234,7 +234,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> ~[A] { <fn(push: pure fn(+A)), fn(push: fn(+A))> (builder)(|+x| push(vec, x)); } - ret vec; + return vec; } /** @@ -269,7 +269,7 @@ pure fn head<T: copy>(v: &[const T]) -> T { v[0] } /// Returns a vector containing all but the first element of a slice pure fn tail<T: copy>(v: &[const T]) -> ~[T] { - ret slice(v, 1u, len(v)); + return slice(v, 1u, len(v)); } /** @@ -297,7 +297,7 @@ pure fn last<T: copy>(v: &[const T]) -> T { * or `none` if the vector is empty. */ pure fn last_opt<T: copy>(v: &[const T]) -> option<T> { - if len(v) == 0u { ret none; } + if len(v) == 0u { return none; } some(v[len(v) - 1u]) } @@ -309,7 +309,7 @@ pure fn slice<T: copy>(v: &[const T], start: uint, end: uint) -> ~[T] { unchecked { for uint::range(start, end) |i| { vec::push(result, v[i]) } } - ret result; + return result; } /// Return a slice that points into another slice. @@ -351,7 +351,7 @@ pure fn const_view<T>(v: &[const T], start: uint, end: uint) -> &[const T] { /// Split the vector `v` by applying each element against the predicate `f`. fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut start = 0u; let mut result = ~[]; @@ -374,7 +374,7 @@ fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { */ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut start = 0u; let mut count = n; @@ -400,7 +400,7 @@ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { */ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut end = ln; let mut result = ~[]; @@ -423,7 +423,7 @@ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { */ fn rsplitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut end = ln; let mut count = n; @@ -564,7 +564,7 @@ pure fn append<T: copy>(+lhs: ~[T], rhs: &[const T]) -> ~[T] { unchecked { push_all(v, rhs); } - ret v; + return v; } #[inline(always)] @@ -591,7 +591,7 @@ pure fn append_mut<T: copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] { } i += 1u; } - ret v; + return v; } /** @@ -649,7 +649,7 @@ pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> ~[U] { let mut result = ~[]; unchecked{reserve(result, len(v));} for each(v) |elem| { unsafe { push(result, f(elem)); } } - ret result; + return result; } fn map_consume<T, U>(+v: ~[T], f: fn(+T) -> U) -> ~[U] { @@ -665,7 +665,7 @@ pure fn mapi<T, U>(v: &[T], f: fn(uint, T) -> U) -> ~[U] { let mut result = ~[]; unchecked{reserve(result, len(v));} for eachi(v) |i, elem| { unsafe { push(result, f(i, elem)); } } - ret result; + return result; } /** @@ -675,7 +675,7 @@ pure fn mapi<T, U>(v: &[T], f: fn(uint, T) -> U) -> ~[U] { pure fn flat_map<T, U>(v: &[T], f: fn(T) -> ~[U]) -> ~[U] { let mut result = ~[]; for each(v) |elem| { unchecked{ push_all_move(result, f(elem)); } } - ret result; + return result; } /// Apply a function to each pair of elements and return the results @@ -689,7 +689,7 @@ pure fn map2<T: copy, U: copy, V>(v0: &[T], v1: &[U], unsafe { push(u, f(copy v0[i], copy v1[i])) }; i += 1u; } - ret u; + return u; } /** @@ -707,7 +707,7 @@ pure fn filter_map<T, U: copy>(v: &[T], f: fn(T) -> option<U>) some(result_elem) { unsafe { push(result, result_elem); } } } } - ret result; + return result; } /** @@ -722,7 +722,7 @@ pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] { for each(v) |elem| { if f(elem) { unsafe { push(result, elem); } } } - ret result; + return result; } /** @@ -733,7 +733,7 @@ pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] { pure fn concat<T: copy>(v: &[~[T]]) -> ~[T] { let mut r = ~[]; for each(v) |inner| { unsafe { push_all(r, inner); } } - ret r; + return r; } /// Concatenate a vector of vectors, placing a given separator between each @@ -744,7 +744,7 @@ pure fn connect<T: copy>(v: &[~[T]], sep: T) -> ~[T] { if first { first = false; } else { unsafe { push(r, sep); } } unchecked { push_all(r, inner) }; } - ret r; + return r; } /// Reduce a vector from left to right @@ -753,7 +753,7 @@ pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T { do iter(v) |elt| { accum = p(accum, elt); } - ret accum; + return accum; } /// Reduce a vector from right to left @@ -762,7 +762,7 @@ pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U { do riter(v) |elt| { accum = p(elt, accum); } - ret accum; + return accum; } /** @@ -771,8 +771,8 @@ pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U { * If the vector contains no elements then false is returned. */ pure fn any<T>(v: &[T], f: fn(T) -> bool) -> bool { - for each(v) |elem| { if f(elem) { ret true; } } - ret false; + for each(v) |elem| { if f(elem) { return true; } } + return false; } /** @@ -786,10 +786,10 @@ pure fn any2<T, U>(v0: &[T], v1: &[U], let v1_len = len(v1); let mut i = 0u; while i < v0_len && i < v1_len { - if f(v0[i], v1[i]) { ret true; }; + if f(v0[i], v1[i]) { return true; }; i += 1u; } - ret false; + return false; } /** @@ -798,8 +798,8 @@ pure fn any2<T, U>(v0: &[T], v1: &[U], * If the vector contains no elements then true is returned. */ pure fn all<T>(v: &[T], f: fn(T) -> bool) -> bool { - for each(v) |elem| { if !f(elem) { ret false; } } - ret true; + for each(v) |elem| { if !f(elem) { return false; } } + return true; } /** @@ -808,8 +808,8 @@ pure fn all<T>(v: &[T], f: fn(T) -> bool) -> bool { * If the vector contains no elements then true is returned. */ pure fn alli<T>(v: &[T], f: fn(uint, T) -> bool) -> bool { - for eachi(v) |i, elem| { if !f(i, elem) { ret false; } } - ret true; + for eachi(v) |i, elem| { if !f(i, elem) { return false; } } + return true; } /** @@ -820,23 +820,23 @@ pure fn alli<T>(v: &[T], f: fn(uint, T) -> bool) -> bool { pure fn all2<T, U>(v0: &[T], v1: &[U], f: fn(T, U) -> bool) -> bool { let v0_len = len(v0); - if v0_len != len(v1) { ret false; } + if v0_len != len(v1) { return false; } let mut i = 0u; - while i < v0_len { if !f(v0[i], v1[i]) { ret false; }; i += 1u; } - ret true; + while i < v0_len { if !f(v0[i], v1[i]) { return false; }; i += 1u; } + return true; } /// Return true if a vector contains an element with the given value pure fn contains<T>(v: &[T], x: T) -> bool { - for each(v) |elt| { if x == elt { ret true; } } - ret false; + for each(v) |elt| { if x == elt { return true; } } + return false; } /// Returns the number of elements that are equal to a given value pure fn count<T>(v: &[T], x: T) -> uint { let mut cnt = 0u; for each(v) |elt| { if x == elt { cnt += 1u; } } - ret cnt; + return cnt; } /** @@ -913,8 +913,8 @@ pure fn position_between<T>(v: &[T], start: uint, end: uint, assert start <= end; assert end <= len(v); let mut i = start; - while i < end { if f(v[i]) { ret some::<uint>(i); } i += 1u; } - ret none; + while i < end { if f(v[i]) { return some::<uint>(i); } i += 1u; } + return none; } /// Find the last index containing a matching value @@ -947,10 +947,10 @@ pure fn rposition_between<T>(v: &[T], start: uint, end: uint, assert end <= len(v); let mut i = end; while i > start { - if f(v[i - 1u]) { ret some::<uint>(i - 1u); } + if f(v[i - 1u]) { return some::<uint>(i - 1u); } i -= 1u; } - ret none; + return none; } // FIXME: if issue #586 gets implemented, could have a postcondition @@ -974,7 +974,7 @@ pure fn unzip<T: copy, U: copy>(v: &[(T, U)]) -> (~[T], ~[U]) { vec::push(bs, b); } } - ret (as, bs); + return (as, bs); } /** @@ -989,7 +989,7 @@ pure fn zip<T: copy, U: copy>(v: &[const T], u: &[const U]) -> ~[(T, U)] { let mut i = 0u; assert sz == len(u); while i < sz unchecked { vec::push(zipped, (v[i], u[i])); i += 1u; } - ret zipped; + return zipped; } /** @@ -1017,12 +1017,12 @@ fn reverse<T>(v: ~[mut T]) { pure fn reversed<T: copy>(v: &[const T]) -> ~[T] { let mut rs: ~[T] = ~[]; let mut i = len::<T>(v); - if i == 0u { ret rs; } else { i -= 1u; } + if i == 0u { return rs; } else { i -= 1u; } unchecked { while i != 0u { vec::push(rs, v[i]); i -= 1u; } vec::push(rs, v[0]); } - ret rs; + return rs; } /** @@ -1229,7 +1229,7 @@ pure fn windowed<TT: copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] { vec::push(ww, vec::slice(xx, ii, ii+nn)); } }); - ret ww; + return ww; } /** @@ -1541,7 +1541,7 @@ mod unsafe { */ #[inline(always)] unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] { - ret ::unsafe::reinterpret_cast( + return ::unsafe::reinterpret_cast( rustrt::vec_from_buf_shared(sys::get_type_desc::<T>(), ptr as *(), elts as size_t)); @@ -1572,14 +1572,14 @@ mod unsafe { #[inline(always)] unsafe fn to_ptr<T>(v: ~[const T]) -> *T { let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); - ret ::unsafe::reinterpret_cast(addr_of((**repr).data)); + return ::unsafe::reinterpret_cast(addr_of((**repr).data)); } #[inline(always)] unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T { let repr: **slice_repr = ::unsafe::reinterpret_cast(addr_of(v)); - ret ::unsafe::reinterpret_cast(addr_of((**repr).data)); + return ::unsafe::reinterpret_cast(addr_of((**repr).data)); } @@ -1775,21 +1775,21 @@ impl extensions/&<A:copy> of iter_trait_extensions<A> for &[A] { #[cfg(test)] mod tests { - fn square(n: uint) -> uint { ret n * n; } + fn square(n: uint) -> uint { return n * n; } - fn square_ref(&&n: uint) -> uint { ret n * n; } + fn square_ref(&&n: uint) -> uint { return n * n; } - pure fn is_three(&&n: uint) -> bool { ret n == 3u; } + pure fn is_three(&&n: uint) -> bool { return n == 3u; } - pure fn is_odd(&&n: uint) -> bool { ret n % 2u == 1u; } + pure fn is_odd(&&n: uint) -> bool { return n % 2u == 1u; } - pure fn is_equal(&&x: uint, &&y:uint) -> bool { ret x == y; } + pure fn is_equal(&&x: uint, &&y:uint) -> bool { return x == y; } fn square_if_odd(&&n: uint) -> option<uint> { - ret if n % 2u == 1u { some(n * n) } else { none }; + return if n % 2u == 1u { some(n * n) } else { none }; } - fn add(&&x: uint, &&y: uint) -> uint { ret x + y; } + fn add(&&x: uint, &&y: uint) -> uint { return x + y; } #[test] fn test_unsafe_ptrs() { @@ -2015,7 +2015,7 @@ mod tests { #[test] fn test_map2() { - fn times(&&x: int, &&y: int) -> int { ret x * y; } + fn times(&&x: int, &&y: int) -> int { return x * y; } let f = times; let v0 = ~[1, 2, 3, 4, 5]; let v1 = ~[5, 4, 3, 2, 1]; @@ -2043,10 +2043,10 @@ mod tests { fn halve(&&i: int) -> option<int> { if i % 2 == 0 { - ret option::some::<int>(i / 2); - } else { ret option::none::<int>; } + return option::some::<int>(i / 2); + } else { return option::none::<int>; } } - fn halve_for_sure(&&i: int) -> int { ret i / 2; } + fn halve_for_sure(&&i: int) -> int { return i / 2; } let all_even: ~[int] = ~[0, 2, 8, 6]; let all_odd1: ~[int] = ~[1, 7, 3]; let all_odd2: ~[int] = ~[]; @@ -2230,8 +2230,8 @@ mod tests { #[test] fn test_position() { - fn less_than_three(&&i: int) -> bool { ret i < 3; } - fn is_eighteen(&&i: int) -> bool { ret i == 18; } + fn less_than_three(&&i: int) -> bool { return i < 3; } + fn is_eighteen(&&i: int) -> bool { return i == 18; } assert position(~[], less_than_three) == none; diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 2df720e6fe1..b9bc977db31 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -20,7 +20,7 @@ fn chunk(size: uint) -> @chunk { } fn arena_with_size(initial_size: uint) -> arena { - ret arena_({mut chunks: @cons(chunk(initial_size), @nil)}); + return arena_({mut chunks: @cons(chunk(initial_size), @nil)}); } fn arena() -> arena { @@ -36,7 +36,7 @@ impl arena for arena { head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u)); self.chunks = @cons(head, self.chunks); - ret self.alloc_inner(n_bytes, align); + return self.alloc_inner(n_bytes, align); } #[inline(always)] @@ -48,13 +48,13 @@ impl arena for arena { start = (start + alignm1) & !alignm1; let end = start + n_bytes; if end > vec::capacity(head.data) { - ret self.alloc_grow(n_bytes, align); + return self.alloc_grow(n_bytes, align); } unsafe { let p = ptr::offset(vec::unsafe::to_ptr(head.data), start); head.fill = end; - ret unsafe::reinterpret_cast(p); + return unsafe::reinterpret_cast(p); } } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 7a8946d02a6..8ee0253ba40 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -100,11 +100,11 @@ impl of from_base64 for ~[u8] { 1u { vec::push(r, ((n >> 16u) & 0xFFu) as u8); vec::push(r, ((n >> 8u ) & 0xFFu) as u8); - ret copy r; + return copy r; } 2u { vec::push(r, ((n >> 10u) & 0xFFu) as u8); - ret copy r; + return copy r; } _ { fail ~"invalid base64 padding"; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index a9b3910ec19..f27e6c3e266 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -143,7 +143,7 @@ class big_bitv { fn equals(b: &big_bitv) -> bool { let len = b.storage.len(); for uint::iterate(0, len) |i| { - if self.storage[i] != b.storage[i] { ret false; } + if self.storage[i] != b.storage[i] { return false; } } } } @@ -287,7 +287,7 @@ class bitv { */ #[inline(always)] fn equal(v1: bitv) -> bool { - if self.nbits != v1.nbits { ret false; } + if self.nbits != v1.nbits { return false; } alt self.rep { small(b) { alt v1.rep { @@ -300,7 +300,7 @@ class bitv { big(s1) { s.equals(s1) } - small(_) { ret false; } + small(_) { return false; } } } } @@ -354,7 +354,7 @@ class bitv { alt self.rep { small(b) { b.is_true() } _ { - for self.each() |i| { if !i { ret false; } } + for self.each() |i| { if !i { return false; } } true } } @@ -375,14 +375,14 @@ class bitv { alt self.rep { small(b) { b.is_false() } big(_) { - for self.each() |i| { if i { ret false; } } + for self.each() |i| { if i { return false; } } true } } } fn init_to_vec(i: uint) -> uint { - ret if self.get(i) { 1 } else { 0 }; + return if self.get(i) { 1 } else { 0 }; } /** @@ -392,7 +392,7 @@ class bitv { */ fn to_vec() -> ~[uint] { let sub = |x| self.init_to_vec(x); - ret vec::from_fn::<uint>(self.nbits, sub); + return vec::from_fn::<uint>(self.nbits, sub); } /** @@ -420,7 +420,7 @@ class bitv { while i < self.nbits { let w0 = self.get(i); let w1 = v[i]; - if !w0 && w1 != 0u || w0 && w1 == 0u { ret false; } + if !w0 && w1 != 0u || w0 && w1 == 0u { return false; } i = i + 1; } true @@ -438,11 +438,11 @@ class bitv { const uint_bits: uint = 32u + (1u << 32u >> 27u); -pure fn lor(w0: uint, w1: uint) -> uint { ret w0 | w1; } +pure fn lor(w0: uint, w1: uint) -> uint { return w0 | w1; } -pure fn land(w0: uint, w1: uint) -> uint { ret w0 & w1; } +pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; } -pure fn right(_w0: uint, w1: uint) -> uint { ret w1; } +pure fn right(_w0: uint, w1: uint) -> uint { return w1; } impl extensions of ops::index<uint,bool> for bitv { pure fn index(&&i: uint) -> bool { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 7f71b999d6f..b80ec82bcf3 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -66,7 +66,7 @@ class dtor_res { * * len - The number of elements in the buffer */ unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> { - ret c_vec_({ + return c_vec_({ base: base, len: len, rsrc: @dtor_res(option::none) @@ -86,7 +86,7 @@ unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> { */ unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) -> c_vec<T> { - ret c_vec_({ + return c_vec_({ base: base, len: len, rsrc: @dtor_res(option::some(dtor)) @@ -104,7 +104,7 @@ unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) */ fn get<T: copy>(t: c_vec<T>, ofs: uint) -> T { assert ofs < len(t); - ret unsafe { *ptr::mut_offset((*t).base, ofs) }; + return unsafe { *ptr::mut_offset((*t).base, ofs) }; } /** @@ -123,12 +123,12 @@ fn set<T: copy>(t: c_vec<T>, ofs: uint, v: T) { /// Returns the length of the vector fn len<T>(t: c_vec<T>) -> uint { - ret (*t).len; + return (*t).len; } /// Returns a pointer to the first element of the vector unsafe fn ptr<T>(t: c_vec<T>) -> *mut T { - ret (*t).base; + return (*t).base; } #[cfg(test)] @@ -140,7 +140,7 @@ mod tests { assert mem as int != 0; - ret unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, + return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, ||free(mem)) }; } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index f74cbba23ce..cc2c9dae3d6 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -8,19 +8,19 @@ trait fuzzy_eq { impl fuzzy_eq of fuzzy_eq for float { pure fn fuzzy_eq(&&other: float) -> bool { - ret float::abs(self - other) < fuzzy_epsilon; + return float::abs(self - other) < fuzzy_epsilon; } } impl fuzzy_eq of fuzzy_eq for f32 { pure fn fuzzy_eq(&&other: f32) -> bool { - ret f32::abs(self - other) < (fuzzy_epsilon as f32); + return f32::abs(self - other) < (fuzzy_epsilon as f32); } } impl fuzzy_eq of fuzzy_eq for f64 { pure fn fuzzy_eq(&&other: f64) -> bool { - ret f64::abs(self - other) < (fuzzy_epsilon as f64); + return f64::abs(self - other) < (fuzzy_epsilon as f64); } } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 408a8ca20c2..f3feb26ebb6 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -38,7 +38,7 @@ fn create<T: copy>() -> t<T> { i += 1u; } - ret rv; + return rv; } fn get<T: copy>(elts: dvec<cell<T>>, i: uint) -> T { alt elts.get_elt(i) { some(t) { t } _ { fail } } @@ -50,7 +50,7 @@ fn create<T: copy>() -> t<T> { elts: dvec<cell<T>>}; impl <T: copy> of t<T> for repr<T> { - fn size() -> uint { ret self.nelts; } + fn size() -> uint { return self.nelts; } fn add_front(t: T) { let oldlo: uint = self.lo; if self.lo == 0u { @@ -83,7 +83,7 @@ fn create<T: copy>() -> t<T> { self.elts.set_elt(self.lo, none); self.lo = (self.lo + 1u) % self.elts.len(); self.nelts -= 1u; - ret t; + return t; } fn pop_back() -> T { if self.hi == 0u { @@ -92,13 +92,13 @@ fn create<T: copy>() -> t<T> { let t: T = get(self.elts, self.hi); self.elts.set_elt(self.hi, none); self.nelts -= 1u; - ret t; + return t; } - fn peek_front() -> T { ret get(self.elts, self.lo); } - fn peek_back() -> T { ret get(self.elts, self.hi - 1u); } + fn peek_front() -> T { return get(self.elts, self.lo); } + fn peek_back() -> T { return get(self.elts, self.hi - 1u); } fn get(i: int) -> T { let idx = (self.lo + (i as uint)) % self.elts.len(); - ret get(self.elts, idx); + return get(self.elts, idx); } } @@ -235,21 +235,25 @@ mod tests { #[test] fn test() { - fn inteq(&&a: int, &&b: int) -> bool { ret a == b; } - fn intboxeq(&&a: @int, &&b: @int) -> bool { ret a == b; } + 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 { one(b1) { ret a1 == b1; } _ { ret false; } } } + one(a1) { + alt b { one(b1) {return a1 == b1; } _ { return false; } } + } two(a1, a2) { alt b { - two(b1, b2) { ret a1 == b1 && a2 == b2; } - _ { ret false; } + two(b1, b2) { return a1 == b1 && a2 == b2; } + _ { return false; } } } three(a1, a2, a3) { alt b { - three(b1, b2, b3) { ret a1 == b1 && a2 == b2 && a3 == b3; } - _ { ret false; } + three(b1, b2, b3) { + return a1 == b1 && a2 == b2 && a3 == b3; + } + _ { return false; } } } } @@ -257,26 +261,28 @@ mod tests { fn taggypareq<T>(a: taggypar<T>, b: taggypar<T>) -> bool { alt a { onepar::<T>(a1) { - alt b { onepar::<T>(b1) { ret a1 == b1; } _ { ret false; } } + alt b { + onepar::<T>(b1) { return a1 == b1; } _ { return false; } + } } twopar::<T>(a1, a2) { alt b { - twopar::<T>(b1, b2) { ret a1 == b1 && a2 == b2; } - _ { ret false; } + twopar::<T>(b1, b2) { return a1 == b1 && a2 == b2; } + _ { return false; } } } threepar::<T>(a1, a2, a3) { alt b { threepar::<T>(b1, b2, b3) { - ret a1 == b1 && a2 == b2 && a3 == b3; + return a1 == b1 && a2 == b2 && a3 == b3; } - _ { ret false; } + _ { return false; } } } } } fn reccyeq(a: reccy, b: reccy) -> bool { - ret a.x == b.x && a.y == b.y && taggyeq(a.t, b.t); + return a.x == b.x && a.y == b.y && taggyeq(a.t, b.t); } debug!{"*** test boxes"}; test_boxes(@5, @72, @64, @175); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index d5d1e70bc7b..46ccaa2d096 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -63,19 +63,19 @@ impl extensions of ops::index<uint,doc> for doc { fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { let a = data[start]; if a & 0x80u8 != 0u8 { - ret {val: (a & 0x7fu8) as uint, next: start + 1u}; + return {val: (a & 0x7fu8) as uint, next: start + 1u}; } if a & 0x40u8 != 0u8 { - ret {val: ((a & 0x3fu8) as uint) << 8u | + return {val: ((a & 0x3fu8) as uint) << 8u | (data[start + 1u] as uint), next: start + 2u}; } else if a & 0x20u8 != 0u8 { - ret {val: ((a & 0x1fu8) as uint) << 16u | + return {val: ((a & 0x1fu8) as uint) << 16u | (data[start + 1u] as uint) << 8u | (data[start + 2u] as uint), next: start + 3u}; } else if a & 0x10u8 != 0u8 { - ret {val: ((a & 0x0fu8) as uint) << 24u | + return {val: ((a & 0x0fu8) as uint) << 24u | (data[start + 1u] as uint) << 16u | (data[start + 2u] as uint) << 8u | (data[start + 3u] as uint), @@ -84,14 +84,14 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { } fn doc(data: @~[u8]) -> doc { - ret {data: data, start: 0u, end: vec::len::<u8>(*data)}; + return {data: data, start: 0u, end: vec::len::<u8>(*data)}; } fn doc_at(data: @~[u8], start: uint) -> tagged_doc { let elt_tag = vuint_at(*data, start); let elt_size = vuint_at(*data, elt_tag.next); let end = elt_size.next + elt_size.val; - ret {tag: elt_tag.val, + return {tag: elt_tag.val, doc: {data: data, start: elt_size.next, end: end}}; } @@ -102,15 +102,19 @@ fn maybe_get_doc(d: doc, tg: uint) -> option<doc> { let elt_size = vuint_at(*d.data, elt_tag.next); pos = elt_size.next + elt_size.val; if elt_tag.val == tg { - ret some::<doc>({data: d.data, start: elt_size.next, end: pos}); + return some::<doc>({ + data: d.data, + start: elt_size.next, + end: pos + }); } } - ret none::<doc>; + return none::<doc>; } fn get_doc(d: doc, tg: uint) -> doc { alt maybe_get_doc(d, tg) { - some(d) { ret d; } + some(d) { return d; } none { error!{"failed to find block with tag %u", tg}; fail; @@ -147,29 +151,29 @@ fn tagged_docs(d: doc, tg: uint, it: fn(doc) -> bool) { fn doc_data(d: doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) } fn with_doc_data<T>(d: doc, f: fn(x: &[u8]) -> T) -> T { - ret f(vec::view(*d.data, d.start, d.end)); + return f(vec::view(*d.data, d.start, d.end)); } -fn doc_as_str(d: doc) -> ~str { ret str::from_bytes(doc_data(d)); } +fn doc_as_str(d: doc) -> ~str { return str::from_bytes(doc_data(d)); } fn doc_as_u8(d: doc) -> u8 { assert d.end == d.start + 1u; - ret (*d.data)[d.start]; + return (*d.data)[d.start]; } fn doc_as_u16(d: doc) -> u16 { assert d.end == d.start + 2u; - ret io::u64_from_be_bytes(*d.data, d.start, 2u) as u16; + return io::u64_from_be_bytes(*d.data, d.start, 2u) as u16; } fn doc_as_u32(d: doc) -> u32 { assert d.end == d.start + 4u; - ret io::u64_from_be_bytes(*d.data, d.start, 4u) as u32; + return io::u64_from_be_bytes(*d.data, d.start, 4u) as u32; } fn doc_as_u64(d: doc) -> u64 { assert d.end == d.start + 8u; - ret io::u64_from_be_bytes(*d.data, d.start, 8u); + return io::u64_from_be_bytes(*d.data, d.start, 8u); } fn doc_as_i8(d: doc) -> i8 { doc_as_u8(d) as i8 } @@ -205,16 +209,16 @@ fn write_sized_vuint(w: io::writer, n: uint, size: uint) { } fn write_vuint(w: io::writer, n: uint) { - if n < 0x7f_u { write_sized_vuint(w, n, 1u); ret; } - if n < 0x4000_u { write_sized_vuint(w, n, 2u); ret; } - if n < 0x200000_u { write_sized_vuint(w, n, 3u); ret; } - if n < 0x10000000_u { write_sized_vuint(w, n, 4u); ret; } + if n < 0x7f_u { write_sized_vuint(w, n, 1u); return; } + if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } + if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } + if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } fail fmt!{"vint to write too big: %?", n}; } fn writer(w: io::writer) -> writer { let size_positions: ~[uint] = ~[]; - ret writer_({writer: w, mut size_positions: size_positions}); + return writer_({writer: w, mut size_positions: size_positions}); } // FIXME (#2741): Provide a function to write the standard ebml header. @@ -462,7 +466,7 @@ impl deserializer_priv for ebml_deserializer { r_doc.end, self.parent.end}; } self.pos = r_doc.end; - ret r_doc; + return r_doc; } fn push_doc<T: copy>(d: ebml::doc, f: fn() -> T) -> T{ @@ -473,13 +477,13 @@ impl deserializer_priv for ebml_deserializer { let r = f(); self.parent = old_parent; self.pos = old_pos; - ret r; + return r; } fn _next_uint(exp_tag: ebml_serializer_tag) -> uint { let r = ebml::doc_as_u32(self.next_doc(exp_tag)); debug!{"_next_uint exp_tag=%? result=%?", exp_tag, r}; - ret r as uint; + return r as uint; } } @@ -495,7 +499,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer { if v > (core::uint::max_value as u64) { fail fmt!{"uint %? too large for this architecture", v}; } - ret v as uint; + return v as uint; } fn read_i64() -> i64 { ebml::doc_as_u64(self.next_doc(es_i64)) as i64 } @@ -507,7 +511,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer { if v > (int::max_value as i64) || v < (int::min_value as i64) { fail fmt!{"int %? out of range for this architecture", v}; } - ret v as int; + return v as int; } fn read_bool() -> bool { ebml::doc_as_u8(self.next_doc(es_bool)) as bool } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 86a75e653d8..ed7d4206436 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -49,14 +49,14 @@ * }; * if opt_present(matches, "h") || opt_present(matches, "help") { * print_usage(program); - * ret; + * return; * } * let output = opt_maybe_str(matches, "o"); * let input = if vec::is_not_empty(matches.free) { * matches.free[0] * } else { * print_usage(program); - * ret; + * return; * }; * do_work(input, output); * } @@ -94,29 +94,29 @@ enum occur { req, optional, multi, } type opt = {name: name, hasarg: hasarg, occur: occur}; fn mkname(nm: ~str) -> name { - ret if str::len(nm) == 1u { + return if str::len(nm) == 1u { short(str::char_at(nm, 0u)) } else { long(nm) }; } /// Create an option that is required and takes an argument fn reqopt(name: ~str) -> opt { - ret {name: mkname(name), hasarg: yes, occur: req}; + return {name: mkname(name), hasarg: yes, occur: req}; } /// Create an option that is optional and takes an argument fn optopt(name: ~str) -> opt { - ret {name: mkname(name), hasarg: yes, occur: optional}; + return {name: mkname(name), hasarg: yes, occur: optional}; } /// Create an option that is optional and does not take an argument fn optflag(name: ~str) -> opt { - ret {name: mkname(name), hasarg: no, occur: optional}; + return {name: mkname(name), hasarg: no, occur: optional}; } /// Create an option that is optional and takes an optional argument fn optflagopt(name: ~str) -> opt { - ret {name: mkname(name), hasarg: maybe, occur: optional}; + return {name: mkname(name), hasarg: maybe, occur: optional}; } /** @@ -124,7 +124,7 @@ fn optflagopt(name: ~str) -> opt { * multiple times */ fn optmulti(name: ~str) -> opt { - ret {name: mkname(name), hasarg: yes, occur: multi}; + return {name: mkname(name), hasarg: yes, occur: multi}; } enum optval { val(~str), given, } @@ -136,11 +136,11 @@ enum optval { val(~str), given, } type matches = {opts: ~[opt], vals: ~[~[optval]], free: ~[~str]}; fn is_arg(arg: ~str) -> bool { - ret str::len(arg) > 1u && arg[0] == '-' as u8; + return str::len(arg) > 1u && arg[0] == '-' as u8; } fn name_str(nm: name) -> ~str { - ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; + return alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; } fn find_opt(opts: ~[opt], nm: name) -> option<uint> { @@ -161,7 +161,7 @@ enum fail_ { /// Convert a `fail_` enum into an error string fn fail_str(f: fail_) -> ~str { - ret alt f { + return alt f { argument_missing(nm) { ~"Argument to option '" + nm + ~"' missing." } @@ -191,7 +191,7 @@ type result = result::result<matches, fail_>; */ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { let n_opts = vec::len::<opt>(opts); - fn f(_x: uint) -> ~[optval] { ret ~[]; } + fn f(_x: uint) -> ~[optval] { return ~[]; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); let mut free: ~[~str] = ~[]; let l = vec::len(args); @@ -262,12 +262,12 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { name_pos += 1u; let optid = alt find_opt(opts, nm) { some(id) { id } - none { ret err(unrecognized_option(name_str(nm))); } + none { return err(unrecognized_option(name_str(nm))); } }; alt opts[optid].hasarg { no { if !option::is_none::<~str>(i_arg) { - ret err(unexpected_argument(name_str(nm))); + return err(unexpected_argument(name_str(nm))); } vec::push(vals[optid], given); } @@ -284,7 +284,7 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { vec::push(vals[optid], val(option::get::<~str>(i_arg))); } else if i + 1u == l { - ret err(argument_missing(name_str(nm))); + return err(argument_missing(name_str(nm))); } else { i += 1u; vec::push(vals[optid], val(args[i])); } } } @@ -298,42 +298,42 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { let occ = opts[i].occur; if occ == req { if n == 0u { - ret err(option_missing(name_str(opts[i].name))); + return err(option_missing(name_str(opts[i].name))); } } if occ != multi { if n > 1u { - ret err(option_duplicated(name_str(opts[i].name))); + return err(option_duplicated(name_str(opts[i].name))); } } i += 1u; } - ret ok({opts: opts, vals: vec::from_mut(vals), free: free}); + return ok({opts: opts, vals: vec::from_mut(vals), free: free}); } fn opt_vals(m: matches, nm: ~str) -> ~[optval] { - ret alt find_opt(m.opts, mkname(nm)) { + return alt find_opt(m.opts, mkname(nm)) { some(id) { m.vals[id] } none { error!{"No option '%s' defined", nm}; fail } }; } -fn opt_val(m: matches, nm: ~str) -> optval { ret opt_vals(m, nm)[0]; } +fn opt_val(m: matches, nm: ~str) -> optval { return opt_vals(m, nm)[0]; } /// Returns true if an option was matched fn opt_present(m: matches, nm: ~str) -> bool { - ret vec::len::<optval>(opt_vals(m, nm)) > 0u; + return vec::len::<optval>(opt_vals(m, nm)) > 0u; } /// 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)) { - some(_) { ret true; } + some(_) { return true; } _ { } } } - ret false; + return false; } @@ -344,7 +344,7 @@ fn opts_present(m: matches, names: ~[~str]) -> bool { * argument */ fn opt_str(m: matches, nm: ~str) -> ~str { - ret alt opt_val(m, nm) { val(s) { s } _ { fail } }; + return alt opt_val(m, nm) { val(s) { s } _ { fail } }; } /** @@ -356,7 +356,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) { - val(s) { ret s } + val(s) { return s } _ { } } } @@ -375,14 +375,14 @@ fn opt_strs(m: matches, nm: ~str) -> ~[~str] { for vec::each(opt_vals(m, nm)) |v| { alt v { val(s) { vec::push(acc, s); } _ { } } } - ret acc; + return acc; } /// Returns the string argument supplied to a matching option or none fn opt_maybe_str(m: matches, nm: ~str) -> option<~str> { let vals = opt_vals(m, nm); - if vec::len::<optval>(vals) == 0u { ret none::<~str>; } - ret alt vals[0] { val(s) { some::<~str>(s) } _ { none::<~str> } }; + if vec::len::<optval>(vals) == 0u { return none::<~str>; } + return alt vals[0] { val(s) { some::<~str>(s) } _ { none::<~str> } }; } @@ -395,8 +395,8 @@ 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 { ret none::<~str>; } - ret alt vals[0] { val(s) { some::<~str>(s) } _ { some::<~str>(def) } } + if vec::len::<optval>(vals) == 0u { return none::<~str>; } + return alt vals[0] { val(s) { some::<~str>(s) } _ { some::<~str>(def) } } } #[cfg(test)] diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 6a08bb5d9e1..f2c2a616ede 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -68,7 +68,7 @@ fn to_writer(wr: io::writer, j: json) { dict(d) { if d.size() == 0u { wr.write_str(~"{}"); - ret; + return; } wr.write_str(~"{ "); @@ -168,7 +168,7 @@ impl parser for parser { fn parse_value() -> result<json, error> { self.parse_whitespace(); - if self.eof() { ret self.error(~"EOF while parsing value"); } + if self.eof() { return self.error(~"EOF while parsing value"); } alt self.ch { 'n' { self.parse_ident(~"ull", null) } @@ -210,20 +210,20 @@ impl parser for parser { let mut res = alt self.parse_integer() { ok(res) { res } - err(e) { ret err(e); } + err(e) { return err(e); } }; if self.ch == '.' { alt self.parse_decimal(res) { ok(r) { res = r; } - err(e) { ret err(e); } + err(e) { return err(e); } } } if self.ch == 'e' || self.ch == 'E' { alt self.parse_exponent(res) { ok(r) { res = r; } - err(e) { ret err(e); } + err(e) { return err(e); } } } @@ -239,7 +239,7 @@ impl parser for parser { // There can be only one leading '0'. alt self.ch { - '0' to '9' { ret self.error(~"invalid number"); } + '0' to '9' { return self.error(~"invalid number"); } _ {} } } @@ -256,7 +256,7 @@ impl parser for parser { } } } - _ { ret self.error(~"invalid number"); } + _ { return self.error(~"invalid number"); } } ok(res) @@ -268,7 +268,7 @@ impl parser for parser { // Make sure a digit follows the decimal place. alt self.ch { '0' to '9' {} - _ { ret self.error(~"invalid number"); } + _ { return self.error(~"invalid number"); } } let mut res = res; @@ -304,7 +304,7 @@ impl parser for parser { // Make sure a digit follows the exponent place. alt self.ch { '0' to '9' {} - _ { ret self.error(~"invalid number"); } + _ { return self.error(~"invalid number"); } } while !self.eof() { @@ -356,19 +356,19 @@ impl parser for parser { n = n * 10u + (self.ch as uint) - ('0' as uint); } - _ { ret self.error(~"invalid \\u escape"); } + _ { return self.error(~"invalid \\u escape"); } } i += 1u; } // Error out if we didn't parse 4 digits. if i != 4u { - ret self.error(~"invalid \\u escape"); + return self.error(~"invalid \\u escape"); } str::push_char(res, n as char); } - _ { ret self.error(~"invalid escape"); } + _ { return self.error(~"invalid escape"); } } escape = false; } else if self.ch == '\\' { @@ -376,7 +376,7 @@ impl parser for parser { } else { if self.ch == '"' { self.bump(); - ret ok(@res); + return ok(@res); } str::push_char(res, self.ch); } @@ -393,24 +393,24 @@ impl parser for parser { if self.ch == ']' { self.bump(); - ret ok(list(@values)); + return ok(list(@values)); } loop { alt self.parse_value() { ok(v) { vec::push(values, v); } - e { ret e; } + e { return e; } } self.parse_whitespace(); if self.eof() { - ret self.error(~"EOF while parsing list"); + return self.error(~"EOF while parsing list"); } alt self.ch { ',' { self.bump(); } - ']' { self.bump(); ret ok(list(@values)); } - _ { ret self.error(~"expected `,` or `]`"); } + ']' { self.bump(); return ok(list(@values)); } + _ { return self.error(~"expected `,` or `]`"); } } }; } @@ -423,46 +423,46 @@ impl parser for parser { if self.ch == '}' { self.bump(); - ret ok(dict(values)); + return ok(dict(values)); } while !self.eof() { self.parse_whitespace(); if self.ch != '"' { - ret self.error(~"key must be a string"); + return self.error(~"key must be a string"); } let key = alt self.parse_str() { ok(key) { key } - err(e) { ret err(e); } + err(e) { return err(e); } }; self.parse_whitespace(); if self.ch != ':' { if self.eof() { break; } - ret self.error(~"expected `:`"); + return self.error(~"expected `:`"); } self.bump(); alt self.parse_value() { ok(value) { values.insert(copy *key, value); } - e { ret e; } + e { return e; } } self.parse_whitespace(); alt self.ch { ',' { self.bump(); } - '}' { self.bump(); ret ok(dict(values)); } + '}' { self.bump(); return ok(dict(values)); } _ { if self.eof() { break; } - ret self.error(~"expected `,` or `}`"); + return self.error(~"expected `,` or `}`"); } } } - ret self.error(~"EOF while parsing object"); + return self.error(~"EOF while parsing object"); } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index b8da3dcc38f..019c9cce632 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -45,10 +45,10 @@ fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> option<T> { loop { ls = alt *ls { cons(hd, tl) { - if f(hd) { ret some(hd); } + if f(hd) { return some(hd); } tl } - nil { ret none; } + nil { return none; } } }; } @@ -56,9 +56,9 @@ fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> option<T> { /// Returns true if a list contains an element with the given value fn has<T: copy>(ls: @list<T>, elt: T) -> bool { for each(ls) |e| { - if e == elt { ret true; } + if e == elt { return true; } } - ret false; + return false; } /// Returns true if the list is empty @@ -71,7 +71,7 @@ pure fn is_empty<T: copy>(ls: @list<T>) -> bool { /// Returns true if the list is not empty pure fn is_not_empty<T: copy>(ls: @list<T>) -> bool { - ret !is_empty(ls); + return !is_empty(ls); } /// Returns the length of a list @@ -84,7 +84,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 { - cons(_, tl) { ret tl; } + cons(_, tl) { return tl; } nil { fail ~"list empty" } } } @@ -97,8 +97,8 @@ pure fn head<T: copy>(ls: @list<T>) -> T { /// Appends one list to another pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T> { alt *l { - nil { ret m; } - cons(x, xs) { let rest = append(xs, m); ret @cons(x, rest); } + nil { return m; } + cons(x, xs) { let rest = append(xs, m); return @cons(x, rest); } } } @@ -127,7 +127,7 @@ fn each<T>(l: @list<T>, f: fn(T) -> bool) { loop { cur = alt *cur { cons(hd, tl) { - if !f(hd) { ret; } + if !f(hd) { return; } tl } nil { break; } @@ -174,7 +174,7 @@ mod tests { #[test] fn test_foldl() { - fn add(&&a: uint, &&b: int) -> uint { ret a + (b as uint); } + fn add(&&a: uint, &&b: int) -> uint { return a + (b as uint); } let l = from_vec(~[0, 1, 2, 3, 4]); let empty = @list::nil::<int>; assert (list::foldl(0u, l, add) == 10u); @@ -192,14 +192,14 @@ mod tests { #[test] fn test_find_success() { - fn match_(&&i: int) -> bool { ret i == 2; } + fn match_(&&i: int) -> bool { return i == 2; } let l = from_vec(~[0, 1, 2]); assert (list::find(l, match_) == option::some(2)); } #[test] fn test_find_fail() { - fn match_(&&_i: int) -> bool { ret false; } + fn match_(&&_i: int) -> bool { return false; } let l = from_vec(~[0, 1, 2]); let empty = @list::nil::<int>; assert (list::find(l, match_) == option::none::<int>); diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 846a2bfc700..eb5c8cc95ab 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -124,7 +124,7 @@ mod chained { absent { debug!{"search_tbl: absent, comp %u, hash %u, idx %u", comp, h, idx}; - ret not_found; + return not_found; } present(e1) { comp += 1u; @@ -132,7 +132,7 @@ mod chained { debug!{"search_tbl: present, comp %u, \ hash %u, idx %u", comp, h, idx}; - ret found_after(e0, e1); + return found_after(e0, e1); } else { e0 = e1; } @@ -147,15 +147,15 @@ mod chained { absent { debug!{"search_tbl: absent, comp %u, hash %u, idx %u", 0u, h, idx}; - ret not_found; + return not_found; } present(e) { if e.hash == h && self.eqer(e.key, k) { debug!{"search_tbl: present, comp %u, hash %u, idx %u", 1u, h, idx}; - ret found_first(idx, e); + return found_first(idx, e); } else { - ret self.search_rem(k, h, idx, e); + return self.search_rem(k, h, idx, e); } } } @@ -182,7 +182,7 @@ mod chained { absent { break; } present(entry) { let next = entry.next; - if !blk(entry) { ret; } + if !blk(entry) { return; } next } } @@ -224,15 +224,15 @@ mod chained { self.rehash(); } - ret true; + return true; } found_first(_, entry) { entry.value = v; - ret false; + return false; } found_after(_, entry) { entry.value = v; - ret false + return false } } } @@ -292,7 +292,7 @@ mod chained { fn to_writer(wr: io::writer) { if self.count == 0u { wr.write_str("{}"); - ret; + return; } wr.write_str("{ "); @@ -324,7 +324,7 @@ mod chained { fn chains<K,V>(nchains: uint) -> ~[mut chain<K,V>] { - ret vec::to_mut(vec::from_elem(nchains, absent)); + return vec::to_mut(vec::from_elem(nchains, absent)); } fn mk<K, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) -> t<K,V> { @@ -353,32 +353,32 @@ fn hashmap<K: const, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) /// Construct a hashmap for string keys fn str_hash<V: copy>() -> hashmap<~str, V> { - ret hashmap(str::hash, str::eq); + return hashmap(str::hash, str::eq); } /// Construct a hashmap for boxed string keys fn box_str_hash<V: copy>() -> hashmap<@~str, V> { - ret hashmap(|x: @~str| str::hash(*x), |x,y| str::eq(*x,*y)); + return hashmap(|x: @~str| str::hash(*x), |x,y| str::eq(*x,*y)); } /// Construct a hashmap for byte string keys fn bytes_hash<V: copy>() -> hashmap<~[u8], V> { - ret hashmap(vec::u8::hash, vec::u8::eq); + return hashmap(vec::u8::hash, vec::u8::eq); } /// Construct a hashmap for int keys fn int_hash<V: copy>() -> hashmap<int, V> { - ret hashmap(int::hash, int::eq); + return hashmap(int::hash, int::eq); } /// Construct a hashmap for uint keys fn uint_hash<V: copy>() -> hashmap<uint, V> { - ret hashmap(uint::hash, uint::eq); + return hashmap(uint::hash, uint::eq); } /// Convenience function for adding keys to a hashmap with nil type keys fn set_add<K: const copy>(set: set<K>, key: K) -> bool { - ret set.insert(key, ()); + return set.insert(key, ()); } /// Convert a set into a vector. @@ -428,7 +428,7 @@ mod tests { #[test] fn test_simple() { debug!{"*** starting test_simple"}; - fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } + fn eq_uint(&&x: uint, &&y: uint) -> bool { return x == y; } fn uint_id(&&x: uint) -> uint { x } let hasher_uint: map::hashfn<uint> = uint_id; let eqer_uint: map::eqfn<uint> = eq_uint; @@ -501,7 +501,7 @@ mod tests { fn test_growth() { debug!{"*** starting test_growth"}; let num_to_insert: uint = 64u; - fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } + fn eq_uint(&&x: uint, &&y: uint) -> bool { return x == y; } fn uint_id(&&x: uint) -> uint { x } debug!{"uint -> uint"}; let hasher_uint: map::hashfn<uint> = uint_id; @@ -574,12 +574,12 @@ mod tests { fn test_removal() { debug!{"*** starting test_removal"}; let num_to_insert: uint = 64u; - fn eq(&&x: uint, &&y: uint) -> bool { ret x == y; } + fn eq(&&x: uint, &&y: uint) -> bool { return x == y; } fn hash(&&u: uint) -> uint { // This hash function intentionally causes collisions between // consecutive integer pairs. - ret u / 2u * 2u; + return u / 2u * 2u; } assert (hash(0u) == hash(1u)); assert (hash(2u) == hash(3u)); diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 134091dfd1d..2c22d18440a 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -79,7 +79,7 @@ fn md4(msg: ~[u8]) -> {a: u32, b: u32, c: u32, d: u32} { a += aa; b += bb; c += cc; d += dd; i += 64u; } - ret {a: a, b: b, c: c, d: d}; + return {a: a, b: b, c: c, d: d}; } fn md4_str(msg: ~[u8]) -> ~str { diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 38b6d6194eb..cb77f72038a 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -183,7 +183,7 @@ mod v4 { let ip_rep_result = parse_to_ipv4_rep(ip); if result::is_err(ip_rep_result) { let err_str = result::get_err(ip_rep_result); - ret result::err({err_msg: err_str}) + return result::err({err_msg: err_str}) } // ipv4_rep.as_u32 is unsafe :/ let input_is_inaddr_none = @@ -196,11 +196,11 @@ mod v4 { let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name); if result::is_err(ref_ip_rep_result) { let err_str = result::get_err(ref_ip_rep_result); - ret result::err({err_msg: err_str}) + return result::err({err_msg: err_str}) } if result::get(ref_ip_rep_result).as_u32() == INADDR_NONE && !input_is_inaddr_none { - ret result::err( + return result::err( {err_msg: ~"uv_ip4_name produced invalid result."}) } else { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 8bf35c8ee16..2cacd9de475 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -779,7 +779,7 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf { debug!{"ERROR sock_buf as io::reader.read err %? %?", err_data.err_name, err_data.err_msg}; - ret 0; + return 0; } } else { @@ -1581,7 +1581,7 @@ mod test { } } let ret_val = server_ch.recv(); - log(debug, fmt!{"SERVER: exited and got ret val: '%s'", ret_val}); + log(debug, fmt!{"SERVER: exited and got return val: '%s'", ret_val}); ret_val } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 928f8bc9399..5f77e7d414f 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -31,9 +31,9 @@ fn userinfo(-user: ~str, -pass: option<~str>) -> userinfo { fn split_char_first(s: ~str, c: char) -> (~str, ~str) { let mut v = str::splitn_char(s, c, 1); if v.len() == 1 { - ret (s, ~""); + return (s, ~""); } else { - ret (vec::shift(v), vec::pop(v)); + return (vec::shift(v), vec::pop(v)); } } @@ -44,16 +44,16 @@ fn userinfo_from_str(uinfo: ~str) -> userinfo { } else { option::some(p) }; - ret userinfo(user, pass); + return userinfo(user, pass); } fn userinfo_to_str(-userinfo: userinfo) -> ~str { if option::is_some(userinfo.pass) { - ret str::concat(~[copy userinfo.user, ~":", + return str::concat(~[copy userinfo.user, ~":", option::unwrap(copy userinfo.pass), ~"@"]); } else { - ret str::concat(~[copy userinfo.user, ~"@"]); + return str::concat(~[copy userinfo.user, ~"@"]); } } @@ -65,7 +65,7 @@ fn query_from_str(rawquery: ~str) -> query { vec::push(query, (k, v)); }; } - ret query; + return query; } fn query_to_str(query: query) -> ~str { @@ -74,7 +74,7 @@ fn query_to_str(query: query) -> ~str { let (k, v) = kv; strvec += ~[fmt!{"%s=%s", k, v}]; }; - ret str::connect(strvec, ~"&"); + return str::connect(strvec, ~"&"); } fn get_scheme(rawurl: ~str) -> option::option<(~str, ~str)> { @@ -82,13 +82,13 @@ fn get_scheme(rawurl: ~str) -> option::option<(~str, ~str)> { if char::is_alphabetic(c) { again; } else if c == ':' && i != 0 { - ret option::some((rawurl.slice(0,i), + return option::some((rawurl.slice(0,i), rawurl.slice(i+3,str::len(rawurl)))); } else { - ret option::none; + return option::none; } }; - ret option::none; + return option::none; } /** @@ -107,7 +107,7 @@ fn get_scheme(rawurl: ~str) -> option::option<(~str, ~str)> { fn from_str(rawurl: ~str) -> result::result<url, ~str> { let mut schm = get_scheme(rawurl); if option::is_none(schm) { - ret result::err(~"invalid scheme"); + return result::err(~"invalid scheme"); } let (scheme, rest) = option::unwrap(schm); let (u, rest) = split_char_first(rest, '@'); @@ -135,7 +135,7 @@ fn from_str(rawurl: ~str) -> result::result<url, ~str> { str::unshift_char(path, '/'); } - ret result::ok(url(scheme, user, host, path, query, fragment)); + return result::ok(url(scheme, user, host, path, query, fragment)); } /** @@ -170,7 +170,7 @@ fn to_str(url: url) -> ~str { ~"" }; - ret str::concat(~[copy url.scheme, + return str::concat(~[copy url.scheme, ~"://", user, copy url.host, diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index e9568a13df0..8debc45a0e9 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -33,7 +33,7 @@ type rope = node::root; /// Create an empty rope fn empty() -> rope { - ret node::empty; + return node::empty; } /** @@ -54,7 +54,7 @@ fn empty() -> rope { * * the function runs in linear time. */ fn of_str(str: @~str) -> rope { - ret of_substr(str, 0u, str::len(*str)); + return of_substr(str, 0u, str::len(*str)); } /** @@ -80,9 +80,9 @@ fn of_str(str: @~str) -> rope { * * this function fails if `byte_offset` or `byte_len` do not match `str`. */ fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> rope { - if byte_len == 0u { ret node::empty; } + if byte_len == 0u { return node::empty; } if byte_offset + byte_len > str::len(*str) { fail; } - ret node::content(node::of_substr(str, byte_offset, byte_len)); + return node::content(node::of_substr(str, byte_offset, byte_len)); } /* @@ -97,7 +97,7 @@ Section: Adding things to a rope * * this function executes in near-constant time */ fn append_char(rope: rope, char: char) -> rope { - ret append_str(rope, @str::from_chars(~[char])); + return append_str(rope, @str::from_chars(~[char])); } /** @@ -108,7 +108,7 @@ fn append_char(rope: rope, char: char) -> rope { * * this function executes in near-linear time */ fn append_str(rope: rope, str: @~str) -> rope { - ret append_rope(rope, of_str(str)) + return append_rope(rope, of_str(str)) } /** @@ -118,7 +118,7 @@ fn append_str(rope: rope, str: @~str) -> rope { * * this function executes in near-constant time */ fn prepend_char(rope: rope, char: char) -> rope { - ret prepend_str(rope, @str::from_chars(~[char])); + return prepend_str(rope, @str::from_chars(~[char])); } /** @@ -128,18 +128,18 @@ fn prepend_char(rope: rope, char: char) -> rope { * * this function executes in near-linear time */ fn prepend_str(rope: rope, str: @~str) -> rope { - ret append_rope(of_str(str), rope) + return append_rope(of_str(str), rope) } /// Concatenate two ropes fn append_rope(left: rope, right: rope) -> rope { alt(left) { - node::empty { ret right; } + node::empty { return right; } node::content(left_content) { alt(right) { - node::empty { ret left; } + node::empty { return left; } node::content(right_content) { - ret node::content(node::concat2(left_content, right_content)); + return node::content(node::concat2(left_content, right_content)); } } } @@ -156,7 +156,7 @@ fn append_rope(left: rope, right: rope) -> rope { fn concat(v: ~[rope]) -> rope { //Copy `v` into a mut vector let mut len = vec::len(v); - if len == 0u { ret node::empty; } + if len == 0u { return node::empty; } let ropes = vec::to_mut(vec::from_elem(len, v[0])); for uint::range(1u, len) |i| { ropes[i] = v[i]; @@ -176,7 +176,7 @@ fn concat(v: ~[rope]) -> rope { } //Return final rope - ret ropes[0]; + return ropes[0]; } @@ -198,7 +198,7 @@ Section: Keeping ropes healthy */ fn bal(rope:rope) -> rope { alt(rope) { - node::empty { ret rope } + node::empty { return rope } node::content(x) { alt(node::bal(x)) { option::none { rope } @@ -227,13 +227,13 @@ Section: Transforming ropes * valid positions in rope */ fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope { - if char_len == 0u { ret node::empty; } + if char_len == 0u { return node::empty; } alt(rope) { node::empty { fail } node::content(node) { if char_len > node::char_len(node) { fail } else { - ret node::content(node::sub_chars(node, char_offset, char_len)) + return node::content(node::sub_chars(node, char_offset, char_len)) } } } @@ -253,13 +253,13 @@ fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope { * valid positions in rope */ fn sub_bytes(rope: rope, byte_offset: uint, byte_len: uint) -> rope { - if byte_len == 0u { ret node::empty; } + if byte_len == 0u { return node::empty; } alt(rope) { node::empty { fail } node::content(node) { if byte_len > node::byte_len(node) { fail } else { - ret node::content(node::sub_bytes(node, byte_offset, byte_len)) + return node::content(node::sub_bytes(node, byte_offset, byte_len)) } } } @@ -281,11 +281,11 @@ Section: Comparing ropes */ fn cmp(left: rope, right: rope) -> int { alt((left, right)) { - (node::empty, node::empty) { ret 0; } - (node::empty, _) { ret -1;} - (_, node::empty) { ret 1;} + (node::empty, node::empty) { return 0; } + (node::empty, _) { return -1;} + (_, node::empty) { return 1;} (node::content(a), node::content(b)) { - ret node::cmp(a, b); + return node::cmp(a, b); } } } @@ -295,7 +295,7 @@ fn cmp(left: rope, right: rope) -> int { * their structure), `false` otherwise */ fn eq(left: rope, right: rope) -> bool { - ret cmp(left, right) == 0; + return cmp(left, right) == 0; } /** @@ -310,7 +310,7 @@ fn eq(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn le(left: rope, right: rope) -> bool { - ret cmp(left, right) <= 0; + return cmp(left, right) <= 0; } /** @@ -325,7 +325,7 @@ fn le(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn lt(left: rope, right: rope) -> bool { - ret cmp(left, right) < 0; + return cmp(left, right) < 0; } /** @@ -340,7 +340,7 @@ fn lt(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn ge(left: rope, right: rope) -> bool { - ret cmp(left, right) >= 0; + return cmp(left, right) >= 0; } /** @@ -355,7 +355,7 @@ fn ge(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn gt(left: rope, right: rope) -> bool { - ret cmp(left, right) > 0; + return cmp(left, right) > 0; } /* @@ -384,8 +384,8 @@ Section: Iterating */ fn loop_chars(rope: rope, it: fn(char) -> bool) -> bool { alt(rope) { - node::empty { ret true } - node::content(x) { ret node::loop_chars(x, it) } + node::empty { return true } + node::content(x) { return node::loop_chars(x, it) } } } @@ -427,8 +427,8 @@ fn iter_chars(rope: rope, it: fn(char)) { */ fn loop_leaves(rope: rope, it: fn(node::leaf) -> bool) -> bool{ alt(rope) { - node::empty { ret true } - node::content(x) {ret node::loop_leaves(x, it)} + node::empty { return true } + node::content(x) {return node::loop_leaves(x, it)} } } @@ -436,23 +436,23 @@ mod iterator { mod leaf { fn start(rope: rope) -> node::leaf_iterator::t { alt(rope) { - node::empty { ret node::leaf_iterator::empty() } - node::content(x) { ret node::leaf_iterator::start(x) } + node::empty { return node::leaf_iterator::empty() } + node::content(x) { return node::leaf_iterator::start(x) } } } fn next(it: node::leaf_iterator::t) -> option<node::leaf> { - ret node::leaf_iterator::next(it); + return node::leaf_iterator::next(it); } } mod char { fn start(rope: rope) -> node::char_iterator::t { alt(rope) { - node::empty { ret node::char_iterator::empty() } - node::content(x) { ret node::char_iterator::start(x) } + node::empty { return node::char_iterator::empty() } + node::content(x) { return node::char_iterator::start(x) } } } fn next(it: node::char_iterator::t) -> option<char> { - ret node::char_iterator::next(it) + return node::char_iterator::next(it) } } } @@ -474,8 +474,8 @@ mod iterator { */ fn height(rope: rope) -> uint { alt(rope) { - node::empty { ret 0u; } - node::content(x) { ret node::height(x); } + node::empty { return 0u; } + node::content(x) { return node::height(x); } } } @@ -490,8 +490,8 @@ fn height(rope: rope) -> uint { */ pure fn char_len(rope: rope) -> uint { alt(rope) { - node::empty { ret 0u; } - node::content(x) { ret node::char_len(x) } + node::empty { return 0u; } + node::content(x) { return node::char_len(x) } } } @@ -504,8 +504,8 @@ pure fn char_len(rope: rope) -> uint { */ pure fn byte_len(rope: rope) -> uint { alt(rope) { - node::empty { ret 0u; } - node::content(x) { ret node::byte_len(x) } + node::empty { return 0u; } + node::content(x) { return node::byte_len(x) } } } @@ -528,7 +528,7 @@ pure fn byte_len(rope: rope) -> uint { fn char_at(rope: rope, pos: uint) -> char { alt(rope) { node::empty { fail } - node::content(x) { ret node::char_at(x, pos) } + node::content(x) { return node::char_at(x, pos) } } } @@ -628,7 +628,7 @@ mod node { * the length of `str`. */ fn of_str(str: @~str) -> @node { - ret of_substr(str, 0u, str::len(*str)); + return of_substr(str, 0u, str::len(*str)); } /** @@ -649,7 +649,7 @@ mod node { * valid positions in `str` */ fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @node { - ret of_substr_unsafer(str, byte_start, byte_len, + return of_substr_unsafer(str, byte_start, byte_len, str::count_chars(*str, byte_start, byte_len)); } @@ -683,7 +683,7 @@ mod node { char_len: char_len, content: str}); if char_len <= hint_max_leaf_char_len { - ret candidate; + return candidate; } else { //Firstly, split `str` in slices of hint_max_leaf_char_len let mut leaves = uint::div_ceil(char_len, hint_max_leaf_char_len); @@ -728,22 +728,22 @@ mod node { } leaves = uint::div_ceil(leaves, 2u); } - ret nodes[0u]; + return nodes[0u]; } } pure fn byte_len(node: @node) -> uint { //FIXME (#2744): Could we do this without the pattern-matching? alt(*node) { - leaf(y) { ret y.byte_len; } - concat(y){ ret y.byte_len; } + leaf(y) { return y.byte_len; } + concat(y){ return y.byte_len; } } } pure fn char_len(node: @node) -> uint { alt(*node) { - leaf(y) { ret y.char_len; } - concat(y) { ret y.char_len; } + leaf(y) { return y.char_len; } + concat(y) { return y.char_len; } } } @@ -796,7 +796,7 @@ mod node { } len = uint::div_ceil(len, 2u); } - ret forest[0]; + return forest[0]; } fn serialize_node(node: @node) -> ~str unsafe { @@ -820,7 +820,7 @@ mod node { } } } - ret unsafe::transmute(buf); + return unsafe::transmute(buf); } /** @@ -832,9 +832,9 @@ mod node { */ fn flatten(node: @node) -> @node unsafe { alt(*node) { - leaf(_) { ret node } + leaf(_) { return node } concat(x) { - ret @leaf({ + return @leaf({ byte_offset: 0u, byte_len: x.byte_len, char_len: x.char_len, @@ -860,7 +860,7 @@ mod node { * as `node` bot lower height and/or fragmentation. */ fn bal(node: @node) -> option<@node> { - if height(node) < hint_max_node_height { ret option::none; } + if height(node) < hint_max_node_height { return option::none; } //1. Gather all leaves as a forest let mut forest = ~[mut]; let it = leaf_iterator::start(node); @@ -872,7 +872,7 @@ mod node { } //2. Rebuild tree from forest let root = @*tree_from_forest_destructive(forest); - ret option::some(root); + return option::some(root); } @@ -900,13 +900,13 @@ mod node { let mut byte_offset = byte_offset; loop { if byte_offset == 0u && byte_len == node::byte_len(node) { - ret node; + return node; } alt(*node) { node::leaf(x) { let char_len = str::count_chars(*x.content, byte_offset, byte_len); - ret @leaf({byte_offset: byte_offset, + return @leaf({byte_offset: byte_offset, byte_len: byte_len, char_len: char_len, content: x.content}); @@ -925,7 +925,7 @@ mod node { sub_bytes(x.left, byte_offset, left_len); let right_result = sub_bytes(x.right, 0u, left_len - byte_offset); - ret concat2(left_result, right_result); + return concat2(left_result, right_result); } } else { //Case 3: Everything fits in x.right @@ -963,19 +963,19 @@ mod node { alt(*node) { node::leaf(x) { if char_offset == 0u && char_len == x.char_len { - ret node; + return node; } let byte_offset = str::count_bytes(*x.content, 0u, char_offset); let byte_len = str::count_bytes(*x.content, byte_offset, char_len); - ret @leaf({byte_offset: byte_offset, + return @leaf({byte_offset: byte_offset, byte_len: byte_len, char_len: char_len, content: x.content}); } node::concat(x) { - if char_offset == 0u && char_len == x.char_len {ret node;} + if char_offset == 0u && char_len == x.char_len {return node;} let left_len : uint = node::char_len(x.left); if char_offset <= left_len { if char_offset + char_len <= left_len { @@ -989,7 +989,7 @@ mod node { sub_chars(x.left, char_offset, left_len); let right_result = sub_chars(x.right, 0u, left_len - char_offset); - ret concat2(left_result, right_result); + return concat2(left_result, right_result); } } else { //Case 3: Everything fits in x.right, tail call @@ -1002,7 +1002,7 @@ mod node { } fn concat2(left: @node, right: @node) -> @node { - ret @concat({left : left, + return @concat({left : left, right : right, char_len: char_len(left) + char_len(right), byte_len: byte_len(left) + byte_len(right), @@ -1012,8 +1012,8 @@ mod node { fn height(node: @node) -> uint { alt(*node) { - leaf(_) { ret 0u; } - concat(x) { ret x.height; } + leaf(_) { return 0u; } + concat(x) { return x.height; } } } @@ -1037,11 +1037,11 @@ mod node { } } } - ret result; + return result; } fn loop_chars(node: @node, it: fn(char) -> bool) -> bool { - ret loop_leaves(node,|leaf| { + return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, leaf.byte_len, it) @@ -1067,13 +1067,13 @@ mod node { loop { alt(*current) { leaf(x) { - ret it(x); + return it(x); } concat(x) { if loop_leaves(x.left, it) { //non tail call current = x.right; //tail call } else { - ret false; + return false; } } } @@ -1103,7 +1103,7 @@ mod node { loop { alt *node { leaf(x) { - ret str::char_at(*x.content, pos); + return str::char_at(*x.content, pos); } concat({left, right, _}) { let left_len = char_len(left); @@ -1122,19 +1122,19 @@ mod node { fn empty() -> t { let stack : ~[mut @node] = ~[mut]; - ret {stack: stack, mut stackpos: -1} + return {stack: stack, mut stackpos: -1} } fn start(node: @node) -> t { let stack = vec::to_mut(vec::from_elem(height(node)+1u, node)); - ret { + return { stack: stack, mut stackpos: 0 } } fn next(it: t) -> option<leaf> { - if it.stackpos < 0 { ret option::none; } + if it.stackpos < 0 { return option::none; } loop { let current = it.stack[it.stackpos]; it.stackpos -= 1; @@ -1146,7 +1146,7 @@ mod node { it.stack[it.stackpos] = x.left; } leaf(x) { - ret option::some(x); + return option::some(x); } } }; @@ -1161,7 +1161,7 @@ mod node { }; fn start(node: @node) -> t { - ret { + return { leaf_iterator: leaf_iterator::start(node), mut leaf: option::none, mut leaf_byte_pos: 0u @@ -1169,7 +1169,7 @@ mod node { } fn empty() -> t { - ret { + return { leaf_iterator: leaf_iterator::empty(), mut leaf: option::none, mut leaf_byte_pos: 0u @@ -1179,7 +1179,7 @@ mod node { fn next(it: t) -> option<char> { loop { alt(get_current_or_next_leaf(it)) { - option::none { ret option::none; } + option::none { return option::none; } option::some(_) { let next_char = get_next_char_in_leaf(it); alt(next_char) { @@ -1187,7 +1187,7 @@ mod node { again; } option::some(_) { - ret next_char; + return next_char; } } } @@ -1197,15 +1197,15 @@ mod node { fn get_current_or_next_leaf(it: t) -> option<leaf> { alt(it.leaf) { - option::some(_) { ret it.leaf } + option::some(_) { return it.leaf } option::none { let next = leaf_iterator::next(it.leaf_iterator); alt(next) { - option::none { ret option::none } + option::none { return option::none } option::some(_) { it.leaf = next; it.leaf_byte_pos = 0u; - ret next; + return next; } } } @@ -1214,18 +1214,18 @@ mod node { fn get_next_char_in_leaf(it: t) -> option<char> { alt copy it.leaf { - option::none { ret option::none } + option::none { return option::none } option::some(aleaf) { if it.leaf_byte_pos >= aleaf.byte_len { //We are actually past the end of the leaf it.leaf = option::none; - ret option::none + return option::none } else { let {ch, next} = str::char_range_at(*aleaf.content, it.leaf_byte_pos + aleaf.byte_offset); it.leaf_byte_pos = next - aleaf.byte_offset; - ret option::some(ch) + return option::some(ch) } } } @@ -1239,7 +1239,7 @@ mod tests { //Utility function, used for sanity check fn rope_to_string(r: rope) -> ~str { alt(r) { - node::empty { ret ~"" } + node::empty { return ~"" } node::content(x) { let str = @mut ~""; fn aux(str: @mut ~str, node: @node::node) unsafe { @@ -1256,7 +1256,7 @@ mod tests { } } aux(str, x); - ret *str + return *str } } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index eef757f4516..14410eed636 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -155,7 +155,7 @@ fn sha1() -> sha1 { st.msg_block_idx = 0u; } fn circular_shift(bits: u32, word: u32) -> u32 { - ret word << bits | word >> 32u32 - bits; + return word << bits | word >> 32u32 - bits; } fn mk_result(st: sha1state) -> ~[u8] { if !st.computed { pad_msg(st); st.computed = true; } @@ -167,7 +167,7 @@ fn sha1() -> sha1 { let d = (hpart & 0xFFu32) as u8; rs = vec::append(rs, ~[a, b, c, d]); } - ret rs; + return rs; } /* @@ -233,12 +233,12 @@ fn sha1() -> sha1 { } fn input(msg: ~[u8]) { add_input(self, msg); } fn input_str(msg: ~str) { add_input(self, str::bytes(msg)); } - fn result() -> ~[u8] { ret mk_result(self); } + fn result() -> ~[u8] { return mk_result(self); } fn result_str() -> ~str { let r = mk_result(self); let mut s = ~""; for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); } - ret s; + return s; } } let st = { @@ -252,7 +252,7 @@ fn sha1() -> sha1 { }; let sh = st as sha1; sh.reset(); - ret sh; + return sh; } #[cfg(test)] @@ -266,7 +266,7 @@ mod tests { let mut i = 0; let mut rs = ~""; while i < 100000 { str::push_str(rs, ~"aaaaaaaaaa"); i += 1; } - ret rs; + return rs; } // Test messages from FIPS 180-1 diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 37f829396ab..825630cf4a4 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -18,7 +18,7 @@ enum smallintmap<T:copy> { /// Create a smallintmap fn mk<T: copy>() -> smallintmap<T> { let v = dvec(); - ret smallintmap_(@{v: v}); + return smallintmap_(@{v: v}); } /** @@ -36,8 +36,8 @@ fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) { * in the map then returns none */ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> { - if key < self.v.len() { ret self.v.get_elt(key); } - ret none::<T>; + if key < self.v.len() { return self.v.get_elt(key); } + return none::<T>; } /** @@ -50,13 +50,13 @@ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> { pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T { alt find(self, key) { none { error!{"smallintmap::get(): key not present"}; fail; } - some(v) { ret v; } + some(v) { return v; } } } /// Returns true if the map contains a value for the specified key fn contains_key<T: copy>(self: smallintmap<T>, key: uint) -> bool { - ret !option::is_none(find(self, key)); + return !option::is_none(find(self, key)); } /// Implements the map::map interface for smallintmap @@ -72,10 +72,10 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn insert(+key: uint, +value: V) -> bool { let exists = contains_key(self, key); insert(self, key, value); - ret !exists; + return !exists; } fn remove(&&key: uint) -> option<V> { - if key >= self.v.len() { ret none; } + if key >= self.v.len() { return none; } let old = self.v.get_elt(key); self.v.set_elt(key, none); old @@ -105,7 +105,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn each_key(it: fn(&&uint) -> bool) { let mut idx = 0u, l = self.v.len(); while idx < l { - if self.v.get_elt(idx) != none && !it(idx) { ret; } + if self.v.get_elt(idx) != none && !it(idx) { return; } idx += 1u; } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 95dbf5f97dc..84aa3c26482 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -18,7 +18,7 @@ type le<T> = fn(T, T) -> bool; fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { type slice = (uint, uint); - ret merge_sort_(le, v, (0u, len(v))); + return merge_sort_(le, v, (0u, len(v))); fn merge_sort_<T: copy>(le: le<T>, v: ~[const T], slice: slice) -> ~[T] { @@ -26,13 +26,13 @@ fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { let end = slice.second(); let v_len = end - begin; - if v_len == 0u { ret ~[]; } - if v_len == 1u { ret ~[v[begin]]; } + if v_len == 0u { return ~[]; } + if v_len == 1u { return ~[v[begin]]; } let mid = v_len / 2u + begin; let a = (begin, mid); let b = (mid, end); - ret merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); + return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); } fn merge<T: copy>(le: le<T>, a: ~[T], b: ~[T]) -> ~[T] { @@ -50,7 +50,7 @@ fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { } rs = vec::append(rs, vec::slice(a, a_ix, a_len)); rs = vec::append(rs, vec::slice(b, b_ix, b_len)); - ret rs; + return rs; } } @@ -68,7 +68,7 @@ fn part<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, i += 1u; } arr[storage_index] <-> arr[right]; - ret storage_index; + return storage_index; } fn qsort<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, @@ -91,13 +91,13 @@ fn qsort<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, * This is an unstable sort. */ fn quick_sort<T: copy>(compare_func: le<T>, arr: ~[mut T]) { - if len::<T>(arr) == 0u { ret; } + if len::<T>(arr) == 0u { return; } qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u); } fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>, arr: ~[mut T], left: int, right: int) { - if right <= left { ret; } + if right <= left { return; } let v: T = arr[right]; let mut i: int = left - 1; let mut j: int = right; @@ -154,7 +154,7 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>, * This is an unstable sort. */ fn quick_sort3<T: copy ord eq>(arr: ~[mut T]) { - if len::<T>(arr) == 0u { ret; } + if len::<T>(arr) == 0u { return; } qsort3::<T>(|x, y| x.lt(y), |x, y| x.eq(y), arr, 0, (len::<T>(arr) as int) - 1); } @@ -202,7 +202,7 @@ mod test_qsort3 { mod test_qsort { fn check_sort(v1: ~[mut int], v2: ~[mut int]) { let len = vec::len::<int>(v1); - fn leual(&&a: int, &&b: int) -> bool { ret a <= b; } + fn leual(&&a: int, &&b: int) -> bool { return a <= b; } let f = leual; quick_sort::<int>(f, v1); let mut i = 0u; @@ -264,7 +264,7 @@ mod tests { fn check_sort(v1: ~[int], v2: ~[int]) { let len = vec::len::<int>(v1); - fn le(&&a: int, &&b: int) -> bool { ret a <= b; } + fn le(&&a: int, &&b: int) -> bool { return a <= b; } let f = le; let v3 = merge_sort::<int>(f, v1); let mut i = 0u; @@ -294,7 +294,7 @@ mod tests { #[test] fn test_merge_sort_mutable() { - fn le(&&a: int, &&b: int) -> bool { ret a <= b; } + fn le(&&a: int, &&b: int) -> bool { return a <= b; } let v1 = ~[mut 3, 2, 1]; let v2 = merge_sort(le, v1); assert v2 == ~[1, 2, 3]; diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index b6f5c81f57e..80a075dbe53 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -11,11 +11,11 @@ fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> { while (i < 1000u) { let s = prefix + r.gen_str(16u) + suffix; if os::make_dir(s, 0x1c0i32) { // FIXME: u+rwx (#2349) - ret some(s); + return some(s); } i += 1u; } - ret none; + return none; } #[test] diff --git a/src/libstd/term.rs b/src/libstd/term.rs index aa2d52822be..0667acb8dd2 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -35,10 +35,10 @@ fn reset(writer: io::writer) { fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; - ret alt os::getenv(~"TERM") { + return alt os::getenv(~"TERM") { option::some(env) { for vec::each(supported_terms) |term| { - if str::eq(term, env) { ret true; } + if str::eq(term, env) { return true; } } false } @@ -56,12 +56,12 @@ fn set_color(writer: io::writer, first_char: u8, color: u8) { /// Set the foreground color fn fg(writer: io::writer, color: u8) { - ret set_color(writer, '3' as u8, color); + return set_color(writer, '3' as u8, color); } /// Set the background color fn bg(writer: io::writer, color: u8) { - ret set_color(writer, '4' as u8, color); + return set_color(writer, '4' as u8, color); } // Local Variables: diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 4c9cd41d48a..5d503e4c15f 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -71,7 +71,7 @@ fn parse_opts(args: ~[~str]) -> opt_res { let matches = alt getopts::getopts(args_, opts) { ok(m) { m } - err(f) { ret either::right(getopts::fail_str(f)) } + err(f) { return either::right(getopts::fail_str(f)) } }; let filter = @@ -85,7 +85,7 @@ fn parse_opts(args: ~[~str]) -> opt_res { let test_opts = {filter: filter, run_ignored: run_ignored, logfile: logfile}; - ret either::left(test_opts); + return either::left(test_opts); } enum test_result { tr_ok, tr_failed, tr_ignored, } @@ -180,7 +180,7 @@ fn run_tests_console(opts: test_opts, st.out.write_str(fmt!{". %u passed; %u failed; %u ignored\n\n", st.passed, st.failed, st.ignored}); - ret success; + return success; fn write_log(out: io::writer, result: test_result, test: test_desc) { out.write_line(fmt!{"%s %s", @@ -262,7 +262,7 @@ fn should_sort_failures_before_printing_them() { assert apos < bpos; } -fn use_color() -> bool { ret get_concurrency() == 1u; } +fn use_color() -> bool { return get_concurrency() == 1u; } enum testevent { te_filtered(~[test_desc]), @@ -346,8 +346,8 @@ fn filter_tests(opts: test_opts, fn filter_fn(test: test_desc, filter_str: ~str) -> option<test_desc> { if str::contains(test.name, filter_str) { - ret option::some(copy test); - } else { ret option::none; } + return option::some(copy test); + } else { return option::none; } } let filter = |x| filter_fn(x, filter_str); @@ -361,11 +361,11 @@ fn filter_tests(opts: test_opts, } else { fn filter(test: test_desc) -> option<test_desc> { if test.ignore { - ret option::some({name: test.name, + return option::some({name: test.name, fn: copy test.fn, ignore: false, should_fail: test.should_fail}); - } else { ret option::none; } + } else { return option::none; } }; vec::filter_map(filtered, |x| filter(x)) @@ -380,7 +380,7 @@ fn filter_tests(opts: test_opts, sort::merge_sort(|x,y| lteq(x, y), filtered) }; - ret filtered; + return filtered; } type test_future = {test: test_desc, wait: fn@() -> test_result}; @@ -388,7 +388,7 @@ type test_future = {test: test_desc, wait: fn@() -> test_result}; fn run_test(+test: test_desc, monitor_ch: comm::chan<monitor_msg>) { if test.ignore { comm::send(monitor_ch, (copy test, tr_ignored)); - ret; + return; } do task::spawn { diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 7cbf16f2ec0..3ec2975db18 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -40,7 +40,7 @@ fn get_time() -> timespec { let mut sec = 0i64; let mut nsec = 0i32; rustrt::get_time(sec, nsec); - ret {sec: sec, nsec: nsec}; + return {sec: sec, nsec: nsec}; } /** @@ -58,7 +58,7 @@ fn precise_time_ns() -> u64 { * in seconds since an unspecified epoch. */ fn precise_time_s() -> float { - ret (precise_time_ns() as float) / 1000000000.; + return (precise_time_ns() as float) / 1000000000.; } fn tzset() { @@ -148,11 +148,11 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { let mut i = pos; for str::each(needle) |ch| { if s[i] != ch { - ret false; + return false; } i += 1u; } - ret true; + return true; } fn match_strs(s: ~str, pos: uint, strs: ~[(~str, i32)]) @@ -163,7 +163,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { let (needle, value) = strs[i]; if match_str(s, pos, needle) { - ret some((value, pos + str::len(needle))); + return some((value, pos + str::len(needle))); } i += 1u; } @@ -186,7 +186,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { value = value * 10_i32 + (ch as i32 - '0' as i32); } ' ' if ws { } - _ { ret none; } + _ { return none; } } i += 1u; } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 3def5fbd0d1..b6dc2bfa579 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -36,7 +36,7 @@ fn insert<K: copy, V: copy>(m: &mut tree_edge<K, V>, k: K, v: V) { mut value: v, mut left: none, mut right: none})); - ret; + return; } some(node) { if k == node.key { diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index df2c28be7c9..31d2e51e160 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -160,12 +160,12 @@ mod icu { } pure fn is_XID_start(c: char) -> bool { - ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) + return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } pure fn is_XID_continue(c: char) -> bool { - ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) + return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } @@ -175,7 +175,7 @@ Function: is_digit Returns true if a character is a digit. */ pure fn is_digit(c: char) -> bool { - ret icu::libicu::u_isdigit(c) == icu::TRUE; + return icu::libicu::u_isdigit(c) == icu::TRUE; } /* @@ -184,7 +184,7 @@ Function: is_lower Returns true if a character is a lowercase letter. */ pure fn is_lower(c: char) -> bool { - ret icu::libicu::u_islower(c) == icu::TRUE; + return icu::libicu::u_islower(c) == icu::TRUE; } /* @@ -193,7 +193,7 @@ Function: is_space Returns true if a character is space. */ pure fn is_space(c: char) -> bool { - ret icu::libicu::u_isspace(c) == icu::TRUE; + return icu::libicu::u_isspace(c) == icu::TRUE; } /* @@ -202,7 +202,7 @@ Function: is_upper Returns true if a character is an uppercase letter. */ pure fn is_upper(c: char) -> bool { - ret icu::libicu::u_isupper(c) == icu::TRUE; + return icu::libicu::u_isupper(c) == icu::TRUE; } #[cfg(test)] diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index d3b9795b85b..2b5beda2e37 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -28,7 +28,7 @@ extern mod rustrt { * loop. */ fn get() -> iotask { - ret get_monitor_task_gl(); + return get_monitor_task_gl(); } #[doc(hidden)] diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index bc9878ccc40..d7de26228ca 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -213,7 +213,7 @@ mod test { run_loop(iotask_ch); exit_ch.send(()); }; - ret comm::recv(iotask_port); + return comm::recv(iotask_port); } extern fn lifetime_handle_close(handle: *libc::c_void) unsafe { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 96c3b5b1609..7b4033d0ff3 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -303,15 +303,15 @@ type uv_getaddrinfo_t = { mod uv_ll_struct_stubgen { fn gen_stub_uv_tcp_t() -> uv_tcp_t { - ret gen_stub_os(); + return gen_stub_os(); #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] fn gen_stub_os() -> uv_tcp_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch="x86_64")] fn gen_stub_arch() -> uv_tcp_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -336,7 +336,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch="x86")] fn gen_stub_arch() -> uv_tcp_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -364,7 +364,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_os() -> uv_tcp_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -385,7 +385,7 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_connect_t() -> uv_connect_t { - ret { + return { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8 @@ -393,7 +393,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_connect_t() -> uv_connect_t { - ret { + return { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, @@ -403,10 +403,10 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_async_t() -> uv_async_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch = "x86_64")] fn gen_stub_arch() -> uv_async_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -421,7 +421,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch = "x86")] fn gen_stub_arch() -> uv_async_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -438,7 +438,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_async_t() -> uv_async_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -452,10 +452,10 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_timer_t() -> uv_timer_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch = "x86_64")] fn gen_stub_arch() -> uv_timer_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -470,7 +470,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch = "x86")] fn gen_stub_arch() -> uv_timer_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -489,7 +489,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_timer_t() -> uv_timer_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -502,10 +502,10 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_write_t() -> uv_write_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch="x86_64")] fn gen_stub_arch() -> uv_write_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -519,7 +519,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch="x86")] fn gen_stub_arch() -> uv_write_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -534,7 +534,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_write_t() -> uv_write_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -676,7 +676,7 @@ extern mod rustrt { } unsafe fn loop_new() -> *libc::c_void { - ret rustrt::rust_uv_loop_new(); + return rustrt::rust_uv_loop_new(); } unsafe fn loop_delete(loop_handle: *libc::c_void) { @@ -684,7 +684,7 @@ unsafe fn loop_delete(loop_handle: *libc::c_void) { } unsafe fn loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int { - ret rustrt::rust_uv_loop_refcount(loop_ptr); + return rustrt::rust_uv_loop_refcount(loop_ptr); } unsafe fn run(loop_handle: *libc::c_void) { @@ -697,7 +697,7 @@ unsafe fn close<T>(handle: *T, cb: *u8) { unsafe fn tcp_init(loop_handle: *libc::c_void, handle: *uv_tcp_t) -> libc::c_int { - ret rustrt::rust_uv_tcp_init(loop_handle, handle); + return rustrt::rust_uv_tcp_init(loop_handle, handle); } // FIXME ref #2064 unsafe fn tcp_connect(connect_ptr: *uv_connect_t, @@ -707,7 +707,7 @@ unsafe fn tcp_connect(connect_ptr: *uv_connect_t, -> libc::c_int { log(debug, fmt!{"b4 foreign tcp_connect--addr port: %u cb: %u", (*addr_ptr).sin_port as uint, after_connect_cb as uint}); - ret rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr, + return rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr); } // FIXME ref #2064 @@ -716,30 +716,30 @@ unsafe fn tcp_connect6(connect_ptr: *uv_connect_t, addr_ptr: *sockaddr_in6, ++after_connect_cb: *u8) -> libc::c_int { - ret rustrt::rust_uv_tcp_connect6(connect_ptr, tcp_handle_ptr, + return rustrt::rust_uv_tcp_connect6(connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr); } // FIXME ref #2064 unsafe fn tcp_bind(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in) -> libc::c_int { - ret rustrt::rust_uv_tcp_bind(tcp_server_ptr, + return rustrt::rust_uv_tcp_bind(tcp_server_ptr, addr_ptr); } // FIXME ref #2064 unsafe fn tcp_bind6(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in6) -> libc::c_int { - ret rustrt::rust_uv_tcp_bind6(tcp_server_ptr, + return rustrt::rust_uv_tcp_bind6(tcp_server_ptr, addr_ptr); } unsafe fn listen<T>(stream: *T, backlog: libc::c_int, cb: *u8) -> libc::c_int { - ret rustrt::rust_uv_listen(stream as *libc::c_void, backlog, cb); + return rustrt::rust_uv_listen(stream as *libc::c_void, backlog, cb); } unsafe fn accept(server: *libc::c_void, client: *libc::c_void) -> libc::c_int { - ret rustrt::rust_uv_accept(server as *libc::c_void, + return rustrt::rust_uv_accept(server as *libc::c_void, client as *libc::c_void); } @@ -747,41 +747,41 @@ unsafe fn write<T>(req: *uv_write_t, stream: *T, buf_in: *~[uv_buf_t], cb: *u8) -> libc::c_int { let buf_ptr = vec::unsafe::to_ptr(*buf_in); let buf_cnt = vec::len(*buf_in) as i32; - ret rustrt::rust_uv_write(req as *libc::c_void, + return rustrt::rust_uv_write(req as *libc::c_void, stream as *libc::c_void, buf_ptr, buf_cnt, cb); } unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, on_read: *u8) -> libc::c_int { - ret rustrt::rust_uv_read_start(stream as *libc::c_void, + return rustrt::rust_uv_read_start(stream as *libc::c_void, on_alloc, on_read); } unsafe fn read_stop(stream: *uv_stream_t) -> libc::c_int { - ret rustrt::rust_uv_read_stop(stream as *libc::c_void); + return rustrt::rust_uv_read_stop(stream as *libc::c_void); } unsafe fn last_error(loop_handle: *libc::c_void) -> uv_err_t { - ret rustrt::rust_uv_last_error(loop_handle); + return rustrt::rust_uv_last_error(loop_handle); } unsafe fn strerror(err: *uv_err_t) -> *libc::c_char { - ret rustrt::rust_uv_strerror(err); + return rustrt::rust_uv_strerror(err); } unsafe fn err_name(err: *uv_err_t) -> *libc::c_char { - ret rustrt::rust_uv_err_name(err); + return rustrt::rust_uv_err_name(err); } unsafe fn async_init(loop_handle: *libc::c_void, async_handle: *uv_async_t, cb: *u8) -> libc::c_int { - ret rustrt::rust_uv_async_init(loop_handle, + return rustrt::rust_uv_async_init(loop_handle, async_handle, cb); } unsafe fn async_send(async_handle: *uv_async_t) { - ret rustrt::rust_uv_async_send(async_handle); + return rustrt::rust_uv_async_send(async_handle); } unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { let out_buf = { base: ptr::null(), len: 0 as libc::size_t }; @@ -800,8 +800,8 @@ unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { log(debug, fmt!{"buf_init - result %u len %u", res_base as uint, res_len as uint}); - ret out_buf; - //ret result; + return out_buf; + //return result; } unsafe fn ip4_addr(ip: ~str, port: int) -> sockaddr_in { @@ -860,15 +860,15 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { unsafe fn timer_init(loop_ptr: *libc::c_void, timer_ptr: *uv_timer_t) -> libc::c_int { - ret rustrt::rust_uv_timer_init(loop_ptr, timer_ptr); + return rustrt::rust_uv_timer_init(loop_ptr, timer_ptr); } unsafe fn timer_start(timer_ptr: *uv_timer_t, cb: *u8, timeout: uint, repeat: uint) -> libc::c_int { - ret rustrt::rust_uv_timer_start(timer_ptr, cb, timeout as libc::c_uint, + return rustrt::rust_uv_timer_start(timer_ptr, cb, timeout as libc::c_uint, repeat as libc::c_uint); } unsafe fn timer_stop(timer_ptr: *uv_timer_t) -> libc::c_int { - ret rustrt::rust_uv_timer_stop(timer_ptr); + return rustrt::rust_uv_timer_stop(timer_ptr); } unsafe fn getaddrinfo(loop_ptr: *libc::c_void, handle: *uv_getaddrinfo_t, @@ -889,38 +889,38 @@ unsafe fn freeaddrinfo(res: *addrinfo) { // libuv struct initializers unsafe fn tcp_t() -> uv_tcp_t { - ret uv_ll_struct_stubgen::gen_stub_uv_tcp_t(); + return uv_ll_struct_stubgen::gen_stub_uv_tcp_t(); } unsafe fn connect_t() -> uv_connect_t { - ret uv_ll_struct_stubgen::gen_stub_uv_connect_t(); + return uv_ll_struct_stubgen::gen_stub_uv_connect_t(); } unsafe fn write_t() -> uv_write_t { - ret uv_ll_struct_stubgen::gen_stub_uv_write_t(); + return uv_ll_struct_stubgen::gen_stub_uv_write_t(); } unsafe fn async_t() -> uv_async_t { - ret uv_ll_struct_stubgen::gen_stub_uv_async_t(); + return uv_ll_struct_stubgen::gen_stub_uv_async_t(); } unsafe fn timer_t() -> uv_timer_t { - ret uv_ll_struct_stubgen::gen_stub_uv_timer_t(); + return uv_ll_struct_stubgen::gen_stub_uv_timer_t(); } unsafe fn getaddrinfo_t() -> uv_getaddrinfo_t { - ret uv_ll_struct_stubgen::gen_stub_uv_getaddrinfo_t(); + return uv_ll_struct_stubgen::gen_stub_uv_getaddrinfo_t(); } // data access helpers unsafe fn get_loop_for_uv_handle<T>(handle: *T) -> *libc::c_void { - ret rustrt::rust_uv_get_loop_for_uv_handle(handle as *libc::c_void); + return rustrt::rust_uv_get_loop_for_uv_handle(handle as *libc::c_void); } unsafe fn get_stream_handle_from_connect_req(connect: *uv_connect_t) -> *uv_stream_t { - ret rustrt::rust_uv_get_stream_handle_from_connect_req( + return rustrt::rust_uv_get_stream_handle_from_connect_req( connect); } unsafe fn get_stream_handle_from_write_req( write_req: *uv_write_t) -> *uv_stream_t { - ret rustrt::rust_uv_get_stream_handle_from_write_req( + return rustrt::rust_uv_get_stream_handle_from_write_req( write_req); } unsafe fn get_data_for_uv_loop(loop_ptr: *libc::c_void) -> *libc::c_void { @@ -930,7 +930,7 @@ unsafe fn set_data_for_uv_loop(loop_ptr: *libc::c_void, data: *libc::c_void) { rustrt::rust_uv_set_data_for_uv_loop(loop_ptr, data); } unsafe fn get_data_for_uv_handle<T>(handle: *T) -> *libc::c_void { - ret rustrt::rust_uv_get_data_for_uv_handle(handle as *libc::c_void); + return rustrt::rust_uv_get_data_for_uv_handle(handle as *libc::c_void); } unsafe fn set_data_for_uv_handle<T, U>(handle: *T, data: *U) { @@ -938,7 +938,7 @@ unsafe fn set_data_for_uv_handle<T, U>(handle: *T, data as *libc::c_void); } unsafe fn get_data_for_req<T>(req: *T) -> *libc::c_void { - ret rustrt::rust_uv_get_data_for_req(req as *libc::c_void); + return rustrt::rust_uv_get_data_for_req(req as *libc::c_void); } unsafe fn set_data_for_req<T, U>(req: *T, data: *U) { @@ -946,14 +946,14 @@ unsafe fn set_data_for_req<T, U>(req: *T, data as *libc::c_void); } unsafe fn get_base_from_buf(buf: uv_buf_t) -> *u8 { - ret rustrt::rust_uv_get_base_from_buf(buf); + return rustrt::rust_uv_get_base_from_buf(buf); } unsafe fn get_len_from_buf(buf: uv_buf_t) -> libc::size_t { - ret rustrt::rust_uv_get_len_from_buf(buf); + return rustrt::rust_uv_get_len_from_buf(buf); } unsafe fn malloc_buf_base_of(suggested_size: libc::size_t) -> *u8 { - ret rustrt::rust_uv_malloc_buf_base_of(suggested_size); + return rustrt::rust_uv_malloc_buf_base_of(suggested_size); } unsafe fn free_base_of_buf(buf: uv_buf_t) { rustrt::rust_uv_free_base_of_buf(buf); @@ -964,7 +964,7 @@ unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str { let err_ptr = ptr::addr_of(err); let err_name = str::unsafe::from_c_str(err_name(err_ptr)); let err_msg = str::unsafe::from_c_str(strerror(err_ptr)); - ret fmt!{"LIBUV ERROR: name: %s msg: %s", + return fmt!{"LIBUV ERROR: name: %s msg: %s", err_name, err_msg}; } @@ -1028,7 +1028,7 @@ mod test { handle, char_ptr as uint, suggested_size as uint}); - ret buf_init(char_ptr, suggested_size as uint); + return buf_init(char_ptr, suggested_size as uint); } extern fn on_read_cb(stream: *uv_stream_t, @@ -1277,7 +1277,7 @@ mod test { let err_msg = get_last_err_info(test_loop); log(debug, fmt!{"server_connect_cb: non-zero status: %?", err_msg}); - ret; + return; } let server_data = get_data_for_uv_handle( server_stream_ptr as *libc::c_void) as *tcp_server_data; diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 4ef4288376c..90330db78a7 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -61,7 +61,7 @@ fn extend(cx: ctx, +elt: ident) -> @path { } fn mk_ast_map_visitor() -> vt { - ret visit::mk_vt(@{ + return visit::mk_vt(@{ visit_item: map_item, visit_expr: map_expr, visit_fn: map_fn, @@ -79,7 +79,7 @@ fn map_crate(diag: span_handler, c: crate) -> map { mut local_id: 0u, diag: diag}; visit::visit_crate(c, cx, mk_ast_map_visitor()); - ret cx.map; + return cx.map; } // Used for items loaded from external crate that are being inlined into this diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index a2ac336f605..1ba0beea305 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -19,7 +19,7 @@ pure fn mk_sp(lo: uint, hi: uint) -> span { } // make this a const, once the compiler supports it -pure fn dummy_sp() -> span { ret mk_sp(0u, 0u); } +pure fn dummy_sp() -> span { return mk_sp(0u, 0u); } pure fn path_name(p: @path) -> ~str { path_name_i(p.idents) } @@ -44,7 +44,7 @@ pure fn stmt_id(s: stmt) -> node_id { fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { alt d { def_variant(enum_id, var_id) { - ret {enm: enum_id, var: var_id}; } + return {enm: enum_id, var: var_id}; } _ { fail ~"non-variant in variant_def_ids"; } } } @@ -66,40 +66,40 @@ pure fn def_id_of_def(d: def) -> def_id { pure fn binop_to_str(op: binop) -> ~str { alt op { - add { ret ~"+"; } - subtract { ret ~"-"; } - mul { ret ~"*"; } - div { ret ~"/"; } - rem { ret ~"%"; } - and { ret ~"&&"; } - or { ret ~"||"; } - bitxor { ret ~"^"; } - bitand { ret ~"&"; } - bitor { ret ~"|"; } - shl { ret ~"<<"; } - shr { ret ~">>"; } - eq { ret ~"=="; } - lt { ret ~"<"; } - le { ret ~"<="; } - ne { ret ~"!="; } - ge { ret ~">="; } - gt { ret ~">"; } + add { return ~"+"; } + subtract { return ~"-"; } + mul { return ~"*"; } + div { return ~"/"; } + rem { return ~"%"; } + and { return ~"&&"; } + or { return ~"||"; } + bitxor { return ~"^"; } + bitand { return ~"&"; } + bitor { return ~"|"; } + shl { return ~"<<"; } + shr { return ~">>"; } + eq { return ~"=="; } + lt { return ~"<"; } + le { return ~"<="; } + ne { return ~"!="; } + ge { return ~">="; } + gt { return ~">"; } } } pure fn binop_to_method_name(op: binop) -> option<~str> { alt op { - add { ret some(~"add"); } - subtract { ret some(~"sub"); } - mul { ret some(~"mul"); } - div { ret some(~"div"); } - rem { ret some(~"modulo"); } - bitxor { ret some(~"bitxor"); } - bitand { ret some(~"bitand"); } - bitor { ret some(~"bitor"); } - shl { ret some(~"shl"); } - shr { ret some(~"shr"); } - and | or | eq | lt | le | ne | ge | gt { ret none; } + add { return some(~"add"); } + subtract { return some(~"sub"); } + mul { return some(~"mul"); } + div { return some(~"div"); } + rem { return some(~"modulo"); } + bitxor { return some(~"bitxor"); } + bitand { return some(~"bitand"); } + bitor { return some(~"bitor"); } + shl { return some(~"shl"); } + shr { return some(~"shr"); } + and | or | eq | lt | le | ne | ge | gt { return none; } } } @@ -117,16 +117,16 @@ pure fn is_shift_binop(b: binop) -> bool { pure fn unop_to_str(op: unop) -> ~str { alt op { - box(mt) { if mt == m_mutbl { ret ~"@mut "; } ret ~"@"; } - uniq(mt) { if mt == m_mutbl { ret ~"~mut "; } ret ~"~"; } - deref { ret ~"*"; } - not { ret ~"!"; } - neg { ret ~"-"; } + box(mt) { if mt == m_mutbl { ~"@mut " } else { ~"@" } } + uniq(mt) { if mt == m_mutbl { ~"~mut " } else { ~"~" } } + deref { ~"*" } + not { ~"!" } + neg { ~"-" } } } pure fn is_path(e: @expr) -> bool { - ret alt e.node { expr_path(_) { true } _ { false } }; + return alt e.node { expr_path(_) { true } _ { false } }; } pure fn int_ty_to_str(t: int_ty) -> ~str { @@ -192,10 +192,10 @@ fn is_exported(i: ident, m: _mod) -> bool { for vps.each |vp| { alt vp.node { ast::view_path_simple(id, _, _) { - if id == i { ret true; } + if id == i { return true; } alt parent_enum { some(parent_enum_id) { - if id == parent_enum_id { ret true; } + if id == parent_enum_id { return true; } } _ {} } @@ -203,9 +203,9 @@ fn is_exported(i: ident, m: _mod) -> bool { ast::view_path_list(path, ids, _) { if vec::len(path.idents) == 1u { - if i == path.idents[0] { ret true; } + if i == path.idents[0] { return true; } for ids.each |id| { - if id.node.name == i { ret true; } + if id.node.name == i { return true; } } } else { fail ~"export of path-qualified list"; @@ -223,40 +223,40 @@ fn is_exported(i: ident, m: _mod) -> bool { // If there are no declared exports then // everything not imported is exported // even if it's local (since it's explicit) - ret !has_explicit_exports && local; + return !has_explicit_exports && local; } pure fn is_call_expr(e: @expr) -> bool { alt e.node { expr_call(_, _, _) { true } _ { false } } } -fn eq_ty(&&a: @ty, &&b: @ty) -> bool { ret box::ptr_eq(a, b); } +fn eq_ty(&&a: @ty, &&b: @ty) -> bool { return box::ptr_eq(a, b); } fn hash_ty(&&t: @ty) -> uint { let res = (t.span.lo << 16u) + t.span.hi; - ret res; + return res; } fn def_eq(a: ast::def_id, b: ast::def_id) -> bool { - ret a.crate == b.crate && a.node == b.node; + return a.crate == b.crate && a.node == b.node; } fn hash_def(d: ast::def_id) -> uint { let mut h = 5381u; h = (h << 5u) + h ^ (d.crate as uint); h = (h << 5u) + h ^ (d.node as uint); - ret h; + return h; } fn new_def_hash<V: copy>() -> std::map::hashmap<ast::def_id, V> { let hasher: std::map::hashfn<ast::def_id> = hash_def; let eqer: std::map::eqfn<ast::def_id> = def_eq; - ret std::map::hashmap::<ast::def_id, V>(hasher, eqer); + return std::map::hashmap::<ast::def_id, V>(hasher, eqer); } fn block_from_expr(e: @expr) -> blk { let blk_ = default_block(~[], option::some::<@expr>(e), e.id); - ret {node: blk_, span: e.span}; + return {node: blk_, span: e.span}; } fn default_block(+stmts1: ~[@stmt], expr1: option<@expr>, id1: node_id) -> @@ -551,7 +551,7 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { *min = int::min(*min, id); *max = int::max(*max, id + 1); } - ret {min:*min, max:*max}; + return {min:*min, max:*max}; } fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 5801bc895e5..bfaa7fa3bbd 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -52,25 +52,25 @@ export require_unique_names; fn mk_name_value_item_str(+name: ast::ident, +value: ~str) -> @ast::meta_item { let value_lit = dummy_spanned(ast::lit_str(@value)); - ret mk_name_value_item(name, value_lit); + return mk_name_value_item(name, value_lit); } fn mk_name_value_item(+name: ast::ident, +value: ast::lit) -> @ast::meta_item { - ret @dummy_spanned(ast::meta_name_value(name, value)); + return @dummy_spanned(ast::meta_name_value(name, value)); } fn mk_list_item(+name: ast::ident, +items: ~[@ast::meta_item]) -> @ast::meta_item { - ret @dummy_spanned(ast::meta_list(name, items)); + return @dummy_spanned(ast::meta_list(name, items)); } fn mk_word_item(+name: ast::ident) -> @ast::meta_item { - ret @dummy_spanned(ast::meta_word(name)); + return @dummy_spanned(ast::meta_word(name)); } fn mk_attr(item: @ast::meta_item) -> ast::attribute { - ret dummy_spanned({style: ast::attr_inner, value: *item, + return dummy_spanned({style: ast::attr_inner, value: *item, is_sugared_doc: false}); } @@ -81,7 +81,7 @@ fn mk_sugared_doc_attr(text: ~str, lo: uint, hi: uint) -> ast::attribute { value: spanned(lo, hi, ast::meta_name_value(@~"doc", lit)), is_sugared_doc: true }; - ret spanned(lo, hi, attr); + return spanned(lo, hi, attr); } /* Conversion */ @@ -92,7 +92,7 @@ fn attr_meta(attr: ast::attribute) -> @ast::meta_item { @attr.node.value } fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { let mut mitems = ~[]; for attrs.each |a| { vec::push(mitems, attr_meta(a)); } - ret mitems; + return mitems; } fn desugar_doc_attr(attr: ast::attribute) -> ast::attribute { @@ -100,7 +100,7 @@ fn desugar_doc_attr(attr: ast::attribute) -> ast::attribute { let comment = get_meta_item_value_str(@attr.node.value).get(); let meta = mk_name_value_item_str(@~"doc", strip_doc_comment_decoration(*comment)); - ret mk_attr(meta); + return mk_attr(meta); } else { attr } @@ -178,7 +178,7 @@ fn find_attrs_by_name(attrs: ~[ast::attribute], +name: ~str) -> } else { option::none } } ); - ret vec::filter_map(attrs, filter); + return vec::filter_map(attrs, filter); } /// Searcha list of meta items and return only those with a specific name @@ -189,7 +189,7 @@ fn find_meta_items_by_name(metas: ~[@ast::meta_item], +name: ~str) -> option::some(m) } else { option::none } }; - ret vec::filter_map(metas, filter); + return vec::filter_map(metas, filter); } /** @@ -202,14 +202,14 @@ fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool { for haystack.each |item| { debug!{"looking in %s", print::pprust::meta_item_to_str(*item)}; - if eq(item, needle) { debug!{"found it!"}; ret true; } + if eq(item, needle) { debug!{"found it!"}; return true; } } #debug("found it not :("); - ret false; + return false; } fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { - ret alt a.node { + return alt a.node { ast::meta_word(na) { alt b.node { ast::meta_word(nb) { na == nb } _ { false } } } @@ -232,7 +232,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { fn contains_name(metas: ~[@ast::meta_item], +name: ~str) -> bool { let matches = find_meta_items_by_name(metas, name); - ret vec::len(matches) > 0u; + return vec::len(matches) > 0u; } fn attrs_contains_name(attrs: ~[ast::attribute], +name: ~str) -> bool { @@ -243,9 +243,9 @@ fn first_attr_value_str_by_name(attrs: ~[ast::attribute], +name: ~str) -> option<@~str> { let mattrs = find_attrs_by_name(attrs, name); if vec::len(mattrs) > 0u { - ret get_meta_item_value_str(attr_meta(mattrs[0])); + return get_meta_item_value_str(attr_meta(mattrs[0])); } - ret option::none; + return option::none; } fn last_meta_item_by_name( @@ -297,19 +297,19 @@ fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] { ast::meta_list(name, _) { /* FIXME (#2543) */ copy name } } } - ret key(ma) <= key(mb); + return key(ma) <= key(mb); } // This is sort of stupid here, converting to a vec of mutables and back let v: ~[mut @ast::meta_item] = vec::to_mut(items); std::sort::quick_sort(lteq, v); - ret vec::from_mut(v); + return vec::from_mut(v); } fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ast::ident) -> ~[@ast::meta_item] { - ret vec::filter_map(items, |item| { + return vec::filter_map(items, |item| { if get_meta_item_name(item) != name { option::some(/* FIXME (#2543) */ copy item) } else { @@ -326,7 +326,7 @@ fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] { _ { debug!{"ignoring link attribute that has incorrect type"}; } } } - ret found; + return found; } /** @@ -342,7 +342,7 @@ fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { } fn foreign_abi(attrs: ~[ast::attribute]) -> either<~str, ast::foreign_abi> { - ret alt attr::first_attr_value_str_by_name(attrs, ~"abi") { + return alt attr::first_attr_value_str_by_name(attrs, ~"abi") { option::none { either::right(ast::foreign_abi_cdecl) } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 0c211395223..95742451396 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -58,7 +58,7 @@ fn new_filemap_w_substr(+filename: filename, +substr: file_substr, src: @~str, start_pos_ch: uint, start_pos_byte: uint) -> filemap { - ret @{name: filename, substr: substr, src: src, + return @{name: filename, substr: substr, src: src, start_pos: {ch: start_pos_ch, byte: start_pos_byte}, mut lines: ~[{ch: start_pos_ch, byte: start_pos_byte}]}; } @@ -66,14 +66,14 @@ fn new_filemap_w_substr(+filename: filename, +substr: file_substr, fn new_filemap(+filename: filename, src: @~str, start_pos_ch: uint, start_pos_byte: uint) -> filemap { - ret new_filemap_w_substr(filename, fss_none, src, + return new_filemap_w_substr(filename, fss_none, src, start_pos_ch, start_pos_byte); } fn mk_substr_filename(cm: codemap, sp: span) -> ~str { let pos = lookup_char_pos(cm, sp.lo); - ret fmt!{"<%s:%u:%u>", pos.file.name, pos.line, pos.col}; + return fmt!{"<%s:%u:%u>", pos.file.name, pos.line, pos.col}; } fn next_line(file: filemap, chpos: uint, byte_pos: uint) { @@ -102,22 +102,22 @@ fn lookup_line(map: codemap, pos: uint, lookup: lookup_fn) let m = (a + b) / 2u; if lookup(f.lines[m]) > pos { b = m; } else { a = m; } } - ret {fm: f, line: a}; + return {fm: f, line: a}; } fn lookup_pos(map: codemap, pos: uint, lookup: lookup_fn) -> loc { let {fm: f, line: a} = lookup_line(map, pos, lookup); - ret {file: f, line: a + 1u, col: pos - lookup(f.lines[a])}; + return {file: f, line: a + 1u, col: pos - lookup(f.lines[a])}; } fn lookup_char_pos(map: codemap, pos: uint) -> loc { - pure fn lookup(pos: file_pos) -> uint { ret pos.ch; } - ret lookup_pos(map, pos, lookup); + pure fn lookup(pos: file_pos) -> uint { return pos.ch; } + return lookup_pos(map, pos, lookup); } fn lookup_byte_pos(map: codemap, pos: uint) -> loc { - pure fn lookup(pos: file_pos) -> uint { ret pos.byte; } - ret lookup_pos(map, pos, lookup); + pure fn lookup(pos: file_pos) -> uint { return pos.byte; } + return lookup_pos(map, pos, lookup); } fn lookup_char_pos_adj(map: codemap, pos: uint) @@ -144,7 +144,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 { ret pos.ch; } + pure fn lookup(pos: file_pos) -> uint { return pos.ch; } let line = lookup_line(map, sp.lo, lookup); alt (line.fm.substr) { fss_none {sp} @@ -166,14 +166,14 @@ type span = {lo: uint, hi: uint, expn_info: expn_info}; fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str { let lo = lookup_char_pos(cm, sp.lo); let hi = lookup_char_pos(cm, sp.hi); - ret fmt!{"%s:%u:%u: %u:%u", lo.file.name, + return fmt!{"%s:%u:%u: %u:%u", lo.file.name, lo.line, lo.col, hi.line, hi.col} } fn span_to_str(sp: span, cm: codemap) -> ~str { let lo = lookup_char_pos_adj(cm, sp.lo); let hi = lookup_char_pos_adj(cm, sp.hi); - ret fmt!{"%s:%u:%u: %u:%u", lo.filename, + return fmt!{"%s:%u:%u: %u:%u", lo.filename, lo.line, lo.col, hi.line, hi.col} } @@ -181,7 +181,7 @@ type file_lines = {file: filemap, lines: ~[uint]}; fn span_to_filename(sp: span, cm: codemap::codemap) -> filename { let lo = lookup_char_pos(cm, sp.lo); - ret /* FIXME (#2543) */ copy lo.file.name; + return /* FIXME (#2543) */ copy lo.file.name; } fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { @@ -191,7 +191,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { for uint::range(lo.line - 1u, hi.line as uint) |i| { vec::push(lines, i); }; - ret @{file: lo.file, lines: lines}; + return @{file: lo.file, lines: lines}; } fn get_line(fm: filemap, line: int) -> ~str unsafe { @@ -205,7 +205,7 @@ fn get_line(fm: filemap, line: int) -> ~str unsafe { fn lookup_byte_offset(cm: codemap::codemap, chpos: uint) -> {fm: filemap, pos: uint} { - pure fn lookup(pos: file_pos) -> uint { ret pos.ch; } + pure fn lookup(pos: file_pos) -> uint { return pos.ch; } let {fm, line} = lookup_line(cm, chpos, lookup); let line_offset = fm.lines[line].byte - fm.start_pos.byte; let col = chpos - fm.lines[line].ch; @@ -217,17 +217,17 @@ fn span_to_snippet(sp: span, cm: codemap::codemap) -> ~str { let begin = lookup_byte_offset(cm, sp.lo); let end = lookup_byte_offset(cm, sp.hi); assert begin.fm == end.fm; - ret str::slice(*begin.fm.src, begin.pos, end.pos); + return str::slice(*begin.fm.src, begin.pos, end.pos); } fn get_snippet(cm: codemap::codemap, fidx: uint, lo: uint, hi: uint) -> ~str { let fm = cm.files[fidx]; - ret str::slice(*fm.src, lo, hi) + return str::slice(*fm.src, lo, hi) } fn get_filemap(cm: codemap, filename: ~str) -> filemap { - for cm.files.each |fm| { if fm.name == filename { ret fm; } } + for cm.files.each |fm| { if fm.name == filename { return fm; } } //XXjdm the following triggers a mismatched type bug // (or expected function, found _|_) fail; // ("asking for " + filename + " which we don't know about"); diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index d9292afc96a..98cf3953a29 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -88,7 +88,7 @@ impl codemap_handler of handler for handler_t { fn abort_if_errors() { let s; alt self.err_count { - 0u { ret; } + 0u { return; } 1u { s = ~"aborting due to previous error"; } _ { s = fmt!{"aborting due to %u previous errors", self.err_count}; } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e8505387fa8..2947201003f 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -107,7 +107,7 @@ fn syntax_expander_table() -> hashmap<~str, syntax_extension> { builtin(ext::source_util::expand_mod)); syntax_expanders.insert(~"proto", builtin_item_tt(ext::pipes::expand_proto)); - ret syntax_expanders; + return syntax_expanders; } @@ -148,7 +148,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, fn backtrace() -> expn_info { self.backtrace } fn mod_push(i: ast::ident) { vec::push(self.mod_path, i); } fn mod_pop() { vec::pop(self.mod_path); } - fn mod_path() -> ~[ast::ident] { ret self.mod_path; } + fn mod_path() -> ~[ast::ident] { return self.mod_path; } fn bt_push(ei: codemap::expn_info_) { alt ei { expanded_from({call_site: cs, callie: callie}) { @@ -193,7 +193,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, self.parse_sess.span_diagnostic.handler().bug(msg); } fn next_id() -> ast::node_id { - ret parse::next_node_id(self.parse_sess); + return parse::next_node_id(self.parse_sess); } } let imp : ctxt_repr = { @@ -202,14 +202,14 @@ fn mk_ctxt(parse_sess: parse::parse_sess, mut backtrace: none, mut mod_path: ~[] }; - ret imp as ext_ctxt + return imp as ext_ctxt } fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { alt expr.node { ast::expr_lit(l) { alt l.node { - ast::lit_str(s) { ret *s; } + ast::lit_str(s) { return *s; } _ { cx.span_fatal(l.span, error); } } } @@ -222,7 +222,7 @@ fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { ast::expr_path(p) { if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { cx.span_fatal(expr.span, error); - } else { ret p.idents[0]; } + } else { return p.idents[0]; } } _ { cx.span_fatal(expr.span, error); } } @@ -230,7 +230,7 @@ fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, min: uint, name: ~str) -> ~[@ast::expr] { - ret get_mac_args(cx, sp, arg, min, none, name); + return get_mac_args(cx, sp, arg, min, none, name); } fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, @@ -250,7 +250,7 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, cx.span_fatal(sp, fmt!{"#%s needs at least %u arguments.", name, min}); } - _ { ret elts; /* we're good */} + _ { return elts; /* we're good */} } } _ { @@ -308,7 +308,7 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree]) _ { fail ~"badly-structured parse result"; } }; - ret some(@{id: parse::next_node_id(cx.parse_sess()), + return some(@{id: parse::next_node_id(cx.parse_sess()), callee_id: parse::next_node_id(cx.parse_sess()), node: ast::expr_vec(args, ast::m_imm), span: sp}); } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5eca1e8e17c..ab2d93faabe 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -3,7 +3,7 @@ import base::ext_ctxt; fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) -> @ast::expr { - ret @{id: cx.next_id(), callee_id: cx.next_id(), + return @{id: cx.next_id(), callee_id: cx.next_id(), node: expr, span: sp}; } @@ -13,15 +13,15 @@ fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { } fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr { let lit = ast::lit_int(i as i64, ast::ty_i); - ret mk_lit(cx, sp, lit); + return mk_lit(cx, sp, lit); } fn mk_uint(cx: ext_ctxt, sp: span, u: uint) -> @ast::expr { let lit = ast::lit_uint(u as u64, ast::ty_u); - ret mk_lit(cx, sp, lit); + return mk_lit(cx, sp, lit); } fn mk_u8(cx: ext_ctxt, sp: span, u: u8) -> @ast::expr { let lit = ast::lit_uint(u as u64, ast::ty_u8); - ret mk_lit(cx, sp, lit); + return mk_lit(cx, sp, lit); } fn mk_binary(cx: ext_ctxt, sp: span, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr) @@ -48,7 +48,7 @@ fn mk_access_(cx: ext_ctxt, sp: span, p: @ast::expr, m: ast::ident) fn mk_access(cx: ext_ctxt, sp: span, p: ~[ast::ident], m: ast::ident) -> @ast::expr { let pathexpr = mk_path(cx, sp, p); - ret mk_access_(cx, sp, pathexpr, m); + return mk_access_(cx, sp, pathexpr, m); } fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr, args: ~[@ast::expr]) -> @ast::expr { @@ -57,7 +57,7 @@ fn mk_call_(cx: ext_ctxt, sp: span, fn_expr: @ast::expr, fn mk_call(cx: ext_ctxt, sp: span, fn_path: ~[ast::ident], args: ~[@ast::expr]) -> @ast::expr { let pathexpr = mk_path(cx, sp, fn_path); - ret mk_call_(cx, sp, pathexpr, args); + return mk_call_(cx, sp, pathexpr, args); } // e = expr, t = type fn mk_base_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> @@ -79,7 +79,7 @@ fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> } fn mk_base_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { let lit = ast::lit_str(@s); - ret mk_lit(cx, sp, lit); + return mk_lit(cx, sp, lit); } fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { mk_vstore_e(cx, sp, mk_base_str(cx, sp, s), ast::vstore_uniq) diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index b3545cc635d..f5d22e6754c 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -8,7 +8,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, res += *expr_to_ident(cx, e, ~"expected an ident"); } - ret @{id: cx.next_id(), + return @{id: cx.next_id(), callee_id: cx.next_id(), node: ast::expr_path(@{span: sp, global: false, idents: ~[@res], rp: none, types: ~[]}), diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index e03fc2ce47b..4aa55e88f16 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -17,8 +17,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let var = expr_to_str(cx, args[0], ~"#env requires a string"); alt os::getenv(var) { - option::none { ret mk_uniq_str(cx, sp, ~""); } - option::some(s) { ret mk_uniq_str(cx, sp, s); } + 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 62e5841a749..24cc78e366e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -15,7 +15,7 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, orig: fn@(expr_, span, ast_fold) -> (expr_, span)) -> (expr_, span) { - ret alt e { + return alt e { // expr_mac should really be expr_ext or something; it's the // entry-point for all syntax extensions. expr_mac(mac) { @@ -159,7 +159,7 @@ fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, } }; - ret {items: new_items with module_}; + return {items: new_items with module_}; } @@ -185,9 +185,9 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, if is_mod { cx.mod_push(it.ident); } let ret_val = orig(it, fld); if is_mod { cx.mod_pop(); } - ret ret_val; + return ret_val; } - none { ret none; } + none { return none; } } } @@ -221,7 +221,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>, } }; cx.bt_pop(); - ret maybe_it + return maybe_it } _ { cx.span_fatal(it.span, fmt!{"%s is not a legal here", *extname}) } @@ -235,7 +235,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>, fn new_span(cx: ext_ctxt, sp: span) -> span { /* this discards information in the case of macro-defining macros */ - ret {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; + return {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; } // FIXME (#2247): this is a terrible kludge to inject some macros into @@ -244,7 +244,7 @@ fn new_span(cx: ext_ctxt, sp: span) -> span { // compiled part of libcore at very least. fn core_macros() -> ~str { - ret + return ~"{ #macro[[#error[f, ...], log(core::error, #fmt[f, ...])]]; #macro[[#warn[f, ...], log(core::warn, #fmt[f, ...])]]; @@ -275,7 +275,7 @@ fn expand_crate(parse_sess: parse::parse_sess, f.fold_expr(cm); let res = @f.fold_crate(*c); - ret res; + return res; } // Local Variables: // mode: rust diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index d8549ca21c8..10820664344 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -27,7 +27,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg, parse_fmt_err_(cx, fmtspan, s) }; let pieces = parse_fmt_string(fmt, parse_fmt_err); - ret pieces_to_expr(cx, sp, pieces, args); + return pieces_to_expr(cx, sp, pieces, args); } // FIXME (#2249): A lot of these functions for producing expressions can @@ -38,12 +38,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: ~[piece], args: ~[@ast::expr]) -> @ast::expr { fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> ~[ast::ident] { - ret ~[@~"extfmt", @~"rt", ident]; + return ~[@~"extfmt", @~"rt", ident]; } fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: ast::ident) -> @ast::expr { let path = make_path_vec(cx, ident); - ret mk_path(cx, sp, path); + return mk_path(cx, sp, path); } // Produces an AST expression that represents a RT::conv record, // which tells the RT::conv* functions how to perform the conversion @@ -62,18 +62,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, tmp_expr = mk_binary(cx, sp, ast::bitor, tmp_expr, make_rt_path_expr(cx, sp, @fstr)); } - ret tmp_expr; + return tmp_expr; } fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { alt cnt { count_implied { - ret make_rt_path_expr(cx, sp, @~"count_implied"); + return make_rt_path_expr(cx, sp, @~"count_implied"); } count_is(c) { let count_lit = mk_int(cx, sp, c); let count_is_path = make_path_vec(cx, @~"count_is"); let count_is_args = ~[count_lit]; - ret mk_call(cx, sp, count_is_path, count_is_args); + return mk_call(cx, sp, count_is_path, count_is_args); } _ { cx.span_unimpl(sp, ~"unimplemented #fmt conversion"); } } @@ -91,12 +91,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, ty_octal { rt_type = ~"ty_octal"; } _ { rt_type = ~"ty_default"; } } - ret make_rt_path_expr(cx, sp, @rt_type); + return make_rt_path_expr(cx, sp, @rt_type); } fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr, width_expr: @ast::expr, precision_expr: @ast::expr, ty_expr: @ast::expr) -> @ast::expr { - ret mk_rec_e(cx, sp, + return mk_rec_e(cx, sp, ~[{ident: @~"flags", ex: flags_expr}, {ident: @~"width", ex: width_expr}, {ident: @~"precision", ex: precision_expr}, @@ -106,7 +106,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let rt_conv_width = make_count(cx, sp, cnv.width); let rt_conv_precision = make_count(cx, sp, cnv.precision); let rt_conv_ty = make_ty(cx, sp, cnv.ty); - ret make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width, + return make_conv_rec(cx, sp, rt_conv_flags, rt_conv_width, rt_conv_precision, rt_conv_ty); } fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: ~str, cnv: conv, @@ -115,7 +115,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let path = make_path_vec(cx, @fname); let cnv_expr = make_rt_conv_expr(cx, sp, cnv); let args = ~[cnv_expr, arg]; - ret mk_call(cx, arg.span, path, args); + return mk_call(cx, arg.span, path, args); } fn make_new_conv(cx: ext_ctxt, sp: span, cnv: conv, arg: @ast::expr) -> @@ -125,10 +125,10 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, fn is_signed_type(cnv: conv) -> bool { alt cnv.ty { ty_int(s) { - alt s { signed { ret true; } unsigned { ret false; } } + alt s { signed { return true; } unsigned { return false; } } } - ty_float { ret true; } - _ { ret false; } + ty_float { return true; } + _ { return false; } } } let unsupported = ~"conversion not supported in #fmt string"; @@ -168,22 +168,28 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, _ { cx.span_unimpl(sp, unsupported); } } alt cnv.ty { - ty_str { ret make_conv_call(cx, arg.span, ~"str", cnv, arg); } + ty_str { return make_conv_call(cx, arg.span, ~"str", cnv, arg); } ty_int(sign) { alt sign { - signed { ret make_conv_call(cx, arg.span, ~"int", cnv, arg); } + signed { + return make_conv_call(cx, arg.span, ~"int", cnv, arg); + } unsigned { - ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); + return make_conv_call(cx, arg.span, ~"uint", cnv, arg); } } } - ty_bool { ret make_conv_call(cx, arg.span, ~"bool", cnv, arg); } - ty_char { ret make_conv_call(cx, arg.span, ~"char", cnv, arg); } - ty_hex(_) { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } - ty_bits { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } - ty_octal { ret make_conv_call(cx, arg.span, ~"uint", cnv, arg); } - ty_float { ret make_conv_call(cx, arg.span, ~"float", cnv, arg); } - ty_poly { ret make_conv_call(cx, arg.span, ~"poly", cnv, arg); } + ty_bool { return make_conv_call(cx, arg.span, ~"bool", cnv, arg); } + ty_char { return make_conv_call(cx, arg.span, ~"char", cnv, arg); } + ty_hex(_) { + return make_conv_call(cx, arg.span, ~"uint", cnv, arg); + } + ty_bits { return make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_octal { return make_conv_call(cx, arg.span, ~"uint", cnv, arg); } + ty_float { + return make_conv_call(cx, arg.span, ~"float", cnv, arg); + } + ty_poly { return make_conv_call(cx, arg.span, ~"poly", cnv, arg); } } } fn log_conv(c: conv) { @@ -275,7 +281,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } let arg_vec = mk_fixed_vec_e(cx, fmt_sp, piece_exprs); - ret mk_call(cx, fmt_sp, ~[@~"str", @~"concat"], ~[arg_vec]); + return mk_call(cx, fmt_sp, ~[@~"str", @~"concat"], ~[arg_vec]); } // // Local Variables: diff --git a/src/libsyntax/ext/ident_to_str.rs b/src/libsyntax/ext/ident_to_str.rs index 54f97912f3d..06faff9ee1b 100644 --- a/src/libsyntax/ext/ident_to_str.rs +++ b/src/libsyntax/ext/ident_to_str.rs @@ -6,6 +6,6 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"ident_to_str"); - ret mk_uniq_str(cx, sp, *expr_to_ident(cx, args[0u], + return mk_uniq_str(cx, sp, *expr_to_ident(cx, args[0u], ~"expected an ident")); } diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 70d83b164c8..f84e496be9c 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -11,6 +11,6 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, ); //trivial expression - ret @{id: cx.next_id(), callee_id: cx.next_id(), + return @{id: cx.next_id(), callee_id: cx.next_id(), node: ast::expr_rec(~[], option::none), span: sp}; } diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 0375f742b4b..ea8c8c04b0e 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -19,7 +19,7 @@ impl proto_parser of proto_parser for parser { {sep: none, trailing_sep_allowed: false}, |self| self.parse_state(proto)); - ret proto; + return proto; } fn parse_state(proto: protocol) { diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index b9f77ea3fc2..1805fd9fa35 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -149,7 +149,7 @@ class protocol_ { fn has_ty_params() -> bool { for self.states.each |s| { if s.ty_params.len() > 0 { - ret true; + return true; } } false diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 94753ea88e0..1c3e0aa5181 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -112,7 +112,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt do cx.gather.swap |v| { vec::to_mut(std::sort::merge_sort(|a,b| a.lo < b.lo, v)) }; - ret cx; + return cx; } fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>) @@ -155,7 +155,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, } let body = get_mac_body(ecx,_sp,body); - ret alt what { + return alt what { ~"crate" {finish(ecx, body, parse_crate)} ~"expr" {finish(ecx, body, parse_expr)} ~"ty" {finish(ecx, body, parse_ty)} @@ -268,7 +268,7 @@ fn finish<T: qq_helper> ~[@~"syntax", @~"ext", @~"qquote", @node.get_fold_fn()])]); } - ret rcall; + return rcall; } fn replace<T>(node: T, repls: ~[fragment], ff: fn (ast_fold, T) -> T) @@ -280,7 +280,7 @@ fn replace<T>(node: T, repls: ~[fragment], ff: fn (ast_fold, T) -> T) fold_ty: |a,b,c|replace_ty(repls, a, b, c, aft.fold_ty) with *aft}; - ret ff(make_fold(f_pre), node); + return ff(make_fold(f_pre), node); } fn fold_crate(f: ast_fold, &&n: @ast::crate) -> @ast::crate { @f.fold_crate(*n) diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index b261e7657a2..b835300d5c7 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -13,9 +13,9 @@ export add_new_extension; fn path_to_ident(pth: @path) -> option<ident> { if vec::len(pth.idents) == 1u && vec::len(pth.types) == 0u { - ret some(pth.idents[0u]); + return some(pth.idents[0u]); } - ret none; + return none; } //a vec of binders might be a little big. @@ -94,7 +94,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> } idx += 1u; } - ret alt res { + return alt res { some(val) { val } none { {pre: elts, rep: none, post: ~[]} } } @@ -104,18 +104,18 @@ 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) { none { ret none; } some(fv) { vec::push(res, fv); } } + alt f(elem) { none { return none; } some(fv) { vec::push(res, fv); } } } - ret some(res); + return some(res); } fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { alt ad { - leaf(x) { ret f(x); } + leaf(x) { return f(x); } seq(ads, span) { alt option_flatten_map(|x| a_d_map(x, f), *ads) { - none { ret none; } - some(ts) { ret some(seq(@ts, span)); } + none { return none; } + some(ts) { return some(seq(@ts, span)); } } } } @@ -123,12 +123,12 @@ 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 { - ret alt s1(m) { + return alt s1(m) { none { none } some(matches) { a_d_map(matches, s2) } } } - ret { |x| scomp(s1, s2, x) }; + return { |x| scomp(s1, s2, x) }; } @@ -150,9 +150,11 @@ fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders { literal_ast_matchers: dvec()}; //this oughta return binders instead, but macro args are a sequence of //expressions, rather than a single expression - fn trivial_selector(m: matchable) -> match_result { ret some(leaf(m)); } + fn trivial_selector(m: matchable) -> match_result { + return some(leaf(m)); + } p_t_s_rec(cx, match_expr(e), trivial_selector, res); - ret res; + return res; } @@ -165,7 +167,7 @@ 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 { ret none; } _ { } } + alt sel(match_expr(e)) { none { return none; } _ { } } } let mut never_mind: bool = false; for b.real_binders.each |key, val| { @@ -175,18 +177,18 @@ fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { } }; //HACK: `ret` doesn't work in `for each` - if never_mind { ret none; } - ret some(res); + if never_mind { return none; } + return some(res); } /* use the bindings on the body to generate the expanded code */ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { let idx_path: @mut ~[uint] = @mut ~[]; - fn new_id(_old: node_id, cx: ext_ctxt) -> node_id { ret cx.next_id(); } + fn new_id(_old: node_id, cx: ext_ctxt) -> node_id { return cx.next_id(); } fn new_span(cx: ext_ctxt, sp: span) -> span { /* this discards information in the case of macro-defining macros */ - ret {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; + return {lo: sp.lo, hi: sp.hi, expn_info: cx.backtrace()}; } let afp = default_ast_fold(); let f_pre = @@ -209,7 +211,7 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { with *afp}; let f = make_fold(f_pre); let result = f.fold_expr(body); - ret result; + return result; } @@ -219,25 +221,25 @@ fn follow(m: arb_depth<matchable>, idx_path: @mut ~[uint]) -> let mut res: arb_depth<matchable> = m; for vec::each(*idx_path) |idx| { res = alt res { - leaf(_) { ret res;/* end of the line */ } + leaf(_) { return res;/* end of the line */ } seq(new_ms, _) { new_ms[idx] } } } - ret res; + return res; } fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, idx_path: @mut ~[uint]) -> option<matchable> { alt mmaybe { - none { ret none } + none { return none } some(m) { - ret alt follow(m, idx_path) { + return alt follow(m, idx_path) { seq(_, sp) { cx.span_fatal(sp, ~"syntax matched under ... but not " + ~"used that way.") } - leaf(m) { ret some(m) } + leaf(m) { return some(m) } } } } @@ -250,7 +252,7 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings, idents: hashmap<ident, ()>) -> ident { if b.contains_key(i) { idents.insert(i, ()); } - ret i; + return i; } // using fold is a hack: we want visit, but it doesn't hit idents ) : // solve this with macros @@ -319,7 +321,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], } } res = vec::append(res, vec::map(post, recur)); - ret res; + return res; } } } @@ -329,7 +331,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 { - ret alt follow_for_trans(cx, b.find(i), idx_path) { + return alt 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 } @@ -340,7 +342,7 @@ fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], 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 { ret p; } + 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) { some(match_ident(id)) { {span: id.span, global: false, idents: ~[id.node], @@ -358,7 +360,7 @@ 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) { - ret alt e { + return alt e { expr_path(p) { // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { @@ -387,7 +389,7 @@ 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) { - ret alt t { + return alt t { ast::ty_path(pth, _) { alt path_to_ident(pth) { some(id) { @@ -413,7 +415,7 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(blk_, span, ast_fold) -> (blk_, span)) -> (blk_, span) { - ret alt block_to_ident(blk) { + return alt block_to_ident(blk) { some(id) { alt follow_for_trans(cx, b.find(id), idx_path) { some(match_block(new_blk)) { (new_blk.node, new_blk.span) } @@ -474,7 +476,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 { - ret alt m { + return alt m { match_expr(e) { if e == pat { some(leaf(match_exact)) } else { none } } @@ -494,7 +496,7 @@ 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 { - ret alt m { + return alt m { match_expr(e) { alt e.node { expr_path(pth) { @@ -515,7 +517,7 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { alt path_to_ident(p) { some(p_id) { fn select(cx: ext_ctxt, m: matchable) -> match_result { - ret alt m { + return alt m { match_expr(e) { some(leaf(specialize_match(m))) } _ { cx.bug(~"broken traversal in p_t_s_r") } } @@ -530,8 +532,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 { ret none; } - ret alt blk.expr { + if vec::len(blk.stmts) != 0u { return none; } + return alt blk.expr { some(expr) { alt expr.node { expr_path(pth) { path_to_ident(pth) } _ { none } } } @@ -542,7 +544,7 @@ 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 { - ret alt m { + return alt m { match_expr(e) { alt e.node { expr_mac(mac) { fn_m(mac) } _ { none } } } @@ -565,7 +567,7 @@ 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 { - ret alt m { + return alt m { match_expr(e) { alt e.node { expr_vec(arg_elts, _) { @@ -595,7 +597,7 @@ 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 { - ret alt m { + return alt m { match_expr(e) { alt e.node { expr_vec(arg_elts, _) { @@ -619,7 +621,7 @@ 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 { - ret alt m { + return alt m { match_expr(e) { alt e.node { expr_vec(arg_elts, _) { @@ -709,7 +711,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); - ret {ident: + return {ident: alt macro_name { some(id) { id } none { @@ -728,7 +730,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, }; for clauses.each |c| { alt use_selectors_to_bind(c.params, arg) { - some(bindings) { ret transcribe(cx, bindings, c.body); } + 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 226292086f8..00c1e4ff47a 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -18,7 +18,7 @@ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"line"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret mk_uint(cx, sp, loc.line); + return mk_uint(cx, sp, loc.line); } /* col!{}: expands to the current column number */ @@ -26,7 +26,7 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"col"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret mk_uint(cx, sp, loc.col); + return mk_uint(cx, sp, loc.col); } /* file!{}: expands to the current filename */ @@ -37,19 +37,19 @@ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); let { file: @{ name: filename, _ }, _ } = codemap::lookup_char_pos(cx.codemap(), sp.lo); - ret mk_uniq_str(cx, sp, filename); + return mk_uniq_str(cx, sp, filename); } fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"stringify"); - ret mk_uniq_str(cx, sp, pprust::expr_to_str(args[0])); + return mk_uniq_str(cx, sp, pprust::expr_to_str(args[0])); } fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); - ret mk_uniq_str(cx, sp, + return mk_uniq_str(cx, sp, str::connect(cx.mod_path().map(|x|*x), ~"::")); } @@ -60,7 +60,7 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), res_rel_file(cx, sp, file), parse::parser::SOURCE_FILE); - ret p.parse_expr(); + return p.parse_expr(); } fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, @@ -77,7 +77,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, } } - ret mk_uniq_str(cx, sp, result::unwrap(res)); + return mk_uniq_str(cx, sp, result::unwrap(res)); } fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, @@ -91,7 +91,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let u8_exprs = vec::map(src, |char: u8| { mk_u8(cx, sp, char) }); - ret mk_uniq_vec_e(cx, sp, u8_exprs); + return mk_uniq_vec_e(cx, sp, u8_exprs); } result::err(e) { cx.parse_sess().span_diagnostic.handler().fatal(e) @@ -104,9 +104,9 @@ fn res_rel_file(cx: ext_ctxt, sp: codemap::span, +arg: path) -> path { if !path::path_is_absolute(arg) { let cu = codemap::span_to_filename(sp, cx.codemap()); let dir = path::dirname(cu); - ret path::connect(dir, arg); + return path::connect(dir, arg); } else { - ret arg; + return arg; } } diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index ed4e2e44f08..6930c09e7ce 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -129,7 +129,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) } let ret_val = box_str_hash::<@named_match>(); for ms.each() |m| { n_rec(p_s, m, res, ret_val) } - ret ret_val; + return ret_val; } enum parse_result { @@ -260,13 +260,13 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) /* error messages here could be improved with links to orig. rules */ if tok == EOF { if eof_eis.len() == 1u { - ret success( + return success( nameize(sess, ms, vec::map(eof_eis[0u].matches, |dv| dv.pop()))); } else if eof_eis.len() > 1u { - ret failure(sp, ~"Ambiguity: multiple successful parses"); + return failure(sp, ~"Ambiguity: multiple successful parses"); } else { - ret failure(sp, ~"Unexpected end of macro invocation"); + return failure(sp, ~"Unexpected end of macro invocation"); } } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) @@ -277,12 +277,12 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) fmt!{"%s ('%s')", *name, *bind} } _ { fail; } } }), ~" or "); - ret failure(sp, fmt!{ + return failure(sp, fmt!{ "Local ambiguity: multiple parsing options: \ built-in NTs %s or %u other options.", nts, next_eis.len()}); } else if (bb_eis.len() == 0u && next_eis.len() == 0u) { - ret failure(sp, ~"No rules expected the token " + return failure(sp, ~"No rules expected the token " + to_str(*rdr.interner(), tok)); } else if (next_eis.len() > 0u) { /* Now process the next token */ diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index a5fc20c461b..3c680640a31 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -70,7 +70,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, ~[rhs]); let p = parser(cx.parse_sess(), cx.cfg(), trncbr as reader, SOURCE_FILE); - ret mr_expr(p.parse_expr()); + return mr_expr(p.parse_expr()); } failure(sp, msg) { if sp.lo >= best_fail_spot.lo { @@ -87,5 +87,8 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, let exp = |cx, sp, arg| generic_extension(cx, sp, arg, lhses, rhses); - ret mr_def({ident: name, ext: expr_tt({expander: exp, span: some(sp)})}); + return mr_def({ + ident: name, + ext: expr_tt({expander: exp, span: some(sp)}) + }); } \ No newline at end of file diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 9ab6261052a..9fda95c464e 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -56,7 +56,7 @@ fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, mut cur_span: ast_util::mk_sp(0u,0u) }; tt_next_token(r); /* get cur_tok and cur_span set up */ - ret r; + return r; } pure fn dup_tt_frame(&&f: tt_frame) -> tt_frame { @@ -145,7 +145,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { alt r.cur.up { tt_frame_up(none) { r.cur_tok = EOF; - ret ret_val; + return ret_val; } tt_frame_up(some(tt_f)) { if r.cur.dotdotdoted { @@ -163,7 +163,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { alt r.cur.sep { some(tk) { r.cur_tok = tk; /* repeat same span, I guess */ - ret ret_val; + return ret_val; } none {} } @@ -180,7 +180,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { tt_tok(sp, tok) { r.cur_span = sp; r.cur_tok = tok; r.cur.idx += 1u; - ret ret_val; + return ret_val; } tt_seq(sp, tts, sep, zerok) { alt lockstep_iter_size(tt_seq(sp, tts, sep, zerok), r) { @@ -204,7 +204,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } r.cur.idx += 1u; - ret tt_next_token(r); + return tt_next_token(r); } else { vec::push(r.repeat_len, len); vec::push(r.repeat_idx, 0u); @@ -223,12 +223,12 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { matched_nonterminal(nt_ident(sn,b)) { r.cur_span = sp; r.cur_tok = IDENT(sn,b); r.cur.idx += 1u; - ret ret_val; + return ret_val; } matched_nonterminal(other_whole_nt) { r.cur_span = sp; r.cur_tok = INTERPOLATED(other_whole_nt); r.cur.idx += 1u; - ret ret_val; + return ret_val; } matched_seq(*) { r.sp_diag.span_fatal( diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 7900b5eea15..ee0512e1b07 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -79,7 +79,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 { - ret @{node: + return @{node: alt mi.node { meta_word(id) { meta_word(fld.fold_ident(id)) } meta_list(id, mis) { @@ -97,21 +97,21 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { //used in noop_fold_item and noop_fold_crate fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute { - ret {node: {style: at.node.style, + return {node: {style: at.node.style, value: *fold_meta_item_(@at.node.value, fld), is_sugared_doc: at.node.is_sugared_doc }, span: fld.new_span(at.span)}; } //used in noop_fold_foreign_item and noop_fold_fn_decl fn fold_arg_(a: arg, fld: ast_fold) -> arg { - ret {mode: a.mode, + return {mode: a.mode, ty: fld.fold_ty(a.ty), ident: fld.fold_ident(a.ident), id: fld.new_id(a.id)}; } //used in noop_fold_expr, and possibly elsewhere in the future fn fold_mac_(m: mac, fld: ast_fold) -> mac { - ret {node: + return {node: alt m.node { mac_invoc(pth, arg, body) { mac_invoc(fld.fold_path(pth), @@ -126,7 +126,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac { } fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { - ret {inputs: vec::map(decl.inputs, |x| fold_arg_(x, fld) ), + return {inputs: vec::map(decl.inputs, |x| fold_arg_(x, fld) ), output: fld.fold_ty(decl.output), purity: decl.purity, cf: decl.cf} @@ -153,15 +153,17 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { let fold_meta_item = |x| fold_meta_item_(x, fld); let fold_attribute = |x| fold_attribute_(x, fld); - ret {directives: vec::map(c.directives, |x| fld.fold_crate_directive(x)), - module: fld.fold_mod(c.module), - attrs: vec::map(c.attrs, fold_attribute), - config: vec::map(c.config, fold_meta_item)}; + return { + directives: vec::map(c.directives, |x| fld.fold_crate_directive(x)), + module: fld.fold_mod(c.module), + attrs: vec::map(c.attrs, fold_attribute), + config: vec::map(c.config, fold_meta_item) + }; } fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) -> crate_directive_ { - ret alt cd { + return alt cd { cdir_src_mod(id, attrs) { cdir_src_mod(fld.fold_ident(id), /* FIXME (#2543) */ copy attrs) } @@ -176,7 +178,7 @@ fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) -> } fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ { - ret /* FIXME (#2543) */ copy vi; + return /* FIXME (#2543) */ copy vi; } @@ -185,7 +187,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) let fold_arg = |x| fold_arg_(x, fld); let fold_attribute = |x| fold_attribute_(x, fld); - ret @{ident: fld.fold_ident(ni.ident), + return @{ident: fld.fold_ident(ni.ident), attrs: vec::map(ni.attrs, fold_attribute), node: alt ni.node { @@ -204,7 +206,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) fn noop_fold_item(&&i: @item, fld: ast_fold) -> option<@item> { let fold_attribute = |x| fold_attribute_(x, fld); - ret some(@{ident: fld.fold_ident(i.ident), + return some(@{ident: fld.fold_ident(i.ident), attrs: vec::map(i.attrs, fold_attribute), id: fld.new_id(i.id), node: fld.fold_item_underscore(i.node), @@ -225,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_ { - ret alt i { + return alt 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), @@ -294,7 +296,7 @@ fn fold_trait_ref(&&p: @trait_ref, fld: ast_fold) -> @trait_ref { } fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { - ret @{ident: fld.fold_ident(m.ident), + return @{ident: fld.fold_ident(m.ident), attrs: /* FIXME (#2543) */ copy m.attrs, tps: fold_ty_params(m.tps, fld), self_ty: m.self_ty, @@ -308,7 +310,7 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method { fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { - ret {view_items: vec::map(b.view_items, |x| fld.fold_view_item(x)), + return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(x)), stmts: vec::map(b.stmts, |x| fld.fold_stmt(x)), expr: option::map(b.expr, |x| fld.fold_expr(x)), id: fld.new_id(b.id), @@ -316,7 +318,7 @@ fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { } fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { - ret alt s { + return alt 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)) } @@ -324,13 +326,13 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { } fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { - ret {pats: vec::map(a.pats, |x| fld.fold_pat(x)), + return {pats: vec::map(a.pats, |x| fld.fold_pat(x)), guard: option::map(a.guard, |x| fld.fold_expr(x)), body: fld.fold_block(a.body)}; } fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { - ret alt p { + return alt p { pat_wild { pat_wild } pat_ident(binding_mode, pth, sub) { pat_ident(binding_mode, @@ -375,14 +377,14 @@ fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ { fn wrap<T>(f: fn@(T, ast_fold) -> T) -> fn@(T, span, ast_fold) -> (T, span) { - ret fn@(x: T, s: span, fld: ast_fold) -> (T, span) { + return fn@(x: T, s: span, fld: ast_fold) -> (T, span) { (f(x, fld), s) } } fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { fn fold_field_(field: field, fld: ast_fold) -> field { - ret {node: + return {node: {mutbl: field.node.mutbl, ident: fld.fold_ident(field.node.ident), expr: fld.fold_expr(field.node.expr)}, @@ -392,7 +394,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { let fold_mac = |x| fold_mac_(x, fld); - ret alt e { + return alt e { expr_new(p, i, v) { expr_new(fld.fold_expr(p), fld.new_id(i), @@ -514,18 +516,18 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { // ...nor do modules fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod { - ret {view_items: vec::map(m.view_items, |x| fld.fold_view_item(x)), + return {view_items: vec::map(m.view_items, |x| fld.fold_view_item(x)), items: vec::filter_map(m.items, |x| fld.fold_item(x))}; } fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod { - ret {view_items: vec::map(nm.view_items, |x| fld.fold_view_item(x)), + return {view_items: vec::map(nm.view_items, |x| fld.fold_view_item(x)), items: vec::map(nm.items, |x| fld.fold_foreign_item(x))} } fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg { - ret {ty: fld.fold_ty(va.ty), id: fld.new_id(va.id)}; + return {ty: fld.fold_ty(va.ty), id: fld.new_id(va.id)}; } let fold_variant_arg = |x| fold_variant_arg_(x, fld); let args = vec::map(v.args, fold_variant_arg); @@ -537,7 +539,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { some(e) {some(fld.fold_expr(e))} none {none} }; - ret {name: /* FIXME (#2543) */ copy v.name, + return {name: /* FIXME (#2543) */ copy v.name, attrs: attrs, args: args, id: fld.new_id(v.id), disr_expr: de, @@ -545,18 +547,18 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { } fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident { - ret /* FIXME (#2543) */ copy i; + return /* FIXME (#2543) */ copy i; } fn noop_fold_path(&&p: path, fld: ast_fold) -> path { - ret {span: fld.new_span(p.span), global: p.global, + return {span: fld.new_span(p.span), global: p.global, idents: vec::map(p.idents, |x| fld.fold_ident(x)), rp: p.rp, types: vec::map(p.types, |x| fld.fold_ty(x))}; } fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { - ret {is_mutbl: l.is_mutbl, + return {is_mutbl: l.is_mutbl, ty: fld.fold_ty(l.ty), pat: fld.fold_pat(l.pat), init: @@ -573,15 +575,15 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { /* temporarily eta-expand because of a compiler bug with using `fn<T>` as a value */ fn noop_map_exprs(f: fn@(&&@expr) -> @expr, es: ~[@expr]) -> ~[@expr] { - ret vec::map(es, f); + return vec::map(es, f); } -fn noop_id(i: node_id) -> node_id { ret i; } +fn noop_id(i: node_id) -> node_id { return i; } -fn noop_span(sp: span) -> span { ret sp; } +fn noop_span(sp: span) -> span { return sp; } fn default_ast_fold() -> ast_fold_precursor { - ret @{fold_crate: wrap(noop_fold_crate), + return @{fold_crate: wrap(noop_fold_crate), fold_crate_directive: wrap(noop_fold_crate_directive), fold_view_item: noop_fold_view_item, fold_foreign_item: noop_fold_foreign_item, @@ -611,17 +613,17 @@ impl of ast_fold for ast_fold_precursor { /* naturally, a macro to write these would be nice */ fn fold_crate(c: crate) -> crate { let (n, s) = self.fold_crate(c.node, c.span, self as ast_fold); - ret {node: n, span: self.new_span(s)}; + return {node: n, span: self.new_span(s)}; } fn fold_crate_directive(&&c: @crate_directive) -> @crate_directive { let (n, s) = self.fold_crate_directive(c.node, c.span, self as ast_fold); - ret @{node: n, + return @{node: n, span: self.new_span(s)}; } fn fold_view_item(&&x: @view_item) -> @view_item { - ret @{node: self.fold_view_item(x.node, self as ast_fold), + return @{node: self.fold_view_item(x.node, self as ast_fold), attrs: vec::map(x.attrs, |a| fold_attribute_(a, self as ast_fold)), vis: x.vis, @@ -629,10 +631,10 @@ impl of ast_fold for ast_fold_precursor { } fn fold_foreign_item(&&x: @foreign_item) -> @foreign_item { - ret self.fold_foreign_item(x, self as ast_fold); + return self.fold_foreign_item(x, self as ast_fold); } fn fold_item(&&i: @item) -> option<@item> { - ret self.fold_item(i, self as ast_fold); + return self.fold_item(i, self as ast_fold); } fn fold_class_item(&&ci: @class_member) -> @class_member { @{node: alt ci.node { @@ -647,65 +649,65 @@ impl of ast_fold for ast_fold_precursor { } fn fold_item_underscore(i: item_) -> item_ { - ret self.fold_item_underscore(i, self as ast_fold); + return self.fold_item_underscore(i, self as ast_fold); } fn fold_method(&&x: @method) -> @method { - ret self.fold_method(x, self as ast_fold); + return self.fold_method(x, self as ast_fold); } fn fold_block(x: blk) -> blk { let (n, s) = self.fold_block(x.node, x.span, self as ast_fold); - ret {node: n, span: self.new_span(s)}; + return {node: n, span: self.new_span(s)}; } fn fold_stmt(&&x: @stmt) -> @stmt { let (n, s) = self.fold_stmt(x.node, x.span, self as ast_fold); - ret @{node: n, span: self.new_span(s)}; + return @{node: n, span: self.new_span(s)}; } fn fold_arm(x: arm) -> arm { - ret self.fold_arm(x, self as ast_fold); + return self.fold_arm(x, self as ast_fold); } fn fold_pat(&&x: @pat) -> @pat { let (n, s) = self.fold_pat(x.node, x.span, self as ast_fold); - ret @{id: self.new_id(x.id), + return @{id: self.new_id(x.id), node: n, span: self.new_span(s)}; } fn fold_decl(&&x: @decl) -> @decl { let (n, s) = self.fold_decl(x.node, x.span, self as ast_fold); - ret @{node: n, span: self.new_span(s)}; + return @{node: n, span: self.new_span(s)}; } fn fold_expr(&&x: @expr) -> @expr { let (n, s) = self.fold_expr(x.node, x.span, self as ast_fold); - ret @{id: self.new_id(x.id), + return @{id: self.new_id(x.id), callee_id: self.new_id(x.callee_id), node: n, span: self.new_span(s)}; } fn fold_ty(&&x: @ty) -> @ty { let (n, s) = self.fold_ty(x.node, x.span, self as ast_fold); - ret @{id: self.new_id(x.id), node: n, span: self.new_span(s)}; + return @{id: self.new_id(x.id), node: n, span: self.new_span(s)}; } fn fold_mod(x: _mod) -> _mod { - ret self.fold_mod(x, self as ast_fold); + return self.fold_mod(x, self as ast_fold); } fn fold_foreign_mod(x: foreign_mod) -> foreign_mod { - ret self.fold_foreign_mod(x, self as ast_fold); + return self.fold_foreign_mod(x, self as ast_fold); } fn fold_variant(x: variant) -> variant { let (n, s) = self.fold_variant(x.node, x.span, self as ast_fold); - ret {node: n, span: self.new_span(s)}; + return {node: n, span: self.new_span(s)}; } fn fold_ident(&&x: ident) -> ident { - ret self.fold_ident(x, self as ast_fold); + return self.fold_ident(x, self as ast_fold); } fn fold_path(&&x: @path) -> @path { @self.fold_path(*x, self as ast_fold) } fn fold_local(&&x: @local) -> @local { let (n, s) = self.fold_local(x.node, x.span, self as ast_fold); - ret @{node: n, span: self.new_span(s)}; + return @{node: n, span: self.new_span(s)}; } fn map_exprs(f: fn@(&&@expr) -> @expr, e: ~[@expr]) -> ~[@expr] { self.map_exprs(f, e) diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 39f4654a138..dad80246bf5 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -34,7 +34,7 @@ type parse_sess = @{ fn new_parse_sess(demitter: option<emitter>) -> parse_sess { let cm = codemap::new_codemap(); - ret @{cm: cm, + return @{cm: cm, mut next_id: 1, span_diagnostic: mk_span_handler(mk_handler(demitter), cm), interner: @interner::mk::<@~str>(|x| str::hash(*x), @@ -44,7 +44,7 @@ fn new_parse_sess(demitter: option<emitter>) -> parse_sess { fn new_parse_sess_special_handler(sh: span_handler, cm: codemap::codemap) -> parse_sess { - ret @{cm: cm, + return @{cm: cm, mut next_id: 1, span_diagnostic: sh, interner: @interner::mk::<@~str>(|x| str::hash(*x), @@ -81,7 +81,7 @@ fn parse_crate_from_crate_file(input: ~str, cfg: ast::crate_cfg, cx, cdirs, prefix, option::some(companionmod)); let mut hi = p.span.hi; p.expect(token::EOF); - ret @ast_util::respan(ast_util::mk_sp(lo, hi), + return @ast_util::respan(ast_util::mk_sp(lo, hi), {directives: cdirs, module: m, attrs: vec::append(crate_attrs, attrs), @@ -95,7 +95,7 @@ fn parse_crate_from_source_file(input: ~str, cfg: ast::crate_cfg, let r = p.parse_crate_mod(cfg); sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; - ret r; + return r; } fn parse_crate_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, @@ -105,7 +105,7 @@ fn parse_crate_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, let r = p.parse_crate_mod(cfg); sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; - ret r; + return r; } fn parse_expr_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, @@ -115,7 +115,7 @@ fn parse_expr_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, let r = p.parse_expr(); sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; - ret r; + return r; } fn parse_item_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, @@ -127,7 +127,7 @@ fn parse_item_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, let r = p.parse_item(attrs, vis); sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; - ret r; + return r; } fn parse_stmt_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, @@ -138,7 +138,7 @@ fn parse_stmt_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, let r = p.parse_stmt(attrs); sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; - ret r; + return r; } fn parse_from_source_str<T>(f: fn (p: parser) -> T, @@ -155,7 +155,7 @@ fn parse_from_source_str<T>(f: fn (p: parser) -> T, } sess.chpos = rdr.chpos; sess.byte_pos = sess.byte_pos + rdr.pos; - ret r; + return r; } fn next_node_id(sess: parse_sess) -> node_id { @@ -163,7 +163,7 @@ fn next_node_id(sess: parse_sess) -> node_id { sess.next_id += 1; // ID 0 is reserved for the crate and doesn't actually exist in the AST assert rv != 0; - ret rv; + return rv; } fn new_parser_etc_from_source_str(sess: parse_sess, cfg: ast::crate_cfg, @@ -175,14 +175,14 @@ fn new_parser_etc_from_source_str(sess: parse_sess, cfg: ast::crate_cfg, sess.cm.files.push(filemap); let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap, sess.interner); - ret (parser(sess, cfg, srdr as reader, ftype), srdr); + return (parser(sess, cfg, srdr as reader, ftype), srdr); } fn new_parser_from_source_str(sess: parse_sess, cfg: ast::crate_cfg, +name: ~str, +ss: codemap::file_substr, source: @~str) -> parser { let (p, _) = new_parser_etc_from_source_str(sess, cfg, name, ss, source); - ret p; + return p; } @@ -199,18 +199,18 @@ fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg, sess.cm.files.push(filemap); let srdr = lexer::new_string_reader(sess.span_diagnostic, filemap, sess.interner); - ret (parser(sess, cfg, srdr as reader, ftype), srdr); + return (parser(sess, cfg, srdr as reader, ftype), srdr); } fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: ~str, ftype: parser::file_type) -> parser { let (p, _) = new_parser_etc_from_file(sess, cfg, path, ftype); - ret p; + return p; } fn new_parser_from_tt(sess: parse_sess, cfg: ast::crate_cfg, tt: ~[ast::token_tree]) -> parser { let trdr = lexer::new_tt_reader(sess.span_diagnostic, sess.interner, none, tt); - ret parser(sess, cfg, trdr as reader, parser::SOURCE_FILE) + return parser(sess, cfg, trdr as reader, parser::SOURCE_FILE) } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index fb28f952629..265b707899a 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -36,21 +36,21 @@ impl parser_attr of parser_attr for parser { self.bump(); let first_attr = self.parse_attribute_naked(ast::attr_outer, lo); - ret some(left(vec::append(~[first_attr], + return some(left(vec::append(~[first_attr], self.parse_outer_attributes()))); } else if !(self.look_ahead(1u) == token::LT || self.look_ahead(1u) == token::LBRACKET || self.look_ahead(1u) == token::POUND || expect_item_next) { self.bump(); - ret some(right(self.parse_syntax_ext_naked(lo))); - } else { ret none; } + return some(right(self.parse_syntax_ext_naked(lo))); + } else { return none; } } token::DOC_COMMENT(_) { - ret some(left(self.parse_outer_attributes())); + return some(left(self.parse_outer_attributes())); } _ { - ret none; + return none; } } } @@ -80,13 +80,13 @@ impl parser_attr of parser_attr for parser { } } } - ret attrs; + return attrs; } fn parse_attribute(style: ast::attr_style) -> ast::attribute { let lo = self.span.lo; self.expect(token::POUND); - ret self.parse_attribute_naked(style, lo); + return self.parse_attribute_naked(style, lo); } fn parse_attribute_naked(style: ast::attr_style, lo: uint) -> @@ -95,7 +95,7 @@ impl parser_attr of parser_attr for parser { let meta_item = self.parse_meta_item(); self.expect(token::RBRACKET); let mut hi = self.span.hi; - ret spanned(lo, hi, {style: style, value: *meta_item, + return spanned(lo, hi, {style: style, value: *meta_item, is_sugared_doc: false}); } @@ -146,7 +146,7 @@ impl parser_attr of parser_attr for parser { } } } - ret {inner: inner_attrs, next: next_outer_attrs}; + return {inner: inner_attrs, next: next_outer_attrs}; } fn parse_meta_item() -> @ast::meta_item { @@ -157,29 +157,29 @@ impl parser_attr of parser_attr for parser { self.bump(); let lit = self.parse_lit(); let mut hi = self.span.hi; - ret @spanned(lo, hi, ast::meta_name_value(ident, lit)); + return @spanned(lo, hi, ast::meta_name_value(ident, lit)); } token::LPAREN { let inner_items = self.parse_meta_seq(); let mut hi = self.span.hi; - ret @spanned(lo, hi, ast::meta_list(ident, inner_items)); + return @spanned(lo, hi, ast::meta_list(ident, inner_items)); } _ { let mut hi = self.span.hi; - ret @spanned(lo, hi, ast::meta_word(ident)); + return @spanned(lo, hi, ast::meta_word(ident)); } } } fn parse_meta_seq() -> ~[@ast::meta_item] { - ret self.parse_seq(token::LPAREN, token::RPAREN, + return self.parse_seq(token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_meta_item()).node; } fn parse_optional_meta() -> ~[@ast::meta_item] { - alt self.token { token::LPAREN { ret self.parse_meta_seq(); } - _ { ret ~[]; } } + alt 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 20fb7772d08..8a5e02163be 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -18,16 +18,16 @@ fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { alt stmt.node { ast::stmt_decl(d, _) { - ret alt d.node { + return alt d.node { ast::decl_local(_) { true } ast::decl_item(_) { false } } } ast::stmt_expr(e, _) { - ret expr_requires_semi_to_be_stmt(e); + return expr_requires_semi_to_be_stmt(e); } ast::stmt_semi(e, _) { - ret false; + return false; } } } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index c9224c2817f..7c24f8b1245 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -47,7 +47,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { while j > i && lines[j - 1u].trim().is_empty() { j -= 1u; } - ret lines.slice(i, j); + return lines.slice(i, j); } // drop leftmost columns that contain only values in chars @@ -69,7 +69,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { } } - ret do lines.map |line| { + return do lines.map |line| { let chars = str::chars(line); if i > chars.len() { ~"" @@ -80,7 +80,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { } if comment.starts_with(~"//") { - ret comment.slice(3u, comment.len()).trim(); + return comment.slice(3u, comment.len()).trim(); } if comment.starts_with(~"/*") { @@ -89,7 +89,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { let lines = block_trim(lines, ~"\t ", none); let lines = block_trim(lines, ~"*", some(1u)); let lines = block_trim(lines, ~"\t ", none); - ret str::connect(lines, ~"\n"); + return str::connect(lines, ~"\n"); } fail ~"not a doc-comment: " + comment; @@ -102,14 +102,14 @@ fn read_to_eol(rdr: string_reader) -> ~str { bump(rdr); } if rdr.curr == '\n' { bump(rdr); } - ret val; + return val; } fn read_one_line_comment(rdr: string_reader) -> ~str { let val = read_to_eol(rdr); assert ((val[0] == '/' as u8 && val[1] == '/' as u8) || (val[0] == '#' as u8 && val[1] == '!' as u8)); - ret val; + return val; } fn consume_non_eol_whitespace(rdr: string_reader) { @@ -173,8 +173,10 @@ fn read_line_comments(rdr: string_reader, code_to_the_left: bool, fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool { let mut i: uint = begin; - while i != end { if !is_whitespace(s[i] as char) { ret false; } i += 1u; } - ret true; + while i != end { + if !is_whitespace(s[i] as char) { return false; } i += 1u; + } + return true; } fn trim_whitespace_prefix_and_push_line(&lines: ~[~str], @@ -208,7 +210,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool, bump(rdr); bump(rdr); } - ret; + return; } let mut curr_line = ~"/*"; @@ -250,7 +252,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool, } fn peeking_at_comment(rdr: string_reader) -> bool { - ret ((rdr.curr == '/' && nextch(rdr) == '/') || + return ((rdr.curr == '/' && nextch(rdr) == '/') || (rdr.curr == '/' && nextch(rdr) == '*')) || (rdr.curr == '#' && nextch(rdr) == '!'); } @@ -314,5 +316,5 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, } first_read = false; } - ret {cmnts: comments, lits: literals}; + return {cmnts: comments, lits: literals}; } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index c747c8e9165..e0b551f0e45 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -9,13 +9,13 @@ type seq_sep = { }; fn seq_sep_trailing_disallowed(t: token::token) -> seq_sep { - ret {sep: option::some(t), trailing_sep_allowed: false}; + return {sep: option::some(t), trailing_sep_allowed: false}; } fn seq_sep_trailing_allowed(t: token::token) -> seq_sep { - ret {sep: option::some(t), trailing_sep_allowed: true}; + return {sep: option::some(t), trailing_sep_allowed: true}; } fn seq_sep_none() -> seq_sep { - ret {sep: option::none, trailing_sep_allowed: false}; + return {sep: option::none, trailing_sep_allowed: false}; } fn token_to_str(reader: reader, ++token: token::token) -> ~str { @@ -85,7 +85,7 @@ impl parser_common of parser_common for parser { fn parse_ident() -> ast::ident { alt copy self.token { - token::IDENT(i, _) { self.bump(); ret self.get_str(i); } + token::IDENT(i, _) { self.bump(); return self.get_str(i); } token::INTERPOLATED(token::nt_ident(*)) { self.bug( ~"ident interpolation not converted to real token"); } _ { self.fatal(~"expected ident, found `" @@ -98,16 +98,16 @@ impl parser_common of parser_common for parser { let lo = self.span.lo; let ident = self.parse_ident(); let hi = self.span.hi; - ret spanned(lo, hi, {name: ident, id: self.get_id()}); + return spanned(lo, hi, {name: ident, id: self.get_id()}); } fn parse_value_ident() -> ast::ident { self.check_restricted_keywords(); - ret self.parse_ident(); + return self.parse_ident(); } fn eat(tok: token::token) -> bool { - ret if self.token == tok { self.bump(); true } else { false }; + return if self.token == tok { self.bump(); true } else { false }; } // A sanity check that the word we are asking for is a known keyword @@ -217,7 +217,7 @@ impl parser_common of parser_common for parser { vec::push(v, f(self)); } - ret v; + return v; } fn parse_seq_to_gt<T: copy>(sep: option<token::token>, @@ -225,7 +225,7 @@ impl parser_common of parser_common for parser { let v = self.parse_seq_to_before_gt(sep, f); self.expect_gt(); - ret v; + return v; } fn parse_seq_lt_gt<T: copy>(sep: option<token::token>, @@ -235,14 +235,14 @@ impl parser_common of parser_common for parser { let result = self.parse_seq_to_before_gt::<T>(sep, f); let hi = self.span.hi; self.expect_gt(); - ret spanned(lo, hi, result); + return spanned(lo, hi, result); } fn parse_seq_to_end<T: copy>(ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T] { let val = self.parse_seq_to_before_end(ket, sep, f); self.bump(); - ret val; + return val; } @@ -259,7 +259,7 @@ impl parser_common of parser_common for parser { if sep.trailing_sep_allowed && self.token == ket { break; } vec::push(v, f(self)); } - ret v; + return v; } fn parse_unspanned_seq<T: copy>(bra: token::token, @@ -269,7 +269,7 @@ impl parser_common of parser_common for parser { self.expect(bra); let result = self.parse_seq_to_before_end::<T>(ket, sep, f); self.bump(); - ret result; + return result; } // NB: Do not use this function unless you actually plan to place the @@ -281,6 +281,6 @@ impl parser_common of parser_common for parser { let result = self.parse_seq_to_before_end::<T>(ket, sep, f); let hi = self.span.hi; self.bump(); - ret spanned(lo, hi, result); + return spanned(lo, hi, result); } } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 8a53625be1e..90519c23e5f 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -28,7 +28,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive], let mut view_items: ~[@ast::view_item] = ~[]; let mut items: ~[@ast::item] = ~[]; eval_crate_directives(cx, cdirs, prefix, view_items, items); - ret ({view_items: vec::append(view_items, cview_items), + return ({view_items: vec::append(view_items, cview_items), items: vec::append(items, citems)}, cattrs); } @@ -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 { - ret alt suffix { + return alt suffix { option::some(s) { path::connect(prefix, s) } option::none { prefix } } + ~".rs"; @@ -72,18 +72,18 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) let m0 = p0.parse_mod_items(token::EOF, inner_attrs.next); cx.sess.chpos = r0.chpos; cx.sess.byte_pos = cx.sess.byte_pos + r0.pos; - ret (m0.view_items, m0.items, inner_attrs.inner); + return (m0.view_items, m0.items, inner_attrs.inner); } else { - ret (~[], ~[], ~[]); + return (~[], ~[], ~[]); } } fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str { alt ::attr::first_attr_value_str_by_name(attrs, ~"path") { some(d) { - ret d; + return d; } - none { ret id; } + none { return id; } } } diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index 5a343f370f3..a2d7a04a6bf 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -38,7 +38,7 @@ fn new_string_reader(span_diagnostic: span_handler, itr: @interner<@~str>) -> string_reader { let r = new_low_level_string_reader(span_diagnostic, filemap, itr); string_advance_token(r); /* fill in peek_* */ - ret r; + return r; } /* For comments.rs, which hackily pokes into 'pos' and 'curr' */ @@ -58,7 +58,7 @@ fn new_low_level_string_reader(span_diagnostic: span_handler, r.pos = next.next; r.curr = next.ch; } - ret r; + return r; } fn dup_string_reader(&&r: string_reader) -> string_reader { @@ -73,7 +73,7 @@ impl string_reader_as_reader of reader for string_reader { fn next_token() -> {tok: token::token, sp: span} { let ret_val = {tok: self.peek_tok, sp: self.peek_span}; string_advance_token(self); - ret ret_val; + return ret_val; } fn fatal(m: ~str) -> ! { self.span_diagnostic.span_fatal(copy self.peek_span, m) @@ -112,7 +112,7 @@ fn string_advance_token(&&r: string_reader) { for consume_whitespace_and_comments(r).each |comment| { r.peek_tok = comment.tok; r.peek_span = comment.sp; - ret; + return; } if is_eof(r) { @@ -128,7 +128,7 @@ fn string_advance_token(&&r: string_reader) { fn get_str_from(rdr: string_reader, start: uint) -> ~str unsafe { // I'm pretty skeptical about this subtraction. What if there's a // multi-byte character before the mark? - ret str::slice(*rdr.src, start - 1u, rdr.pos - 1u); + return str::slice(*rdr.src, start - 1u, rdr.pos - 1u); } fn bump(rdr: string_reader) { @@ -155,49 +155,51 @@ fn is_eof(rdr: string_reader) -> bool { } fn nextch(rdr: string_reader) -> char { if rdr.pos < (*rdr.src).len() { - ret str::char_at(*rdr.src, rdr.pos); - } else { ret -1 as char; } + return str::char_at(*rdr.src, rdr.pos); + } else { return -1 as char; } } -fn dec_digit_val(c: char) -> int { ret (c as int) - ('0' as int); } +fn dec_digit_val(c: char) -> int { return (c as int) - ('0' as int); } fn hex_digit_val(c: char) -> int { - if in_range(c, '0', '9') { ret (c as int) - ('0' as int); } - if in_range(c, 'a', 'f') { ret (c as int) - ('a' as int) + 10; } - if in_range(c, 'A', 'F') { ret (c as int) - ('A' as int) + 10; } + if in_range(c, '0', '9') { return (c as int) - ('0' as int); } + if in_range(c, 'a', 'f') { return (c as int) - ('a' as int) + 10; } + if in_range(c, 'A', 'F') { return (c as int) - ('A' as int) + 10; } fail; } -fn bin_digit_value(c: char) -> int { if c == '0' { ret 0; } ret 1; } +fn bin_digit_value(c: char) -> int { if c == '0' { return 0; } return 1; } fn is_whitespace(c: char) -> bool { - ret c == ' ' || c == '\t' || c == '\r' || c == '\n'; + return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } -fn may_begin_ident(c: char) -> bool { ret is_alpha(c) || c == '_'; } +fn may_begin_ident(c: char) -> bool { return is_alpha(c) || c == '_'; } -fn in_range(c: char, lo: char, hi: char) -> bool { ret lo <= c && c <= hi; } +fn in_range(c: char, lo: char, hi: char) -> bool { + return lo <= c && c <= hi +} fn is_alpha(c: char) -> bool { - ret in_range(c, 'a', 'z') || in_range(c, 'A', 'Z'); + return in_range(c, 'a', 'z') || in_range(c, 'A', 'Z'); } -fn is_dec_digit(c: char) -> bool { ret in_range(c, '0', '9'); } +fn is_dec_digit(c: char) -> bool { return in_range(c, '0', '9'); } -fn is_alnum(c: char) -> bool { ret is_alpha(c) || is_dec_digit(c); } +fn is_alnum(c: char) -> bool { return is_alpha(c) || is_dec_digit(c); } fn is_hex_digit(c: char) -> bool { - ret in_range(c, '0', '9') || in_range(c, 'a', 'f') || + return in_range(c, '0', '9') || in_range(c, 'a', 'f') || in_range(c, 'A', 'F'); } -fn is_bin_digit(c: char) -> bool { ret c == '0' || c == '1'; } +fn is_bin_digit(c: char) -> bool { return c == '0' || c == '1'; } // might return a sugared-doc-attr fn consume_whitespace_and_comments(rdr: string_reader) -> option<{tok: token::token, sp: span}> { while is_whitespace(rdr.curr) { bump(rdr); } - ret consume_any_line_comment(rdr); + return consume_any_line_comment(rdr); } // might return a sugared-doc-attr @@ -216,17 +218,17 @@ fn consume_any_line_comment(rdr: string_reader) str::push_char(acc, rdr.curr); bump(rdr); } - ret some({ + return some({ tok: token::DOC_COMMENT((*rdr.interner).intern(@acc)), sp: ast_util::mk_sp(start_chpos, rdr.chpos) }); } else { while rdr.curr != '\n' && !is_eof(rdr) { bump(rdr); } // Restart whitespace munch. - ret consume_whitespace_and_comments(rdr); + return consume_whitespace_and_comments(rdr); } } - '*' { bump(rdr); bump(rdr); ret consume_block_comment(rdr); } + '*' { bump(rdr); bump(rdr); return consume_block_comment(rdr); } _ {} } } else if rdr.curr == '#' { @@ -236,11 +238,11 @@ fn consume_any_line_comment(rdr: string_reader) let loc = codemap::lookup_char_pos_adj(cmap, rdr.chpos); if loc.line == 1u && loc.col == 0u { while rdr.curr != '\n' && !is_eof(rdr) { bump(rdr); } - ret consume_whitespace_and_comments(rdr); + return consume_whitespace_and_comments(rdr); } } } - ret none; + return none; } // might return a sugared-doc-attr @@ -261,7 +263,7 @@ fn consume_block_comment(rdr: string_reader) acc += ~"*/"; bump(rdr); bump(rdr); - ret some({ + return some({ tok: token::DOC_COMMENT((*rdr.interner).intern(@acc)), sp: ast_util::mk_sp(start_chpos, rdr.chpos) }); @@ -285,7 +287,7 @@ fn consume_block_comment(rdr: string_reader) } // restart whitespace munch. - ret consume_whitespace_and_comments(rdr); + return consume_whitespace_and_comments(rdr); } fn scan_exponent(rdr: string_reader) -> option<~str> { @@ -301,9 +303,9 @@ fn scan_exponent(rdr: string_reader) -> option<~str> { } let exponent = scan_digits(rdr, 10u); if str::len(exponent) > 0u { - ret some(rslt + exponent); + return some(rslt + exponent); } else { rdr.fatal(~"scan_exponent: bad fp literal"); } - } else { ret none::<~str>; } + } else { return none::<~str>; } } fn scan_digits(rdr: string_reader, radix: uint) -> ~str { @@ -316,7 +318,7 @@ fn scan_digits(rdr: string_reader, radix: uint) -> ~str { str::push_char(rslt, c); bump(rdr); } - _ { ret rslt; } + _ { return rslt; } } }; } @@ -370,8 +372,8 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { } let parsed = option::get(u64::from_str_radix(num_str, base as u64)); alt tp { - either::left(t) { ret token::LIT_INT(parsed as i64, t); } - either::right(t) { ret token::LIT_UINT(parsed, t); } + either::left(t) { return token::LIT_INT(parsed as i64, t); } + either::right(t) { return token::LIT_UINT(parsed, t); } } } let mut is_float = false; @@ -395,12 +397,12 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { if c == '3' && n == '2' { bump(rdr); bump(rdr); - ret token::LIT_FLOAT((*rdr.interner).intern(@num_str), + return token::LIT_FLOAT((*rdr.interner).intern(@num_str), ast::ty_f32); } else if c == '6' && n == '4' { bump(rdr); bump(rdr); - ret token::LIT_FLOAT((*rdr.interner).intern(@num_str), + return token::LIT_FLOAT((*rdr.interner).intern(@num_str), ast::ty_f64); /* FIXME (#2252): if this is out of range for either a 32-bit or 64-bit float, it won't be noticed till the @@ -410,7 +412,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { } } if is_float { - ret token::LIT_FLOAT((*rdr.interner).intern(@num_str), ast::ty_f); + return token::LIT_FLOAT((*rdr.interner).intern(@num_str), ast::ty_f); } else { if str::len(num_str) == 0u { rdr.fatal(~"no valid digits found for number"); @@ -419,7 +421,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { debug!{"lexing %s as an unsuffixed integer literal", num_str}; - ret token::LIT_INT_UNSUFFIXED(parsed as i64); + return token::LIT_INT_UNSUFFIXED(parsed as i64); } } @@ -435,7 +437,7 @@ fn scan_numeric_escape(rdr: string_reader, n_hex_digits: uint) -> char { accum_int += hex_digit_val(n); i -= 1u; } - ret accum_int as char; + return accum_int as char; } fn next_token_inner(rdr: string_reader) -> token::token { @@ -454,21 +456,21 @@ fn next_token_inner(rdr: string_reader) -> token::token { bump(rdr); c = rdr.curr; } - if str::eq(accum_str, ~"_") { ret token::UNDERSCORE; } + if str::eq(accum_str, ~"_") { return token::UNDERSCORE; } let is_mod_name = c == ':' && nextch(rdr) == ':'; // FIXME: perform NFKC normalization here. (Issue #2253) - ret token::IDENT((*rdr.interner).intern(@accum_str), is_mod_name); + return token::IDENT((*rdr.interner).intern(@accum_str), is_mod_name); } if is_dec_digit(c) { - ret scan_number(c, rdr); + return scan_number(c, rdr); } fn binop(rdr: string_reader, op: token::binop) -> token::token { bump(rdr); if rdr.curr == '=' { bump(rdr); - ret token::BINOPEQ(op); - } else { ret token::BINOP(op); } + return token::BINOPEQ(op); + } else { return token::BINOP(op); } } alt c { @@ -477,35 +479,35 @@ fn next_token_inner(rdr: string_reader) -> token::token { // One-byte tokens. - ';' { bump(rdr); ret token::SEMI; } - ',' { bump(rdr); ret token::COMMA; } + ';' { bump(rdr); return token::SEMI; } + ',' { bump(rdr); return token::COMMA; } '.' { bump(rdr); if rdr.curr == '.' && nextch(rdr) == '.' { bump(rdr); bump(rdr); - ret token::ELLIPSIS; + return token::ELLIPSIS; } - ret token::DOT; + return token::DOT; } - '(' { bump(rdr); ret token::LPAREN; } - ')' { bump(rdr); ret token::RPAREN; } - '{' { bump(rdr); ret token::LBRACE; } - '}' { bump(rdr); ret token::RBRACE; } - '[' { bump(rdr); ret token::LBRACKET; } - ']' { bump(rdr); ret token::RBRACKET; } - '@' { bump(rdr); ret token::AT; } - '#' { bump(rdr); ret token::POUND; } - '~' { bump(rdr); ret token::TILDE; } + '(' { bump(rdr); return token::LPAREN; } + ')' { bump(rdr); return token::RPAREN; } + '{' { bump(rdr); return token::LBRACE; } + '}' { bump(rdr); return token::RBRACE; } + '[' { bump(rdr); return token::LBRACKET; } + ']' { bump(rdr); return token::RBRACKET; } + '@' { bump(rdr); return token::AT; } + '#' { bump(rdr); return token::POUND; } + '~' { bump(rdr); return token::TILDE; } ':' { bump(rdr); if rdr.curr == ':' { bump(rdr); - ret token::MOD_SEP; - } else { ret token::COLON; } + return token::MOD_SEP; + } else { return token::COLON; } } - '$' { bump(rdr); ret token::DOLLAR; } + '$' { bump(rdr); return token::DOLLAR; } @@ -516,42 +518,42 @@ fn next_token_inner(rdr: string_reader) -> token::token { bump(rdr); if rdr.curr == '=' { bump(rdr); - ret token::EQEQ; + return token::EQEQ; } else if rdr.curr == '>' { bump(rdr); - ret token::FAT_ARROW; + return token::FAT_ARROW; } else { - ret token::EQ; + return token::EQ; } } '!' { bump(rdr); if rdr.curr == '=' { bump(rdr); - ret token::NE; - } else { ret token::NOT; } + return token::NE; + } else { return token::NOT; } } '<' { bump(rdr); alt rdr.curr { - '=' { bump(rdr); ret token::LE; } - '<' { ret binop(rdr, token::SHL); } + '=' { bump(rdr); return token::LE; } + '<' { return binop(rdr, token::SHL); } '-' { bump(rdr); alt rdr.curr { - '>' { bump(rdr); ret token::DARROW; } - _ { ret token::LARROW; } + '>' { bump(rdr); return token::DARROW; } + _ { return token::LARROW; } } } - _ { ret token::LT; } + _ { return token::LT; } } } '>' { bump(rdr); alt rdr.curr { - '=' { bump(rdr); ret token::GE; } - '>' { ret binop(rdr, token::SHR); } - _ { ret token::GT; } + '=' { bump(rdr); return token::GE; } + '>' { return binop(rdr, token::SHR); } + _ { return token::GT; } } } '\'' { @@ -580,7 +582,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { rdr.fatal(~"unterminated character constant"); } bump(rdr); // advance curr past token - ret token::LIT_INT(c2 as i64, ast::ty_char); + return token::LIT_INT(c2 as i64, ast::ty_char); } '"' { let n = rdr.chpos; @@ -623,33 +625,33 @@ fn next_token_inner(rdr: string_reader) -> token::token { } } bump(rdr); - ret token::LIT_STR((*rdr.interner).intern(@accum_str)); + return token::LIT_STR((*rdr.interner).intern(@accum_str)); } '-' { if nextch(rdr) == '>' { bump(rdr); bump(rdr); - ret token::RARROW; - } else { ret binop(rdr, token::MINUS); } + return token::RARROW; + } else { return binop(rdr, token::MINUS); } } '&' { if nextch(rdr) == '&' { bump(rdr); bump(rdr); - ret token::ANDAND; - } else { ret binop(rdr, token::AND); } + return token::ANDAND; + } else { return binop(rdr, token::AND); } } '|' { alt nextch(rdr) { - '|' { bump(rdr); bump(rdr); ret token::OROR; } - _ { ret binop(rdr, token::OR); } + '|' { bump(rdr); bump(rdr); return token::OROR; } + _ { return binop(rdr, token::OR); } } } - '+' { ret binop(rdr, token::PLUS); } - '*' { ret binop(rdr, token::STAR); } - '/' { ret binop(rdr, token::SLASH); } - '^' { ret binop(rdr, token::CARET); } - '%' { ret binop(rdr, token::PERCENT); } + '+' { return binop(rdr, token::PLUS); } + '*' { return binop(rdr, token::STAR); } + '/' { return binop(rdr, token::SLASH); } + '^' { return binop(rdr, token::CARET); } + '%' { return binop(rdr, token::PERCENT); } c { rdr.fatal(fmt!{"unknown start of token: %d", c as int}); } } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ada3810b45f..4eaf32e9968 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -108,11 +108,11 @@ macro_rules! maybe_whole_expr { {$p:expr} => { alt copy $p.token { INTERPOLATED(token::nt_expr(e)) { $p.bump(); - ret pexpr(e); + return pexpr(e); } INTERPOLATED(token::nt_path(pt)) { $p.bump(); - ret $p.mk_pexpr($p.span.lo, $p.span.lo, + return $p.mk_pexpr($p.span.lo, $p.span.lo, expr_path(pt)); } _ {} @@ -121,7 +121,7 @@ macro_rules! maybe_whole_expr { macro_rules! maybe_whole { {$p:expr, $constructor:path} => { alt copy $p.token { - INTERPOLATED($constructor(x)) { $p.bump(); ret x; } + INTERPOLATED($constructor(x)) { $p.bump(); return x; } _ {} }} } @@ -132,7 +132,7 @@ fn dummy() { /* we will need this to bootstrap maybe_whole! */ #macro[[#maybe_whole_path[p], alt p.token { - INTERPOLATED(token::nt_path(pt)) { p.bump(); ret pt; } + INTERPOLATED(token::nt_path(pt)) { p.bump(); return pt; } _ {} }]]; } @@ -198,9 +198,9 @@ class parser { } fn buffer_length() -> int { if self.buffer_start <= self.buffer_end { - ret self.buffer_end - self.buffer_start; + return self.buffer_end - self.buffer_start; } - ret (4 - self.buffer_start) + self.buffer_end; + return (4 - self.buffer_start) + self.buffer_end; } fn look_ahead(distance: uint) -> token::token { let dist = distance as int; @@ -208,7 +208,7 @@ class parser { self.buffer[self.buffer_end] = self.reader.next_token(); self.buffer_end = (self.buffer_end + 1) & 3; } - ret copy self.buffer[(self.buffer_start + dist - 1) & 3].tok; + return copy self.buffer[(self.buffer_start + dist - 1) & 3].tok; } fn fatal(m: ~str) -> ! { self.sess.span_diagnostic.span_fatal(copy self.span, m) @@ -255,7 +255,7 @@ class parser { id: p.get_id()} }; let (ret_style, ret_ty) = self.parse_ret_ty(); - ret {inputs: inputs, output: ret_ty, + return {inputs: inputs, output: ret_ty, purity: purity, cf: ret_style}; } @@ -315,7 +315,7 @@ class parser { fn parse_mt() -> mt { let mutbl = self.parse_mutability(); let t = self.parse_ty(false); - ret {ty: t, mutbl: mutbl}; + return {ty: t, mutbl: mutbl}; } fn parse_ty_field() -> ty_field { @@ -324,11 +324,13 @@ class parser { let id = self.parse_ident(); self.expect(token::COLON); let ty = self.parse_ty(false); - ret spanned(lo, ty.span.hi, {ident: id, mt: {ty: ty, mutbl: mutbl}}); + return spanned(lo, ty.span.hi, { + ident: id, mt: {ty: ty, mutbl: mutbl} + }); } fn parse_ret_ty() -> (ret_style, @ty) { - ret if self.eat(token::RARROW) { + return if self.eat(token::RARROW) { let lo = self.span.lo; if self.eat(token::NOT) { (noreturn, @{id: self.get_id(), @@ -391,7 +393,7 @@ class parser { alt self.maybe_parse_dollar_mac() { some(e) { - ret @{id: self.get_id(), + return @{id: self.get_id(), node: ty_mac(spanned(lo, self.span.hi, e)), span: mk_sp(lo, self.span.hi)}; } @@ -457,7 +459,7 @@ class parser { } else { self.fatal(~"expected type"); }; let sp = mk_sp(lo, self.last_span.hi); - ret @{id: self.get_id(), + return @{id: self.get_id(), node: alt self.maybe_parse_fixed_vstore() { // Consider a fixed vstore suffix (/N or /_) none { t } @@ -596,7 +598,7 @@ class parser { self.bump(); self.lit_from_token(tok) }; - ret {node: lit, span: mk_sp(lo, self.last_span.hi)}; + return {node: lit, span: mk_sp(lo, self.last_span.hi)}; } fn parse_path_without_tps() -> @path { @@ -639,7 +641,7 @@ class parser { let lo = self.span.lo; let path = self.parse_path_without_tps(); if colons && !self.eat(token::MOD_SEP) { - ret path; + return path; } // Parse the region parameter, if any, which will @@ -670,7 +672,7 @@ class parser { } }; - ret @{span: mk_sp(lo, tps.span.hi), + return @{span: mk_sp(lo, tps.span.hi), rp: rp, types: tps.node with *path}; } @@ -691,16 +693,16 @@ class parser { let i = self.parse_ident(); self.expect(sep); let e = self.parse_expr(); - ret spanned(lo, e.span.hi, {mutbl: m, ident: i, expr: e}); + return spanned(lo, e.span.hi, {mutbl: m, ident: i, expr: e}); } fn mk_expr(lo: uint, hi: uint, +node: expr_) -> @expr { - ret @{id: self.get_id(), callee_id: self.get_id(), + return @{id: self.get_id(), callee_id: self.get_id(), node: node, span: mk_sp(lo, hi)}; } fn mk_mac_expr(lo: uint, hi: uint, m: mac_) -> @expr { - ret @{id: self.get_id(), + return @{id: self.get_id(), callee_id: self.get_id(), node: expr_mac({node: m, span: mk_sp(lo, hi)}), span: mk_sp(lo, hi)}; @@ -711,12 +713,12 @@ class parser { let lv_lit = @{node: lit_uint(i as u64, ty_u32), span: span}; - ret @{id: self.get_id(), callee_id: self.get_id(), + return @{id: self.get_id(), callee_id: self.get_id(), node: expr_lit(lv_lit), span: span}; } fn mk_pexpr(lo: uint, hi: uint, node: expr_) -> pexpr { - ret pexpr(self.mk_expr(lo, hi, node)); + return pexpr(self.mk_expr(lo, hi, node)); } fn to_expr(e: pexpr) -> @expr { @@ -734,7 +736,7 @@ class parser { let mut ex: expr_; alt self.maybe_parse_dollar_mac() { - some(x) {ret pexpr(self.mk_mac_expr(lo, self.span.hi, x));} + some(x) {return pexpr(self.mk_mac_expr(lo, self.span.hi, x));} _ {} } @@ -744,7 +746,7 @@ class parser { hi = self.span.hi; self.bump(); let lit = @spanned(lo, hi, lit_nil); - ret self.mk_pexpr(lo, hi, expr_lit(lit)); + return self.mk_pexpr(lo, hi, expr_lit(lit)); } let mut es = ~[self.parse_expr()]; while self.token == token::COMMA { @@ -758,7 +760,7 @@ class parser { // This is so that wrappers around parse_bottom_expr() // can tell whether the expression was parenthesized or not, // which affects expr_is_complete(). - ret self.mk_pexpr(lo, hi, expr_tup(es)); + return self.mk_pexpr(lo, hi, expr_tup(es)); } else if self.token == token::LBRACE { if self.looking_at_record_literal() { ex = self.parse_record_literal(); @@ -766,29 +768,30 @@ class parser { } else { self.bump(); let blk = self.parse_block_tail(lo, default_blk); - ret self.mk_pexpr(blk.span.lo, blk.span.hi, expr_block(blk)); + return self.mk_pexpr(blk.span.lo, blk.span.hi, + expr_block(blk)); } } else if token::is_bar(self.token) { - ret pexpr(self.parse_lambda_expr()); + return pexpr(self.parse_lambda_expr()); } else if self.eat_keyword(~"new") { self.expect(token::LPAREN); let r = self.parse_expr(); self.expect(token::RPAREN); let v = self.parse_expr(); - ret self.mk_pexpr(lo, self.span.hi, + return self.mk_pexpr(lo, self.span.hi, expr_new(r, self.get_id(), v)); } else if self.eat_keyword(~"if") { - ret pexpr(self.parse_if_expr()); + return pexpr(self.parse_if_expr()); } else if self.eat_keyword(~"for") { - ret pexpr(self.parse_sugary_call_expr(~"for", expr_loop_body)); + return pexpr(self.parse_sugary_call_expr(~"for", expr_loop_body)); } else if self.eat_keyword(~"do") { - ret pexpr(self.parse_sugary_call_expr(~"do", expr_do_body)); + return pexpr(self.parse_sugary_call_expr(~"do", expr_do_body)); } else if self.eat_keyword(~"while") { - ret pexpr(self.parse_while_expr()); + return pexpr(self.parse_while_expr()); } else if self.eat_keyword(~"loop") { - ret pexpr(self.parse_loop_expr()); + return pexpr(self.parse_loop_expr()); } else if self.eat_keyword(~"alt") || self.eat_keyword(~"match") { - ret pexpr(self.parse_alt_expr()); + return pexpr(self.parse_alt_expr()); } else if self.eat_keyword(~"fn") { let proto = self.parse_fn_ty_proto(); alt proto { @@ -798,11 +801,11 @@ class parser { } _ { /* fallthrough */ } } - ret pexpr(self.parse_fn_expr(proto)); + return pexpr(self.parse_fn_expr(proto)); } else if self.eat_keyword(~"unchecked") { - ret pexpr(self.parse_block_expr(lo, unchecked_blk)); + return pexpr(self.parse_block_expr(lo, unchecked_blk)); } else if self.eat_keyword(~"unsafe") { - ret pexpr(self.parse_block_expr(lo, unsafe_blk)); + return pexpr(self.parse_block_expr(lo, unsafe_blk)); } else if self.token == token::LBRACKET { self.bump(); let mutbl = self.parse_mutability(); @@ -813,7 +816,7 @@ class parser { ex = expr_vec(es, mutbl); } else if self.token == token::ELLIPSIS { self.bump(); - ret pexpr(self.mk_mac_expr(lo, self.span.hi, mac_ellipsis)); + return pexpr(self.mk_mac_expr(lo, self.span.hi, mac_ellipsis)); } else if self.token == token::POUND { let ex_ext = self.parse_syntax_ext(); hi = ex_ext.span.hi; @@ -875,7 +878,8 @@ class parser { }; let hi = self.span.hi; - ret pexpr(self.mk_mac_expr(lo, hi, mac_invoc_tt(pth, tts))); + return pexpr(self.mk_mac_expr( + lo, hi, mac_invoc_tt(pth, tts))); } else if self.token == token::LBRACE { // This might be a struct literal. if self.looking_at_record_literal() { @@ -895,7 +899,7 @@ class parser { hi = pth.span.hi; self.expect(token::RBRACE); ex = expr_struct(pth, fields); - ret self.mk_pexpr(lo, hi, ex); + return self.mk_pexpr(lo, hi, ex); } } @@ -923,19 +927,19 @@ class parser { _ { } } - ret self.mk_pexpr(lo, hi, ex); + return self.mk_pexpr(lo, hi, ex); } fn parse_block_expr(lo: uint, blk_mode: blk_check_mode) -> @expr { self.expect(token::LBRACE); let blk = self.parse_block_tail(lo, blk_mode); - ret self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); + return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); } fn parse_syntax_ext() -> @expr { let lo = self.span.lo; self.expect(token::POUND); - ret self.parse_syntax_ext_naked(lo); + return self.parse_syntax_ext_naked(lo); } fn parse_syntax_ext_naked(lo: uint) -> @expr { @@ -977,7 +981,7 @@ class parser { let hi = self.last_span.lo; b = some({span: mk_sp(lo,hi)}); } - ret self.mk_mac_expr(lo, self.span.hi, mac_invoc(pth, e, b)); + return self.mk_mac_expr(lo, self.span.hi, mac_invoc(pth, e, b)); } fn parse_dot_or_call_expr() -> pexpr { @@ -986,7 +990,7 @@ class parser { } fn permits_call() -> bool { - ret self.restriction != RESTRICT_NO_CALL_EXPRS; + return self.restriction != RESTRICT_NO_CALL_EXPRS; } fn parse_dot_or_call_expr_with(e0: pexpr) -> pexpr { @@ -1036,10 +1040,10 @@ class parser { e = self.mk_pexpr(lo, hi, expr_index(self.to_expr(e), ix)); } - _ { ret e; } + _ { return e; } } } - ret e; + return e; } fn parse_sep_and_zerok() -> (option<token::token>, bool) { @@ -1047,7 +1051,7 @@ class parser { || self.token == token::BINOP(token::PLUS) { let zerok = self.token == token::BINOP(token::STAR); self.bump(); - ret (none, zerok); + return (none, zerok); } else { let sep = self.token; self.bump(); @@ -1055,7 +1059,7 @@ class parser { || self.token == token::BINOP(token::PLUS) { let zerok = self.token == token::BINOP(token::STAR); self.bump(); - ret (some(sep), zerok); + return (some(sep), zerok); } else { self.fatal(~"expected `*` or `+`"); } @@ -1083,19 +1087,19 @@ class parser { seq_sep_none(), |p| p.parse_token_tree()); let (s, z) = p.parse_sep_and_zerok(); - ret tt_seq(mk_sp(sp.lo ,p.span.hi), seq.node, s, z); + return tt_seq(mk_sp(sp.lo ,p.span.hi), seq.node, s, z); } else { - ret tt_nonterminal(sp, p.parse_ident()); + return tt_nonterminal(sp, p.parse_ident()); } } _ { /* ok */ } } let res = tt_tok(p.span, p.token); p.bump(); - ret res; + return res; } - ret alt self.token { + return alt self.token { token::LPAREN | token::LBRACE | token::LBRACKET { let ket = token::flip_delimiter(self.token); tt_delim(vec::append( @@ -1112,7 +1116,8 @@ class parser { fn parse_matchers() -> ~[matcher] { let name_idx = @mut 0u; - ret self.parse_matcher_subseq(name_idx, token::LBRACE, token::RBRACE); + return self.parse_matcher_subseq( + name_idx, token::LBRACE, token::RBRACE); } @@ -1134,7 +1139,7 @@ class parser { self.bump(); - ret ret_val; + return ret_val; } fn parse_matcher(name_idx: @mut uint) -> matcher { @@ -1165,7 +1170,7 @@ class parser { m }; - ret spanned(lo, self.span.hi, m); + return spanned(lo, self.span.hi, m); } @@ -1211,7 +1216,7 @@ class parser { _ { expr_addr_of(m, e) } }; } - _ { ret self.parse_dot_or_call_expr(); } + _ { return self.parse_dot_or_call_expr(); } } } token::AT { @@ -1238,29 +1243,29 @@ class parser { _ { expr_unary(uniq(m), e) } }; } - _ { ret self.parse_dot_or_call_expr(); } + _ { return self.parse_dot_or_call_expr(); } } - ret self.mk_pexpr(lo, hi, ex); + return self.mk_pexpr(lo, hi, ex); } fn parse_binops() -> @expr { - ret self.parse_more_binops(self.parse_prefix_expr(), 0u); + return self.parse_more_binops(self.parse_prefix_expr(), 0u); } fn parse_more_binops(plhs: pexpr, min_prec: uint) -> @expr { let lhs = self.to_expr(plhs); - if self.expr_is_complete(plhs) { ret lhs; } + if self.expr_is_complete(plhs) { return lhs; } let peeked = self.token; if peeked == token::BINOP(token::OR) && (self.restriction == RESTRICT_NO_BAR_OP || self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP) { - ret lhs; + return lhs; } if peeked == token::OROR && self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP { - ret lhs; + return lhs; } let cur_opt = token_to_binop(peeked); alt cur_opt { @@ -1273,7 +1278,7 @@ class parser { self.get_id(); // see ast_util::op_expr_callee_id let bin = self.mk_pexpr(lhs.span.lo, rhs.span.hi, expr_binary(cur_op, lhs, rhs)); - ret self.parse_more_binops(bin, min_prec); + return self.parse_more_binops(bin, min_prec); } } _ {} @@ -1282,9 +1287,9 @@ class parser { let rhs = self.parse_ty(true); let _as = self.mk_pexpr(lhs.span.lo, rhs.span.hi, expr_cast(lhs, rhs)); - ret self.parse_more_binops(_as, min_prec); + return self.parse_more_binops(_as, min_prec); } - ret lhs; + return lhs; } fn parse_assign_expr() -> @expr { @@ -1294,7 +1299,7 @@ class parser { token::EQ { self.bump(); let rhs = self.parse_expr(); - ret self.mk_expr(lo, rhs.span.hi, expr_assign(lhs, rhs)); + return self.mk_expr(lo, rhs.span.hi, expr_assign(lhs, rhs)); } token::BINOPEQ(op) { self.bump(); @@ -1313,21 +1318,22 @@ class parser { token::SHR { aop = shr; } } self.get_id(); // see ast_util::op_expr_callee_id - ret self.mk_expr(lo, rhs.span.hi, expr_assign_op(aop, lhs, rhs)); + return self.mk_expr(lo, rhs.span.hi, + expr_assign_op(aop, lhs, rhs)); } token::LARROW { self.bump(); let rhs = self.parse_expr(); - ret self.mk_expr(lo, rhs.span.hi, expr_move(lhs, rhs)); + return self.mk_expr(lo, rhs.span.hi, expr_move(lhs, rhs)); } token::DARROW { self.bump(); let rhs = self.parse_expr(); - ret self.mk_expr(lo, rhs.span.hi, expr_swap(lhs, rhs)); + return self.mk_expr(lo, rhs.span.hi, expr_swap(lhs, rhs)); } _ {/* fall through */ } } - ret lhs; + return lhs; } fn parse_if_expr() -> @expr { @@ -1342,7 +1348,7 @@ class parser { hi = elexpr.span.hi; } let q = {cond: cond, then: thn, els: els, lo: lo, hi: hi}; - ret self.mk_expr(q.lo, q.hi, expr_if(q.cond, q.then, q.els)); + return self.mk_expr(q.lo, q.hi, expr_if(q.cond, q.then, q.els)); } fn parse_fn_expr(proto: proto) -> @expr { @@ -1355,7 +1361,7 @@ class parser { |p| p.parse_arg_or_capture_item()); let body = self.parse_block(); - ret self.mk_expr(lo, body.span.hi, + return self.mk_expr(lo, body.span.hi, expr_fn(proto, decl, body, capture_clause)); } @@ -1406,16 +1412,16 @@ class parser { id: self.get_id(), rules: default_blk}; let fakeblock = spanned(body.span.lo, body.span.hi, fakeblock); - ret self.mk_expr(lo, body.span.hi, + return self.mk_expr(lo, body.span.hi, expr_fn_block(decl, fakeblock, captures)); } fn parse_else_expr() -> @expr { if self.eat_keyword(~"if") { - ret self.parse_if_expr(); + return self.parse_if_expr(); } else { let blk = self.parse_block(); - ret self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); + return self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)); } } @@ -1464,14 +1470,14 @@ class parser { let cond = self.parse_expr(); let body = self.parse_block_no_value(); let mut hi = body.span.hi; - ret self.mk_expr(lo, hi, expr_while(cond, body)); + return self.mk_expr(lo, hi, expr_while(cond, body)); } fn parse_loop_expr() -> @expr { let lo = self.last_span.lo; let body = self.parse_block_no_value(); let mut hi = body.span.hi; - ret self.mk_expr(lo, hi, expr_loop(body)); + return self.mk_expr(lo, hi, expr_loop(body)); } // For distingishing between record literals and blocks @@ -1505,7 +1511,7 @@ class parser { vec::push(fields, self.parse_field(token::COLON)); } self.expect(token::RBRACE); - ret expr_rec(fields, base); + return expr_rec(fields, base); } fn parse_alt_expr() -> @expr { @@ -1547,11 +1553,11 @@ class parser { } let mut hi = self.span.hi; self.bump(); - ret self.mk_expr(lo, hi, expr_alt(discriminant, arms, mode)); + return self.mk_expr(lo, hi, expr_alt(discriminant, arms, mode)); } fn parse_expr() -> @expr { - ret self.parse_expr_res(UNRESTRICTED); + return self.parse_expr_res(UNRESTRICTED); } fn parse_expr_res(r: restriction) -> @expr { @@ -1559,28 +1565,28 @@ class parser { self.restriction = r; let e = self.parse_assign_expr(); self.restriction = old; - ret e; + return e; } fn parse_initializer() -> option<initializer> { alt self.token { token::EQ { self.bump(); - ret some({op: init_assign, expr: self.parse_expr()}); + return some({op: init_assign, expr: self.parse_expr()}); } token::LARROW { self.bump(); - ret some({op: init_move, expr: self.parse_expr()}); + return some({op: init_move, expr: self.parse_expr()}); } // Now that the the channel is the first argument to receive, // combining it with an initializer doesn't really make sense. // case (token::RECV) { // self.bump(); - // ret some(rec(op = init_recv, + // return some(rec(op = init_recv, // expr = self.parse_expr())); // } _ { - ret none; + return none; } } } @@ -1590,7 +1596,7 @@ class parser { loop { vec::push(pats, self.parse_pat(true)); if self.token == token::BINOP(token::OR) { self.bump(); } - else { ret pats; } + else { return pats; } }; } @@ -1779,7 +1785,7 @@ class parser { } } } - ret @{id: self.get_id(), node: pat, span: mk_sp(lo, hi)}; + return @{id: self.get_id(), node: pat, span: mk_sp(lo, hi)}; } fn parse_local(is_mutbl: bool, @@ -1791,7 +1797,7 @@ class parser { span: mk_sp(lo, lo)}; if self.eat(token::COLON) { ty = self.parse_ty(false); } let init = if allow_init { self.parse_initializer() } else { none }; - ret @spanned(lo, self.last_span.hi, + return @spanned(lo, self.last_span.hi, {is_mutbl: is_mutbl, ty: ty, pat: pat, init: init, id: self.get_id()}); } @@ -1803,7 +1809,7 @@ class parser { while self.eat(token::COMMA) { vec::push(locals, self.parse_local(is_mutbl, true)); } - ret @spanned(lo, self.last_span.hi, decl_local(locals)); + return @spanned(lo, self.last_span.hi, decl_local(locals)); } /* assumes "let" token has already been consumed */ @@ -1819,7 +1825,7 @@ class parser { let name = self.parse_ident(); self.expect(token::COLON); let ty = self.parse_ty(false); - ret @{node: instance_var(name, ty, is_mutbl, self.get_id(), pr), + return @{node: instance_var(name, ty, is_mutbl, self.get_id(), pr), span: mk_sp(lo, self.last_span.hi)}; } @@ -1836,14 +1842,15 @@ class parser { check_expected_item(self, first_item_attrs); self.expect_keyword(~"let"); let decl = self.parse_let(); - ret @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id())); + 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) { none { item_attrs = ~[]; } some(left(attrs)) { item_attrs = attrs; } some(right(ext)) { - ret @spanned(lo, ext.span.hi, stmt_expr(ext, self.get_id())); + return @spanned(lo, ext.span.hi, + stmt_expr(ext, self.get_id())); } } @@ -1853,7 +1860,7 @@ class parser { some(i) { let mut hi = i.span.hi; let decl = @spanned(lo, hi, decl_item(i)); - ret @spanned(lo, hi, stmt_decl(decl, self.get_id())); + return @spanned(lo, hi, stmt_decl(decl, self.get_id())); } none() { /* fallthrough */ } } @@ -1862,7 +1869,7 @@ class parser { // Remainder are line-expr stmts. let e = self.parse_expr_res(RESTRICT_STMT_EXPR); - ret @spanned(lo, e.span.hi, stmt_expr(e, self.get_id())); + return @spanned(lo, e.span.hi, stmt_expr(e, self.get_id())); } } @@ -1870,14 +1877,14 @@ class parser { log(debug, (~"expr_is_complete", self.restriction, print::pprust::expr_to_str(*e), classify::expr_requires_semi_to_be_stmt(*e))); - ret self.restriction == RESTRICT_STMT_EXPR && + return self.restriction == RESTRICT_STMT_EXPR && !classify::expr_requires_semi_to_be_stmt(*e); } fn parse_block() -> blk { let (attrs, blk) = self.parse_inner_attrs_and_block(false); assert vec::is_empty(attrs); - ret blk; + return blk; } fn parse_inner_attrs_and_block(parse_attrs: bool) @@ -1897,17 +1904,17 @@ class parser { self.expect(token::LBRACE); let {inner, next} = maybe_parse_inner_attrs_and_next(self, parse_attrs); - ret (inner, self.parse_block_tail_(lo, unchecked_blk, next)); + return (inner, self.parse_block_tail_(lo, unchecked_blk, next)); } else if self.eat_keyword(~"unsafe") { self.expect(token::LBRACE); let {inner, next} = maybe_parse_inner_attrs_and_next(self, parse_attrs); - ret (inner, self.parse_block_tail_(lo, unsafe_blk, next)); + return (inner, self.parse_block_tail_(lo, unsafe_blk, next)); } else { self.expect(token::LBRACE); let {inner, next} = maybe_parse_inner_attrs_and_next(self, parse_attrs); - ret (inner, self.parse_block_tail_(lo, default_blk, next)); + return (inner, self.parse_block_tail_(lo, default_blk, next)); } } @@ -1915,7 +1922,7 @@ class parser { // We parse blocks that cannot have a value the same as any other // block; the type checker will make sure that the tail expression (if // any) has unit type. - ret self.parse_block(); + return self.parse_block(); } // Precondition: already parsed the '{' or '#{' @@ -1983,7 +1990,7 @@ class parser { self.bump(); let bloc = {view_items: view_items, stmts: stmts, expr: expr, id: self.get_id(), rules: s}; - ret spanned(lo, hi, bloc); + return spanned(lo, hi, bloc); } fn parse_ty_param() -> ty_param { @@ -2003,7 +2010,7 @@ class parser { push(bounds, bound_trait(self.parse_ty(false))); } } } - ret {ident: ident, id: self.get_id(), bounds: @bounds}; + return {ident: ident, id: self.get_id(), bounds: @bounds}; } fn parse_ty_params() -> ~[ty_param] { @@ -2025,7 +2032,7 @@ class parser { let capture_clause = @either::rights(args_or_capture_items); let (ret_style, ret_ty) = self.parse_ret_ty(); - ret ({inputs: inputs, + return ({inputs: inputs, output: ret_ty, purity: purity, cf: ret_style}, capture_clause); @@ -2183,7 +2190,7 @@ class parser { } else { @{id: self.get_id(), node: ty_infer, span: self.span} }; - ret ({inputs: either::lefts(inputs_captures), + return ({inputs: either::lefts(inputs_captures), output: output, purity: impure_fn, cf: return_val}, @@ -2193,13 +2200,13 @@ class parser { fn parse_fn_header() -> {ident: ident, tps: ~[ty_param]} { let id = self.parse_value_ident(); let ty_params = self.parse_ty_params(); - ret {ident: id, tps: ty_params}; + return {ident: id, tps: ty_params}; } fn mk_item(lo: uint, hi: uint, +ident: ident, +node: item_, vis: visibility, +attrs: ~[attribute]) -> @item { - ret @{ident: ident, + return @{ident: ident, attrs: attrs, id: self.get_id(), node: node, @@ -2441,10 +2448,10 @@ class parser { !self.token_is_pound_or_doc_comment(self.token) { let a_var = self.parse_instance_var(vis); self.expect(token::SEMI); - ret a_var; + return a_var; } else { let m = self.parse_method(vis); - ret @{node: class_method(m), span: m.span}; + return @{node: class_method(m), span: m.span}; } } @@ -2475,21 +2482,21 @@ class parser { vec::push(results, self.parse_single_class_item(private)); } self.bump(); - ret members(results); + return members(results); } let attrs = self.parse_outer_attributes(); if self.eat_keyword(~"new") { // result type is always the type of the class - ret self.parse_ctor(attrs, ty_path(class_name_with_tps, + return self.parse_ctor(attrs, ty_path(class_name_with_tps, self.get_id())); } else if self.eat_keyword(~"drop") { - ret self.parse_dtor(attrs); + return self.parse_dtor(attrs); } else { - ret members(~[self.parse_single_class_item(public)]); + return members(~[self.parse_single_class_item(public)]); } } @@ -2529,7 +2536,7 @@ class parser { self.fatal(~"expected item"); } - ret {view_items: view_items, items: items}; + return {view_items: view_items, items: items}; } fn parse_item_const() -> item_info { @@ -2558,7 +2565,7 @@ class parser { let (decl, _) = self.parse_fn_decl(purity, |p| p.parse_arg()); let mut hi = self.span.hi; self.expect(token::SEMI); - ret @{ident: t.ident, + return @{ident: t.ident, attrs: attrs, node: foreign_item_fn(decl, t.tps), id: self.get_id(), @@ -2595,7 +2602,7 @@ class parser { initial_attrs = ~[]; vec::push(items, self.parse_foreign_item(attrs)); } - ret {view_items: view_items, + return {view_items: view_items, items: items}; } @@ -2616,7 +2623,7 @@ class parser { fn parse_type_decl() -> {lo: uint, ident: ident} { let lo = self.last_span.lo; let id = self.parse_ident(); - ret {lo: lo, ident: id}; + return {lo: lo, ident: id}; } fn parse_item_type() -> item_info { @@ -2654,7 +2661,7 @@ class parser { id: self.get_id(), disr_expr: none, vis: public}); - ret (id, item_enum(~[variant], ty_params), none); + return (id, item_enum(~[variant], ty_params), none); } self.expect(token::LBRACE); @@ -2787,7 +2794,7 @@ class parser { hi: self.span.hi, expn_info: none}}; (id, item_mac(m), none) - } else { ret none; }; + } else { return none; }; some(self.mk_item(lo, self.last_span.hi, ident, item_, vis, alt extra_attrs { some(as) { vec::append(attrs, as) } @@ -2798,7 +2805,7 @@ class parser { fn parse_use() -> view_item_ { let ident = self.parse_ident(); let metadata = self.parse_optional_meta(); - ret view_item_use(ident, metadata, self.get_id()); + return view_item_use(ident, metadata, self.get_id()); } fn parse_view_path() -> @view_path { @@ -2818,7 +2825,7 @@ class parser { } let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: none, types: ~[]}; - ret @spanned(lo, self.span.hi, + return @spanned(lo, self.span.hi, view_path_simple(first_ident, path, self.get_id())); } @@ -2843,7 +2850,7 @@ class parser { let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: none, types: ~[]}; - ret @spanned(lo, self.span.hi, + return @spanned(lo, self.span.hi, view_path_list(path, idents, self.get_id())); } @@ -2853,7 +2860,7 @@ class parser { let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: none, types: ~[]}; - ret @spanned(lo, self.span.hi, + return @spanned(lo, self.span.hi, view_path_glob(path, self.get_id())); } @@ -2866,7 +2873,7 @@ class parser { let last = path[vec::len(path) - 1u]; let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: none, types: ~[]}; - ret @spanned(lo, self.span.hi, + return @spanned(lo, self.span.hi, view_path_simple(last, path, self.get_id())); } @@ -2876,7 +2883,7 @@ class parser { self.bump(); vec::push(vp, self.parse_view_path()); } - ret vp; + return vp; } fn is_view_item() -> bool { @@ -2922,7 +2929,7 @@ class parser { let crate_attrs = self.parse_inner_attrs_and_next(); let first_item_outer_attrs = crate_attrs.next; let m = self.parse_mod_items(token::EOF, first_item_outer_attrs); - ret @spanned(lo, self.span.lo, + return @spanned(lo, self.span.lo, {directives: ~[], module: m, attrs: crate_attrs.inner, @@ -2968,7 +2975,7 @@ class parser { token::SEMI { let mut hi = self.span.hi; self.bump(); - ret spanned(lo, hi, cdir_src_mod(id, outer_attrs)); + return spanned(lo, hi, cdir_src_mod(id, outer_attrs)); } // mod x = "foo_dir" { ...directives... } token::LBRACE { @@ -2980,15 +2987,15 @@ class parser { next_outer_attr); let mut hi = self.span.hi; self.expect(token::RBRACE); - ret spanned(lo, hi, + return spanned(lo, hi, cdir_dir_mod(id, cdirs, mod_attrs)); } _ { self.unexpected(); } } } else if self.is_view_item() { let vi = self.parse_view_item(outer_attrs); - ret spanned(lo, vi.span.hi, cdir_view_item(vi)); - } else { ret self.fatal(~"expected crate directive"); } + return spanned(lo, vi.span.hi, cdir_view_item(vi)); + } else { return self.fatal(~"expected crate directive"); } } fn parse_crate_directives(term: token::token, @@ -3013,7 +3020,7 @@ class parser { vec::push(cdirs, cdir); first_outer_attr = ~[]; } - ret cdirs; + return cdirs; } } // diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index cbea14f3185..9d3bbef2cd4 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -331,7 +331,7 @@ fn restricted_keyword_table() -> hashmap<~str, ()> { ~"new", ~"owned", ~"pure", - ~"ref", ~"ret", ~"return", + ~"ref", ~"return", ~"struct", ~"true", ~"trait", ~"type", ~"unchecked", ~"unsafe", diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index a2479ef1365..9228ea2e0d5 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -63,11 +63,11 @@ enum token { STRING(@~str, int), BREAK(break_t), BEGIN(begin_t), END, EOF, } fn tok_str(++t: token) -> ~str { alt t { - STRING(s, len) { ret fmt!{"STR(%s,%d)", *s, len}; } - BREAK(_) { ret ~"BREAK"; } - BEGIN(_) { ret ~"BEGIN"; } - END { ret ~"END"; } - EOF { ret ~"EOF"; } + STRING(s, len) { return fmt!{"STR(%s,%d)", *s, len}; } + BREAK(_) { return ~"BREAK"; } + BEGIN(_) { return ~"BEGIN"; } + END { return ~"END"; } + EOF { return ~"EOF"; } } } @@ -86,7 +86,7 @@ fn buf_str(toks: ~[mut token], szs: ~[mut int], left: uint, right: uint, i %= n; } s += ~"]"; - ret s; + return s; } enum print_stack_break { fits, broken(breaks), } @@ -333,11 +333,11 @@ impl printer for printer { if self.top == self.bottom { self.scan_stack_empty = true; } else { self.top += self.buf_len - 1u; self.top %= self.buf_len; } - ret x; + return x; } fn scan_top() -> uint { assert (!self.scan_stack_empty); - ret self.scan_stack[self.top]; + return self.scan_stack[self.top]; } fn scan_pop_bottom() -> uint { assert (!self.scan_stack_empty); @@ -345,7 +345,7 @@ impl printer for printer { if self.top == self.bottom { self.scan_stack_empty = true; } else { self.bottom += 1u; self.bottom %= self.buf_len; } - ret x; + return x; } fn advance_right() { self.right += 1u; @@ -517,10 +517,10 @@ fn space(p: printer) { spaces(p, 1u); } fn hardbreak(p: printer) { spaces(p, size_infinity as uint); } fn hardbreak_tok_offset(off: int) -> token { - ret BREAK({offset: off, blank_space: size_infinity}); + return BREAK({offset: off, blank_space: size_infinity}); } -fn hardbreak_tok() -> token { ret hardbreak_tok_offset(0); } +fn hardbreak_tok() -> token { return hardbreak_tok_offset(0); } // diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b02bebf58b7..6a2b5c787de 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -22,7 +22,7 @@ type pp_ann = {pre: fn@(ann_node), post: fn@(ann_node)}; fn no_ann() -> pp_ann { fn ignore(_node: ann_node) { } - ret {pre: ignore, post: ignore}; + return {pre: ignore, post: ignore}; } type ps = @@ -47,7 +47,7 @@ fn end(s: ps) { } fn rust_printer(writer: io::writer) -> ps { - ret @{s: pp::mk_printer(writer, default_columns), + return @{s: pp::mk_printer(writer, default_columns), cm: none::<codemap>, intr: @interner::mk::<@~str>(|x| str::hash(*x), |x,y| str::eq(*x, *y)), @@ -95,24 +95,26 @@ fn print_crate_(s: ps, &&crate: @ast::crate) { eof(s.s); } -fn ty_to_str(ty: @ast::ty) -> ~str { ret to_str(ty, print_type); } +fn ty_to_str(ty: @ast::ty) -> ~str { return to_str(ty, print_type); } -fn pat_to_str(pat: @ast::pat) -> ~str { ret to_str(pat, print_pat); } +fn pat_to_str(pat: @ast::pat) -> ~str { return to_str(pat, print_pat); } -fn expr_to_str(e: @ast::expr) -> ~str { ret to_str(e, print_expr); } +fn expr_to_str(e: @ast::expr) -> ~str { return to_str(e, print_expr); } -fn stmt_to_str(s: ast::stmt) -> ~str { ret to_str(s, print_stmt); } +fn stmt_to_str(s: ast::stmt) -> ~str { return to_str(s, print_stmt); } -fn item_to_str(i: @ast::item) -> ~str { ret to_str(i, print_item); } +fn item_to_str(i: @ast::item) -> ~str { return to_str(i, print_item); } -fn attr_to_str(i: ast::attribute) -> ~str { ret to_str(i, print_attribute); } +fn attr_to_str(i: ast::attribute) -> ~str { + return to_str(i, print_attribute); +} fn typarams_to_str(tps: ~[ast::ty_param]) -> ~str { - ret to_str(tps, print_type_params) + return to_str(tps, print_type_params) } fn path_to_str(&&p: @ast::path) -> ~str { - ret to_str(p, |a,b| print_path(a, b, false)); + return to_str(p, |a,b| print_path(a, b, false)); } fn fun_to_str(decl: ast::fn_decl, name: ast::ident, @@ -152,15 +154,15 @@ fn block_to_str(blk: ast::blk) -> ~str { } fn meta_item_to_str(mi: ast::meta_item) -> ~str { - ret to_str(@mi, print_meta_item); + return to_str(@mi, print_meta_item); } fn attribute_to_str(attr: ast::attribute) -> ~str { - ret to_str(attr, print_attribute); + return to_str(attr, print_attribute); } fn variant_to_str(var: ast::variant) -> ~str { - ret to_str(var, print_variant); + return to_str(var, print_variant); } #[test] @@ -228,14 +230,14 @@ fn is_end(s: ps) -> bool { } fn is_bol(s: ps) -> bool { - ret s.s.last_token() == pp::EOF || + return s.s.last_token() == pp::EOF || s.s.last_token() == pp::hardbreak_tok(); } fn in_cbox(s: ps) -> bool { let len = s.boxes.len(); - if len == 0u { ret false; } - ret s.boxes[len - 1u] == pp::consistent; + if len == 0u { return false; } + return s.boxes[len - 1u] == pp::consistent; } fn hardbreak_if_not_bol(s: ps) { if !is_bol(s) { hardbreak(s.s); } } @@ -294,7 +296,7 @@ fn commasep_cmnt<IN>(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN), } fn commasep_exprs(s: ps, b: breaks, exprs: ~[@ast::expr]) { - fn expr_span(&&expr: @ast::expr) -> codemap::span { ret expr.span; } + fn expr_span(&&expr: @ast::expr) -> codemap::span { return expr.span; } commasep_cmnt(s, b, exprs, print_expr, expr_span); } @@ -365,7 +367,7 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { print_type(s, f.node.mt.ty); end(s); } - fn get_span(f: ast::ty_field) -> codemap::span { ret f.span; } + fn get_span(f: ast::ty_field) -> codemap::span { return f.span; } commasep_cmnt(s, consistent, fields, print_field, get_span); word(s.s, ~",}"); } @@ -805,7 +807,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, s.ann.post(ann_node); } -// ret and fail, without arguments cannot appear is the discriminant of if, +// 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 { @@ -909,7 +911,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_expr(s, field.node.expr); end(s); } - fn get_span(field: ast::field) -> codemap::span { ret field.span; } + fn get_span(field: ast::field) -> codemap::span { return field.span; } maybe_print_comment(s, expr.span.lo); ibox(s, indent_unit); @@ -1162,7 +1164,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_break { word(s.s, ~"break"); } ast::expr_again { word(s.s, ~"again"); } ast::expr_ret(result) { - word(s.s, ~"ret"); + word(s.s, ~"return"); alt result { some(expr) { word(s.s, ~" "); print_expr(s, expr); } _ { } @@ -1339,7 +1341,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) { print_pat(s, f.pat); end(s); } - fn get_span(f: ast::field_pat) -> codemap::span { ret f.pat.span; } + fn get_span(f: ast::field_pat) -> codemap::span { return f.pat.span; } commasep_cmnt(s, consistent, fields, print_field, get_span); if etc { if vec::len(fields) != 0u { word_space(s, ~","); } @@ -1603,10 +1605,10 @@ 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; } _ { ret; } } + alt s.cm { some(ccm) { cm = ccm; } _ { return; } } alt next_comment(s) { some(cmnt) { - if cmnt.style != comments::trailing { ret; } + 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; @@ -1638,7 +1640,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) { alt next_lit(s, lit.span.lo) { some(ltrl) { word(s.s, ltrl.lit); - ret; + return; } _ {} } @@ -1680,20 +1682,20 @@ fn print_literal(s: ps, &&lit: @ast::lit) { } } -fn lit_to_str(l: @ast::lit) -> ~str { ret to_str(l, print_literal); } +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 { some(lits) { while s.cur_lit < vec::len(lits) { let ltrl = lits[s.cur_lit]; - if ltrl.pos > pos { ret none; } + if ltrl.pos > pos { return none; } s.cur_lit += 1u; - if ltrl.pos == pos { ret some(ltrl); } + if ltrl.pos == pos { return some(ltrl); } } - ret none; + return none; } - _ { ret none; } + _ { return none; } } } @@ -1773,10 +1775,10 @@ fn next_comment(s: ps) -> option<comments::cmnt> { alt s.comments { some(cmnts) { if s.cur_cmnt < vec::len(cmnts) { - ret some(cmnts[s.cur_cmnt]); - } else { ret none::<comments::cmnt>; } + return some(cmnts[s.cur_cmnt]); + } else { return none::<comments::cmnt>; } } - _ { ret none::<comments::cmnt>; } + _ { return none::<comments::cmnt>; } } } @@ -1804,7 +1806,7 @@ fn print_purity(s: ps, p: ast::purity) { } fn proto_to_str(p: ast::proto) -> ~str { - ret alt p { + return alt p { ast::proto_bare { ~"extern fn" } ast::proto_any { ~"fn" } ast::proto_block { ~"fn&" } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 4886b903d73..5c2f78bce3b 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -15,7 +15,7 @@ fn mk<T: const copy>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> { let m = map::hashmap::<T, uint>(hasher, eqer); let hi: hash_interner<T> = {map: m, vect: dvec(), hasher: hasher, eqer: eqer}; - ret hi as interner::<T>; + return hi as interner::<T>; } /* when traits can extend traits, we should extend index<uint,T> to get [] */ @@ -28,12 +28,12 @@ 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) { - some(idx) { ret idx; } + some(idx) { return idx; } none { let new_idx = self.vect.len(); self.map.insert(val, new_idx); self.vect.push(val); - ret new_idx; + return new_idx; } } } @@ -43,5 +43,5 @@ impl <T: const copy> of interner<T> for hash_interner<T> { // where we first check a pred and then rely on it, ceasing to fail is ok. pure fn get(idx: uint) -> T { self.vect.get_elt(idx) } - fn len() -> uint { ret self.vect.len(); } + fn len() -> uint { return self.vect.len(); } } \ No newline at end of file diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 5cf73da1944..4cbe13b6d5c 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -64,7 +64,7 @@ type visitor<E> = visit_class_item: fn@(@class_member, E, vt<E>)}; fn default_visitor<E>() -> visitor<E> { - ret @{visit_mod: |a,b,c,d,e|visit_mod::<E>(a, b, c, d, e), + return @{visit_mod: |a,b,c,d,e|visit_mod::<E>(a, b, c, d, e), visit_view_item: |a,b,c|visit_view_item::<E>(a, b, c), visit_foreign_item: |a,b,c|visit_foreign_item::<E>(a, b, c), visit_item: |a,b,c|visit_item::<E>(a, b, c), @@ -466,7 +466,7 @@ type simple_visitor = fn simple_ignore_ty(_t: @ty) {} fn default_simple_visitor() -> simple_visitor { - ret @{visit_mod: fn@(_m: _mod, _sp: span, _id: node_id) { }, + return @{visit_mod: fn@(_m: _mod, _sp: span, _id: node_id) { }, visit_view_item: fn@(_vi: @view_item) { }, visit_foreign_item: fn@(_ni: @foreign_item) { }, visit_item: fn@(_i: @item) { }, @@ -574,7 +574,7 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(cm); visit_class_item(cm, e, v); } - ret mk_vt(@{visit_mod: |a,b,c,d,e|v_mod(v.visit_mod, a, b, c, d, e), + return mk_vt(@{visit_mod: |a,b,c,d,e|v_mod(v.visit_mod, a, b, c, d, e), visit_view_item: |a,b,c| v_view_item(v.visit_view_item, a, b, c), visit_foreign_item: diff --git a/src/rustc/back/abi.rs b/src/rustc/back/abi.rs index 8213ff1576e..706c8ed991e 100644 --- a/src/rustc/back/abi.rs +++ b/src/rustc/back/abi.rs @@ -66,13 +66,13 @@ const worst_case_glue_call_args: uint = 7u; const abi_version: uint = 1u; -fn memcpy_glue_name() -> ~str { ret ~"rust_memcpy_glue"; } +fn memcpy_glue_name() -> ~str { return ~"rust_memcpy_glue"; } -fn bzero_glue_name() -> ~str { ret ~"rust_bzero_glue"; } +fn bzero_glue_name() -> ~str { return ~"rust_bzero_glue"; } -fn yield_glue_name() -> ~str { ret ~"rust_yield_glue"; } +fn yield_glue_name() -> ~str { return ~"rust_yield_glue"; } -fn no_op_type_glue_name() -> ~str { ret ~"rust_no_op_type_glue"; } +fn no_op_type_glue_name() -> ~str { return ~"rust_no_op_type_glue"; } // // Local Variables: // mode: rust diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index fede7d55af9..7e6c9567b4b 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -51,9 +51,9 @@ mod write { fn is_object_or_assembly_or_exe(ot: output_type) -> bool { if ot == output_type_assembly || ot == output_type_object || ot == output_type_exe { - ret true; + return true; } - ret false; + return false; } // Decides what to call an intermediate file, given the name of the output @@ -64,7 +64,7 @@ mod write { some(dot_pos) { str::slice(output_path, 0u, dot_pos) } none { output_path } }; - ret stem + ~"." + extension; + return stem + ~"." + extension; } fn run_passes(sess: session, llmod: ModuleRef, output: ~str) { @@ -234,7 +234,7 @@ mod write { llvm::LLVMDisposeModule(llmod); if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); } - ret; + return; } if opts.output_type == output_type_llvm_assembly { @@ -334,7 +334,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, } } else { vec::push(cmh_items, meta); } } - ret {name: name, vers: vers, cmh_items: cmh_items}; + return {name: name, vers: vers, cmh_items: cmh_items}; } // This calculates CMH as defined above @@ -343,11 +343,11 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, metas: provided_metas, dep_hashes: ~[@~str]) -> ~str { fn len_and_str(s: ~str) -> ~str { - ret fmt!{"%u_%s", str::len(s), s}; + return fmt!{"%u_%s", str::len(s), s}; } fn len_and_str_lit(l: ast::lit) -> ~str { - ret len_and_str(pprust::lit_to_str(@l)); + return len_and_str(pprust::lit_to_str(@l)); } let cmh_items = attr::sort_meta_items(metas.cmh_items); @@ -374,18 +374,18 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, symbol_hasher.input_str(len_and_str(*dh)); } - ret truncated_hash_result(symbol_hasher); + return truncated_hash_result(symbol_hasher); } fn warn_missing(sess: session, name: ~str, default: ~str) { - if !sess.building_library { ret; } + if !sess.building_library { return; } sess.warn(fmt!{"missing crate link meta `%s`, using `%s` as default", name, default}); } fn crate_meta_name(sess: session, _crate: ast::crate, output: ~str, metas: provided_metas) -> @~str { - ret alt metas.name { + return alt 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 { - ret alt metas.vers { + return alt metas.vers { some(v) { v } none { let vers = ~"0.0"; @@ -424,7 +424,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, let extras_hash = crate_meta_extras_hash(symbol_hasher, c, provided_metas, dep_hashes); - ret {name: name, vers: vers, extras_hash: extras_hash}; + return {name: name, vers: vers, extras_hash: extras_hash}; } fn truncated_hash_result(symbol_hasher: hash::streaming) -> ~str unsafe { @@ -447,16 +447,16 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: hash::streaming, t: ty::t, let hash = truncated_hash_result(symbol_hasher); // Prefix with _ so that it never blends into adjacent digits - ret ~"_" + hash; + return ~"_" + hash; } fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { alt ccx.type_hashcodes.find(t) { - some(h) { ret h; } + some(h) { return h; } none { let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta); ccx.type_hashcodes.insert(t, hash); - ret hash; + return hash; } } } @@ -491,10 +491,10 @@ fn sanitize(s: ~str) -> ~str { if result.len() > 0u && result[0] != '_' as u8 && ! char::is_XID_start(result[0] as char) { - ret ~"_" + result; + return ~"_" + result; } - ret result; + return result; } fn mangle(ss: path) -> ~str { @@ -513,14 +513,14 @@ fn mangle(ss: path) -> ~str { } fn exported_name(path: path, hash: @~str, vers: @~str) -> ~str { - ret mangle( + return mangle( vec::append_one(vec::append_one(path, path_name(hash)), path_name(vers))); } fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> ~str { let hash = get_symbol_hash(ccx, t); - ret exported_name(path, @hash, ccx.link_meta.vers); + return exported_name(path, @hash, ccx.link_meta.vers); } fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, @@ -528,20 +528,20 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, ~str { let s = @util::ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); - ret mangle(~[path_name(name), path_name(s), path_name(@hash)]); + return mangle(~[path_name(name), path_name(s), path_name(@hash)]); } fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, flav: @~str) -> ~str { - ret mangle(vec::append_one(path, path_name(@ccx.names(*flav)))); + return mangle(vec::append_one(path, path_name(@ccx.names(*flav)))); } fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> ~str { - ret mangle(path); + return mangle(path); } fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @~str) -> ~str { - ret ccx.names(*flav); + return ccx.names(*flav); } // If the user wants an exe generated we need to invoke @@ -558,15 +558,15 @@ fn link_binary(sess: session, (config.os == session::os_linux || config.os == session::os_freebsd) && option::is_some(found) && option::get(found) == 0u { - ret str::slice(filename, 3u, str::len(filename)); - } else { ret filename; } + return str::slice(filename, 3u, str::len(filename)); + } else { return filename; } }; fn rmext(filename: ~str) -> ~str { let mut parts = str::split_char(filename, '.'); vec::pop(parts); - ret str::connect(parts, ~"."); + return str::connect(parts, ~"."); } - ret alt config.os { + return alt 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 4f85fb48f2a..d92c5f8379e 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -18,7 +18,7 @@ fn get_rpath_flags(sess: session::session, out_filename: ~str) -> ~[~str] { // No rpath on windows if os == session::os_win32 { - ret ~[]; + return ~[]; } debug!{"preparing the RPATH!"}; @@ -89,7 +89,7 @@ fn get_rpaths(os: session::os, cwd: path::path, sysroot: path::path, // Remove duplicates let rpaths = minimize_rpaths(rpaths); - ret rpaths; + return rpaths; } fn get_rpaths_relative_to_output(os: session::os, @@ -148,9 +148,9 @@ fn get_relative_to(abs1: path::path, abs2: path::path) -> path::path { vec::push_all(path, vec::view(split2, start_idx, len2 - 1u)); if vec::is_not_empty(path) { - ret path::connect_many(path); + return path::connect_many(path); } else { - ret ~"."; + return ~"."; } } @@ -192,7 +192,7 @@ fn minimize_rpaths(rpaths: ~[~str]) -> ~[~str] { set.insert(rpath, ()); } } - ret minimized; + return minimized; } #[cfg(unix)] diff --git a/src/rustc/back/upcall.rs b/src/rustc/back/upcall.rs index 94c69976c8c..0b6b2455ac7 100644 --- a/src/rustc/back/upcall.rs +++ b/src/rustc/back/upcall.rs @@ -36,7 +36,7 @@ fn declare_upcalls(targ_cfg: @session::config, let mut arg_tys: ~[TypeRef] = ~[]; for tys.each |t| { vec::push(arg_tys, t); } let fn_ty = T_fn(arg_tys, rv); - ret base::decl_cdecl_fn(llmod, prefix + name, fn_ty); + return base::decl_cdecl_fn(llmod, prefix + name, fn_ty); } fn nothrow(f: ValueRef) -> ValueRef { base::set_no_unwind(f); f @@ -47,7 +47,7 @@ fn declare_upcalls(targ_cfg: @session::config, let int_t = T_int(targ_cfg); let size_t = T_size_t(targ_cfg); - ret @{_fail: dv(~"fail", ~[T_ptr(T_i8()), + return @{_fail: dv(~"fail", ~[T_ptr(T_i8()), T_ptr(T_i8()), size_t]), trace: dv(~"trace", ~[T_ptr(T_i8()), diff --git a/src/rustc/back/x86.rs b/src/rustc/back/x86.rs index a7cd20e875b..93001f5e06a 100644 --- a/src/rustc/back/x86.rs +++ b/src/rustc/back/x86.rs @@ -3,7 +3,7 @@ import session::sess_os_to_meta_os; import metadata::loader::meta_section_name; fn get_target_strs(target_os: session::os) -> target_strs::t { - ret { + return { module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), diff --git a/src/rustc/back/x86_64.rs b/src/rustc/back/x86_64.rs index 63399cd2b41..76a63fbf3d9 100644 --- a/src/rustc/back/x86_64.rs +++ b/src/rustc/back/x86_64.rs @@ -3,7 +3,7 @@ import session::sess_os_to_meta_os; import metadata::loader::meta_section_name; fn get_target_strs(target_os: session::os) -> target_strs::t { - ret { + return { module_asm: ~"", meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 387f62034da..fd4f29a6ad0 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -50,7 +50,7 @@ fn default_configuration(sess: session, argv0: ~str, input: input) -> session::arch_arm { ~"arm" } }; - ret ~[ // Target bindings. + return ~[ // Target bindings. attr::mk_word_item(@os::family()), mk(@~"target_os", os::sysname()), mk(@~"target_family", os::family()), @@ -76,7 +76,7 @@ fn build_configuration(sess: session, argv0: ~str, input: input) -> ~[attr::mk_word_item(@~"notest")] } }; - ret vec::append(vec::append(user_cfg, gen_cfg), default_cfg); + return vec::append(vec::append(user_cfg, gen_cfg), default_cfg); } // Convert strings provided as --cfg [cfgspec] into a crate_cfg @@ -86,7 +86,7 @@ fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg { // meta_word variant. let mut words = ~[]; for cfgspecs.each |s| { vec::push(words, attr::mk_word_item(@s)); } - ret words; + return words; } enum input { @@ -111,13 +111,13 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) } fn time<T>(do_it: bool, what: ~str, thunk: fn() -> T) -> T { - if !do_it { ret thunk(); } + if !do_it { return thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); let end = std::time::precise_time_s(); io::stdout().write_str(fmt!{"time: %3.3f s\t%s\n", end - start, what}); - ret rv; + return rv; } enum compile_upto { @@ -135,7 +135,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, let time_passes = sess.time_passes(); let mut crate = time(time_passes, ~"parsing", ||parse_input(sess, cfg, input) ); - if upto == cu_parse { ret {crate: crate, tcx: none}; } + if upto == cu_parse { return {crate: crate, tcx: none}; } sess.building_library = session::building_library( sess.opts.crate_type, crate, sess.opts.test); @@ -150,7 +150,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, syntax::ext::expand::expand_crate(sess.parse_sess, sess.opts.cfg, crate)); - if upto == cu_expand { ret {crate: crate, tcx: none}; } + if upto == cu_expand { return {crate: crate, tcx: none}; } crate = time(time_passes, ~"intrinsic injection", || front::intrinsic_inject::inject_intrinsic(sess, crate)); @@ -205,7 +205,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, middle::check_const::check_crate(sess, crate, ast_map, def_map, method_map, ty_cx)); - if upto == cu_typeck { ret {crate: crate, tcx: some(ty_cx)}; } + if upto == cu_typeck { return {crate: crate, tcx: some(ty_cx)}; } time(time_passes, ~"block-use checking", || middle::block_use::check_crate(ty_cx, crate)); @@ -228,7 +228,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, time(time_passes, ~"lint checking", || lint::check_crate(ty_cx, crate)); - if upto == cu_no_trans { ret {crate: crate, tcx: some(ty_cx)}; } + if upto == cu_no_trans { return {crate: crate, tcx: some(ty_cx)}; } let outputs = option::get(outputs); let maps = {mutbl_map: mutbl_map, root_map: root_map, @@ -247,13 +247,13 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, sess.opts.output_type != link::output_type_exe || sess.opts.static && sess.building_library; - if stop_after_codegen { ret {crate: crate, tcx: some(ty_cx)}; } + if stop_after_codegen { return {crate: crate, tcx: some(ty_cx)}; } time(time_passes, ~"linking", || link::link_binary(sess, outputs.obj_filename, outputs.out_filename, link_meta)); - ret {crate: crate, tcx: some(ty_cx)}; + return {crate: crate, tcx: some(ty_cx)}; } fn compile_input(sess: session, cfg: ast::crate_cfg, input: input, @@ -338,7 +338,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, } fn get_os(triple: ~str) -> option<session::os> { - ret if str::contains(triple, ~"win32") || + if str::contains(triple, ~"win32") || str::contains(triple, ~"mingw32") { some(session::os_win32) } else if str::contains(triple, ~"darwin") { @@ -347,11 +347,12 @@ fn get_os(triple: ~str) -> option<session::os> { some(session::os_linux) } else if str::contains(triple, ~"freebsd") { some(session::os_freebsd) - } else { none }; + } else { none } } fn get_arch(triple: ~str) -> option<session::arch> { - ret if str::contains(triple, ~"i386") || str::contains(triple, ~"i486") || + if str::contains(triple, ~"i386") || + str::contains(triple, ~"i486") || str::contains(triple, ~"i586") || str::contains(triple, ~"i686") || str::contains(triple, ~"i786") { @@ -361,7 +362,7 @@ fn get_arch(triple: ~str) -> option<session::arch> { } else if str::contains(triple, ~"arm") || str::contains(triple, ~"xscale") { some(session::arch_arm) - } else { none }; + } else { none } } fn build_target_config(sopts: @session::options, @@ -388,7 +389,7 @@ fn build_target_config(sopts: @session::options, let target_cfg: @session::config = @{os: os, arch: arch, target_strs: target_strs, int_type: int_type, uint_type: uint_type, float_type: float_type}; - ret target_cfg; + return target_cfg; } fn host_triple() -> ~str { @@ -401,7 +402,7 @@ fn host_triple() -> ~str { // be grabbing (at compile time) the target triple that this rustc is // built with and calling that (at runtime) the host triple. let ht = env!{"CFG_HOST_TRIPLE"}; - ret if ht != ~"" { + return if ht != ~"" { ht } else { fail ~"rustc built without CFG_HOST_TRIPLE" @@ -530,7 +531,7 @@ fn build_session_options(matches: getopts::matches, parse_only: parse_only, no_trans: no_trans, debugging_opts: debugging_opts}; - ret sopts; + return sopts; } fn build_session(sopts: @session::options, @@ -573,22 +574,23 @@ fn build_session_(sopts: @session::options, fn parse_pretty(sess: session, &&name: ~str) -> pp_mode { if str::eq(name, ~"normal") { - ret ppm_normal; + return ppm_normal; } else if str::eq(name, ~"expanded") { - ret ppm_expanded; + return ppm_expanded; } else if str::eq(name, ~"typed") { - ret ppm_typed; + return ppm_typed; } else if str::eq(name, ~"expanded,identified") { - ret ppm_expanded_identified; + return ppm_expanded_identified; } else if str::eq(name, ~"identified") { - ret ppm_identified; + return ppm_identified; } sess.fatal(~"argument to `pretty` must be one of `normal`, `typed`, or " + ~"`identified`"); } fn opts() -> ~[getopts::opt] { - ret ~[optflag(~"h"), optflag(~"help"), optflag(~"v"), optflag(~"version"), + return ~[optflag(~"h"), optflag(~"help"), + optflag(~"v"), optflag(~"version"), optflag(~"emit-llvm"), optflagopt(~"pretty"), optflag(~"ls"), optflag(~"parse-only"), optflag(~"no-trans"), optflag(~"O"), optopt(~"opt-level"), optmulti(~"L"), optflag(~"S"), @@ -699,7 +701,7 @@ fn build_output_filenames(input: input, } } } - ret @{out_filename: out_path, + return @{out_filename: out_path, obj_filename: obj_path}; } diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 5a592434710..14d00c2d547 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -121,7 +121,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { let mut args = args; let binary = vec::shift(args); - if vec::len(args) == 0u { usage(binary); ret; } + if vec::len(args) == 0u { usage(binary); return; } let matches = alt getopts::getopts(args, opts()) { @@ -133,24 +133,24 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { if opt_present(matches, ~"h") || opt_present(matches, ~"help") { usage(binary); - ret; + return; } let lint_flags = vec::append(getopts::opt_strs(matches, ~"W"), getopts::opt_strs(matches, ~"warn")); if lint_flags.contains(~"help") { describe_warnings(); - ret; + return; } if getopts::opt_strs(matches, ~"Z").contains(~"help") { describe_debug_flags(); - ret; + return; } if opt_present(matches, ~"v") || opt_present(matches, ~"version") { version(binary); - ret; + return; } let input = alt vec::len(matches.free) { 0u { early_error(demitter, ~"no input filename given") } @@ -176,7 +176,10 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { ~"normal"), |a| parse_pretty(sess, a) ); alt pretty { - some::<pp_mode>(ppm) { pretty_print_input(sess, cfg, input, ppm); ret; } + some::<pp_mode>(ppm) { + pretty_print_input(sess, cfg, input, ppm); + return; + } none::<pp_mode> {/* continue */ } } let ls = opt_present(matches, ~"ls"); @@ -189,7 +192,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { early_error(demitter, ~"can not list metadata for stdin"); } } - ret; + return; } compile_input(sess, cfg, input, odir, ofile); diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 173c66fba1d..e70c97754b9 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -168,7 +168,7 @@ impl session for session { self.span_lint_level(level, span, msg); } fn next_node_id() -> ast::node_id { - ret syntax::parse::next_node_id(self.parse_sess); + return syntax::parse::next_node_id(self.parse_sess); } fn diagnostic() -> diagnostic::span_handler { self.span_diagnostic diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index c633cf5d2af..9deaae5ecf1 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -31,7 +31,7 @@ fn strip_items(crate: @ast::crate, in_cfg: in_cfg_pred) let fold = fold::make_fold(precursor); let res = @fold.fold_crate(*crate); - ret res; + return res; } fn filter_item(cx: ctxt, &&item: @ast::item) -> @@ -54,8 +54,10 @@ fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) -> let filtered_items = vec::filter_map(m.items, item_filter); let view_item_filter = |a| filter_view_item(cx, a); let filtered_view_items = vec::filter_map(m.view_items, view_item_filter); - ret {view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)), - items: vec::filter_map(filtered_items, |x| fld.fold_item(x))}; + return { + view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)), + items: vec::filter_map(filtered_items, |x| fld.fold_item(x)) + }; } fn filter_foreign_item(cx: ctxt, &&item: @ast::foreign_item) -> @@ -72,8 +74,10 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod, let view_item_filter = |a| filter_view_item(cx, a); let filtered_view_items = vec::filter_map( nm.view_items, view_item_filter); - ret {view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)), - items: filtered_items}; + return { + view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)), + items: filtered_items + }; } fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) -> @@ -97,7 +101,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) -> ast::blk_ { let filter = |a| filter_stmt(cx, a); let filtered_stmts = vec::filter_map(b.stmts, filter); - ret {view_items: b.view_items, + return {view_items: b.view_items, stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(x)), expr: option::map(b.expr, |x| fld.fold_expr(x)), id: b.id, @@ -105,15 +109,15 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) -> } fn item_in_cfg(cx: ctxt, item: @ast::item) -> bool { - ret cx.in_cfg(item.attrs); + return cx.in_cfg(item.attrs); } fn foreign_item_in_cfg(cx: ctxt, item: @ast::foreign_item) -> bool { - ret cx.in_cfg(item.attrs); + return cx.in_cfg(item.attrs); } fn view_item_in_cfg(cx: ctxt, item: @ast::view_item) -> bool { - ret cx.in_cfg(item.attrs); + return cx.in_cfg(item.attrs); } // Determine if an item should be translated in the current crate @@ -134,13 +138,13 @@ fn metas_in_cfg(cfg: ast::crate_cfg, metas: ~[@ast::meta_item]) -> bool { |&&i| attr::get_meta_item_list(i) )); let has_cfg_metas = vec::len(cfg_metas) > 0u; - if !has_cfg_metas { ret true; } + if !has_cfg_metas { return true; } for cfg_metas.each |cfg_mi| { - if attr::contains(cfg, cfg_mi) { ret true; } + if attr::contains(cfg, cfg_mi) { return true; } } - ret false; + return false; } diff --git a/src/rustc/front/core_inject.rs b/src/rustc/front/core_inject.rs index 24b1a8094e3..7103c736206 100644 --- a/src/rustc/front/core_inject.rs +++ b/src/rustc/front/core_inject.rs @@ -23,7 +23,7 @@ fn inject_libcore_ref(sess: session, crate: @ast::crate) -> @ast::crate { fn spanned<T: copy>(x: T) -> @ast::spanned<T> { - ret @{node: x, + return @{node: x, span: dummy_sp()}; } @@ -43,6 +43,6 @@ fn inject_libcore_ref(sess: session, let vis = vec::append(~[vi1, vi2], crate.node.module.view_items); - ret @{node: {module: { view_items: vis with crate.node.module } + return @{node: {module: { view_items: vis with crate.node.module } with crate.node} with *crate } } diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index 920d4e2ee8c..34a60fda151 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -24,6 +24,6 @@ fn inject_intrinsic(sess: session, let items = vec::append(~[item], crate.node.module.items); - ret @{node: {module: { items: items with crate.node.module } + return @{node: {module: { items: items with crate.node.module } with crate.node} with *crate } } diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 1cf825a5e6b..87011c2ad33 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -51,7 +51,7 @@ fn generate_test_harness(sess: session::session, let fold = fold::make_fold(precursor); let res = @fold.fold_crate(*crate); - ret res; + return res; } fn strip_test_functions(crate: @ast::crate) -> @ast::crate { @@ -82,7 +82,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { let mod_nomain = {view_items: m.view_items, items: vec::filter_map(m.items, nomain)}; - ret fold::noop_fold_mod(mod_nomain, fld); + return fold::noop_fold_mod(mod_nomain, fld); } fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) -> @@ -91,7 +91,7 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) -> // Add a special __test module to the crate that will contain code // generated for the test harness - ret {module: add_test_module(cx, folded.module) with folded}; + return {module: add_test_module(cx, folded.module) with folded}; } @@ -121,7 +121,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> let res = fold::noop_fold_item(i, fld); vec::pop(cx.path); - ret res; + return res; } fn is_test_fn(i: @ast::item) -> bool { @@ -140,7 +140,7 @@ fn is_test_fn(i: @ast::item) -> bool { } } - ret has_test_attr && has_test_signature(i); + return has_test_attr && has_test_signature(i); } fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool { @@ -148,7 +148,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool { let ignoreitems = attr::attr_metas(ignoreattrs); let cfg_metas = vec::concat(vec::filter_map(ignoreitems, |&&i| attr::get_meta_item_list(i) )); - ret if vec::is_not_empty(ignoreitems) { + return if vec::is_not_empty(ignoreitems) { config::metas_in_cfg(cx.crate.node.config, cfg_metas) } else { false @@ -161,7 +161,7 @@ fn should_fail(i: @ast::item) -> bool { fn add_test_module(cx: test_ctxt, m: ast::_mod) -> ast::_mod { let testmod = mk_test_module(cx); - ret {items: vec::append_one(m.items, testmod) with m}; + return {items: vec::append_one(m.items, testmod) with m}; } /* @@ -203,11 +203,11 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { debug!{"Synthetic test module:\n%s\n", pprust::item_to_str(@item)}; - ret @item; + return @item; } fn nospan<T: copy>(t: T) -> ast::spanned<T> { - ret {node: t, span: dummy_sp()}; + return {node: t, span: dummy_sp()}; } fn path_node(ids: ~[ast::ident]) -> @ast::path { @@ -238,7 +238,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item { node: item_, vis: ast::public, span: dummy_sp()}; - ret @item; + return @item; } fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] { @@ -270,7 +270,7 @@ fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty { let inner_ty = @{id: cx.sess.next_node_id(), node: ast::ty_vec(vec_mt), span: dummy_sp()}; - ret @{id: cx.sess.next_node_id(), + return @{id: cx.sess.next_node_id(), node: ast::ty_uniq({ty: inner_ty, mutbl: ast::m_imm}), span: dummy_sp()}; } @@ -286,7 +286,7 @@ fn mk_test_desc_vec(cx: test_ctxt) -> @ast::expr { callee_id: cx.sess.next_node_id(), node: ast::expr_vec(descs, ast::m_imm), span: dummy_sp()}; - ret @{id: cx.sess.next_node_id(), + return @{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(), node: ast::expr_vstore(inner_expr, ast::vstore_uniq), span: dummy_sp()}; @@ -358,7 +358,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr { let desc_rec: ast::expr = {id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(), node: desc_rec_, span: span}; - ret @desc_rec; + return @desc_rec; } // Produces a bare function that wraps the test function @@ -400,7 +400,7 @@ fn mk_test_wrapper(cx: test_ctxt, span: span }; - ret @wrapper_expr; + return @wrapper_expr; } fn mk_main(cx: test_ctxt) -> @ast::item { @@ -451,7 +451,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { node: item_, vis: ast::public, span: dummy_sp()}; - ret @item; + return @item; } fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { @@ -497,7 +497,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr { {id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(), node: test_main_call_expr_, span: dummy_sp()}; - ret @test_main_call_expr; + return @test_main_call_expr; } // Local Variables: diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 68fcb8c9183..2a327a25b11 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -995,28 +995,28 @@ fn associate_type(tn: type_names, s: ~str, t: TypeRef) { } fn type_has_name(tn: type_names, t: TypeRef) -> option<~str> { - ret tn.type_names.find(t); + return tn.type_names.find(t); } fn name_has_type(tn: type_names, s: ~str) -> option<TypeRef> { - ret tn.named_types.find(s); + return tn.named_types.find(s); } fn mk_type_names() -> type_names { - fn hash(&&t: TypeRef) -> uint { ret t as uint; } - fn eq(&&a: TypeRef, &&b: TypeRef) -> bool { ret a as uint == b as uint; } + fn hash(&&t: TypeRef) -> uint { return t as uint; } + fn eq(&&a: TypeRef, &&b: TypeRef) -> bool { a as uint == b as uint } @{type_names: std::map::hashmap(hash, eq), named_types: std::map::str_hash()} } fn type_to_str(names: type_names, ty: TypeRef) -> ~str { - ret type_to_str_inner(names, ~[], ty); + return type_to_str_inner(names, ~[], ty); } fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> ~str { alt type_has_name(names, ty) { - option::some(n) { ret n; } + option::some(n) { return n; } _ {} } @@ -1032,20 +1032,20 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> if first { first = false; } else { s += ~", "; } s += type_to_str_inner(names, outer, t); } - ret s; + return s; } alt kind { - Void { ret ~"Void"; } - Half { ret ~"Half"; } - Float { ret ~"Float"; } - Double { ret ~"Double"; } - X86_FP80 { ret ~"X86_FP80"; } - FP128 { ret ~"FP128"; } - PPC_FP128 { ret ~"PPC_FP128"; } - Label { ret ~"Label"; } + Void { return ~"Void"; } + Half { return ~"Half"; } + Float { return ~"Float"; } + Double { return ~"Double"; } + X86_FP80 { return ~"X86_FP80"; } + FP128 { return ~"FP128"; } + PPC_FP128 { return ~"PPC_FP128"; } + Label { return ~"Label"; } Integer { - ret ~"i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int); + return ~"i" + int::str(llvm::LLVMGetIntTypeWidth(ty) as int); } Function { let mut s = ~"fn("; @@ -1058,7 +1058,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> s += tys_str(names, outer, args); s += ~") -> "; s += type_to_str_inner(names, outer, out_ty); - ret s; + return s; } Struct { let mut s: ~str = ~"{"; @@ -1069,11 +1069,11 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> } s += tys_str(names, outer, elts); s += ~"}"; - ret s; + return s; } Array { let el_ty = llvm::LLVMGetElementType(ty); - ret ~"[" + type_to_str_inner(names, outer, el_ty) + ~" x " + + return ~"[" + type_to_str_inner(names, outer, el_ty) + ~" x " + uint::str(llvm::LLVMGetArrayLength(ty) as uint) + ~"]"; } Pointer { @@ -1082,7 +1082,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> i += 1u; if tout as int == ty as int { let n: uint = vec::len::<TypeRef>(outer0) - i; - ret ~"*\\" + int::str(n as int); + return ~"*\\" + int::str(n as int); } } let addrstr = { @@ -1093,17 +1093,17 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> fmt!{"addrspace(%u)", addrspace} } }; - ret addrstr + ~"*" + + return addrstr + ~"*" + type_to_str_inner(names, outer, llvm::LLVMGetElementType(ty)); } - Vector { ret ~"Vector"; } - Metadata { ret ~"Metadata"; } - X86_MMX { ret ~"X86_MMAX"; } + Vector { return ~"Vector"; } + Metadata { return ~"Metadata"; } + X86_MMX { return ~"X86_MMAX"; } } } fn float_width(llt: TypeRef) -> uint { - ret alt llvm::LLVMGetTypeKind(llt) as int { + return alt llvm::LLVMGetTypeKind(llt) as int { 1 { 32u } 2 { 64u } 3 { 80u } @@ -1116,7 +1116,7 @@ fn fn_ty_param_tys(fn_ty: TypeRef) -> ~[TypeRef] unsafe { let args = vec::from_elem(llvm::LLVMCountParamTypes(fn_ty) as uint, 0 as TypeRef); llvm::LLVMGetParamTypes(fn_ty, vec::unsafe::to_ptr(args)); - ret args; + return args; } @@ -1133,7 +1133,7 @@ type target_data = {lltd: TargetDataRef, dtor: @target_data_res}; fn mk_target_data(string_rep: ~str) -> target_data { let lltd = str::as_c_str(string_rep, |buf| llvm::LLVMCreateTargetData(buf) ); - ret {lltd: lltd, dtor: @target_data_res(lltd)}; + return {lltd: lltd, dtor: @target_data_res(lltd)}; } /* Memory-managed interface to pass managers. */ @@ -1148,7 +1148,7 @@ type pass_manager = {llpm: PassManagerRef, dtor: @pass_manager_res}; fn mk_pass_manager() -> pass_manager { let llpm = llvm::LLVMCreatePassManager(); - ret {llpm: llpm, dtor: @pass_manager_res(llpm)}; + return {llpm: llpm, dtor: @pass_manager_res(llpm)}; } /* Memory-managed interface to object files. */ @@ -1163,8 +1163,8 @@ type object_file = {llof: ObjectFileRef, dtor: @object_file_res}; fn mk_object_file(llmb: MemoryBufferRef) -> option<object_file> { let llof = llvm::LLVMCreateObjectFile(llmb); - if llof as int == 0 { ret option::none::<object_file>; } - ret option::some({llof: llof, dtor: @object_file_res(llof)}); + if llof as int == 0 { return option::none::<object_file>; } + return option::some({llof: llof, dtor: @object_file_res(llof)}); } /* Memory-managed interface to section iterators. */ @@ -1179,7 +1179,7 @@ type section_iter = {llsi: SectionIteratorRef, dtor: @section_iter_res}; fn mk_section_iter(llof: ObjectFileRef) -> section_iter { let llsi = llvm::LLVMGetSections(llof); - ret {llsi: llsi, dtor: @section_iter_res(llsi)}; + return {llsi: llsi, dtor: @section_iter_res(llsi)}; } // diff --git a/src/rustc/metadata/common.rs b/src/rustc/metadata/common.rs index 946f3c764fa..8f97c204611 100644 --- a/src/rustc/metadata/common.rs +++ b/src/rustc/metadata/common.rs @@ -127,12 +127,14 @@ enum astencode_tag { // Reserves 0x50 -- 0x6f } // djb's cdb hashes. -fn hash_node_id(&&node_id: int) -> uint { ret 177573u ^ (node_id as uint); } +fn hash_node_id(&&node_id: int) -> uint { + return 177573u ^ (node_id as uint); +} fn hash_path(&&s: ~str) -> uint { let mut h = 5381u; for str::each(s) |ch| { h = (h << 5u) + h ^ (ch as uint); } - ret h; + return h; } type link_meta = {name: @~str, vers: @~str, extras_hash: ~str}; diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index d0f8ac2747d..06eb2bea3d2 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -116,7 +116,7 @@ fn visit_item(e: env, i: @ast::item) { alt attr::foreign_abi(i.attrs) { either::right(abi) { if abi != ast::foreign_abi_cdecl && - abi != ast::foreign_abi_stdcall { ret; } + abi != ast::foreign_abi_stdcall { return; } } either::left(msg) { e.diag.span_fatal(i.span, msg); } } @@ -177,10 +177,10 @@ fn existing_match(e: env, metas: ~[@ast::meta_item], hash: ~str) -> for e.crate_cache.each |c| { if loader::metadata_matches(*c.metas, metas) && (hash.is_empty() || *c.hash == hash) { - ret some(c.cnum); + return some(c.cnum); } } - ret none; + return none; } fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], @@ -228,10 +228,10 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], let cstore = e.cstore; cstore::set_crate_data(cstore, cnum, cmeta); cstore::add_used_crate_file(cstore, cfilename); - ret cnum; + return cnum; } some(cnum) { - ret cnum; + return cnum; } } } @@ -266,7 +266,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { } } } - ret cnum_map; + return cnum_map; } // Local Variables: diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 91a22b9fe2f..9e2b7c174ef 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -35,12 +35,12 @@ export maybe_get_item_ast, found_ast, found, found_parent, not_found; fn get_symbol(cstore: cstore::cstore, def: ast::def_id) -> ~str { let cdata = cstore::get_crate_data(cstore, def.crate).data; - ret decoder::get_symbol(cdata, def.node); + return decoder::get_symbol(cdata, def.node); } fn get_type_param_count(cstore: cstore::cstore, def: ast::def_id) -> uint { let cdata = cstore::get_crate_data(cstore, def.crate).data; - ret decoder::get_type_param_count(cdata, def.node); + return decoder::get_type_param_count(cdata, def.node); } fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num, @@ -51,7 +51,7 @@ fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num, let (c, data, def) = elt; vec::push(result, decoder::lookup_def(c, data, def)); } - ret result; + return result; } fn lookup_method_purity(cstore: cstore::cstore, did: ast::def_id) @@ -83,7 +83,7 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num, } } } - ret result; + return result; } /// Iterates over all the paths in the given crate. @@ -125,7 +125,7 @@ fn get_enum_variants(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::variant_info] { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); - ret decoder::get_enum_variants(cdata, def.node, tcx) + return decoder::get_enum_variants(cdata, def.node, tcx) } fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id, @@ -147,7 +147,7 @@ fn get_method_names_if_trait(cstore: cstore::cstore, def: ast::def_id) -> option<@dvec<@~str>> { let cdata = cstore::get_crate_data(cstore, def.crate); - ret decoder::get_method_names_if_trait(cdata, def.node); + return decoder::get_method_names_if_trait(cdata, def.node); } fn get_item_attrs(cstore: cstore::cstore, @@ -173,7 +173,7 @@ fn get_type(tcx: ty::ctxt, def: ast::def_id) -> ty::ty_param_bounds_and_ty { fn get_region_param(cstore: metadata::cstore::cstore, def: ast::def_id) -> bool { let cdata = cstore::get_crate_data(cstore, def.crate); - ret decoder::get_region_param(cdata, def.node); + return decoder::get_region_param(cdata, def.node); } fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, @@ -193,7 +193,7 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, class_id, def} ); debug!{"got field data %?", the_field}; let ty = decoder::item_type(def, the_field, tcx, cdata); - ret {bounds: @~[], rp: false, ty: ty}; + return {bounds: @~[], rp: false, ty: ty}; } // Given a def_id for an impl or class, return the traits it implements, diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index fd541c33d2d..dce5a108a03 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -71,7 +71,7 @@ fn mk_cstore() -> cstore { let meta_cache = map::int_hash::<crate_metadata>(); let crate_map = map::int_hash::<ast::crate_num>(); let mod_path_map = new_def_hash(); - ret private(@{metas: meta_cache, + return private(@{metas: meta_cache, use_crate_map: crate_map, mod_path_map: mod_path_map, mut used_crate_files: ~[], @@ -80,17 +80,17 @@ fn mk_cstore() -> cstore { } fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata { - ret p(cstore).metas.get(cnum); + return p(cstore).metas.get(cnum); } fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @~str { let cdata = get_crate_data(cstore, cnum); - ret decoder::get_crate_hash(cdata.data); + return decoder::get_crate_hash(cdata.data); } fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @~str { let cdata = get_crate_data(cstore, cnum); - ret decoder::get_crate_vers(cdata.data); + return decoder::get_crate_vers(cdata.data); } fn set_crate_data(cstore: cstore, cnum: ast::crate_num, @@ -104,7 +104,7 @@ fn set_crate_data(cstore: cstore, cnum: ast::crate_num, } fn have_crate_data(cstore: cstore, cnum: ast::crate_num) -> bool { - ret p(cstore).metas.contains_key(cnum); + return p(cstore).metas.contains_key(cnum); } fn iter_crate_data(cstore: cstore, i: fn(ast::crate_num, crate_metadata)) { @@ -118,19 +118,19 @@ fn add_used_crate_file(cstore: cstore, lib: ~str) { } fn get_used_crate_files(cstore: cstore) -> ~[~str] { - ret p(cstore).used_crate_files; + return p(cstore).used_crate_files; } fn add_used_library(cstore: cstore, lib: ~str) -> bool { assert lib != ~""; - if vec::contains(p(cstore).used_libraries, lib) { ret false; } + if vec::contains(p(cstore).used_libraries, lib) { return false; } vec::push(p(cstore).used_libraries, lib); - ret true; + return true; } fn get_used_libraries(cstore: cstore) -> ~[~str] { - ret p(cstore).used_libraries; + return p(cstore).used_libraries; } fn add_used_link_args(cstore: cstore, args: ~str) { @@ -138,7 +138,7 @@ fn add_used_link_args(cstore: cstore, args: ~str) { } fn get_used_link_args(cstore: cstore) -> ~[~str] { - ret p(cstore).used_link_args; + return p(cstore).used_link_args; } fn add_use_stmt_cnum(cstore: cstore, use_id: ast::node_id, @@ -164,15 +164,15 @@ fn get_dep_hashes(cstore: cstore) -> ~[@~str] { vec::push(result, {name: @cdata.name, hash: hash}); }; fn lteq(a: crate_hash, b: crate_hash) -> bool { - ret *a.name <= *b.name; + return *a.name <= *b.name; } let sorted = std::sort::merge_sort(lteq, result); debug!{"sorted:"}; for sorted.each |x| { debug!{" hash[%s]: %s", *x.name, *x.hash}; } - fn mapper(ch: crate_hash) -> @~str { ret ch.hash; } - ret vec::map(sorted, mapper); + fn mapper(ch: crate_hash) -> @~str { return ch.hash; } + return vec::map(sorted, mapper); } fn get_path(cstore: cstore, d: ast::def_id) -> ~[ast::ident] { diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 37da481a82d..f8252a04ed0 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -75,7 +75,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) -> for ebml::tagged_docs(bucket, belt) |elt| { let pos = io::u64_from_be_bytes(*elt.data, elt.start, 4u) as uint; if eq_fn(vec::slice(*elt.data, elt.start + 4u, elt.end)) { - ret some(ebml::doc_at(d.data, pos).doc); + return some(ebml::doc_at(d.data, pos).doc); } }; none @@ -83,7 +83,7 @@ fn lookup_hash(d: ebml::doc, eq_fn: fn(x:&[u8]) -> bool, hash: uint) -> fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> { fn eq_item(bytes: &[u8], item_id: int) -> bool { - ret io::u64_from_be_bytes(vec::slice(bytes, 0u, 4u), 0u, 4u) as int + return io::u64_from_be_bytes(vec::slice(bytes, 0u, 4u), 0u, 4u) as int == item_id; } lookup_hash(items, @@ -92,7 +92,7 @@ fn maybe_find_item(item_id: int, items: ebml::doc) -> option<ebml::doc> { } fn find_item(item_id: int, items: ebml::doc) -> ebml::doc { - ret option::get(maybe_find_item(item_id, items)); + return option::get(maybe_find_item(item_id, items)); } // Looks up an item in the given metadata and returns an ebml doc pointing @@ -112,12 +112,12 @@ fn item_family(item: ebml::doc) -> char { fn item_symbol(item: ebml::doc) -> ~str { let sym = ebml::get_doc(item, tag_items_data_item_symbol); - ret str::from_bytes(ebml::doc_data(sym)); + return str::from_bytes(ebml::doc_data(sym)); } fn item_parent_item(d: ebml::doc) -> option<ast::def_id> { for ebml::tagged_docs(d, tag_items_data_parent_item) |did| { - ret some(ebml::with_doc_data(did, |d| parse_def_id(d))); + return some(ebml::with_doc_data(did, |d| parse_def_id(d))); } none } @@ -125,7 +125,7 @@ fn item_parent_item(d: ebml::doc) -> option<ast::def_id> { // XXX: This has nothing to do with classes. fn class_member_id(d: ebml::doc, cdata: cmd) -> ast::def_id { let tagdoc = ebml::get_doc(d, tag_def_id); - ret translate_def_id(cdata, ebml::with_doc_data(tagdoc, + return translate_def_id(cdata, ebml::with_doc_data(tagdoc, |d| parse_def_id(d))); } @@ -204,7 +204,7 @@ fn enum_variant_ids(item: ebml::doc, cdata: cmd) -> ~[ast::def_id] { let ext = ebml::with_doc_data(p, |d| parse_def_id(d)); vec::push(ids, {crate: cdata.cnum, node: ext.node}); }; - ret ids; + return ids; } // Given a path and serialized crate metadata, returns the IDs of the @@ -215,16 +215,16 @@ fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] { let data_len = data.len(); let s_len = s.len(); if data_len != s_len { - ret false; + return false; } let mut i = 0; while i < data_len { if data[i] != s[i] { - ret false; + return false; } i += 1; } - ret true; + return true; } let s = ast_util::path_name_i(path); let md = ebml::doc(data); @@ -236,7 +236,7 @@ fn resolve_path(path: ~[ast::ident], data: @~[u8]) -> ~[ast::def_id] { let did_doc = ebml::get_doc(doc, tag_def_id); vec::push(result, ebml::with_doc_data(did_doc, |d| parse_def_id(d))); } - ret result; + return result; } fn item_path(item_doc: ebml::doc) -> ast_map::path { @@ -260,7 +260,7 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path { } } - ret result; + return result; } fn item_name(item: ebml::doc) -> ast::ident { @@ -304,7 +304,7 @@ fn lookup_def(cnum: ast::crate_num, data: @~[u8], did_: ast::def_id) -> let item = lookup_item(did_.node, data); let did = {crate: cnum, node: did_.node}; // We treat references to enums as references to types. - ret def_like_to_def(item_to_def_like(item, did, cnum)); + return def_like_to_def(item_to_def_like(item, did, cnum)); } fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) @@ -316,12 +316,12 @@ fn get_type(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) item_ty_param_bounds(item, tcx, cdata) } else { @~[] }; let rp = item_ty_region_param(item); - ret {bounds: tp_bounds, rp: rp, ty: t}; + return {bounds: tp_bounds, rp: rp, ty: t}; } fn get_region_param(cdata: cmd, id: ast::node_id) -> bool { let item = lookup_item(id, cdata.data); - ret item_ty_region_param(item); + return item_ty_region_param(item); } fn get_type_param_count(data: @~[u8], id: ast::node_id) -> uint { @@ -382,7 +382,7 @@ fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> { } fn get_symbol(data: @~[u8], id: ast::node_id) -> ~str { - ret item_symbol(lookup_item(id, data)); + return item_symbol(lookup_item(id, data)); } // Something that a name can resolve to. @@ -394,7 +394,7 @@ enum def_like { fn def_like_to_def(def_like: def_like) -> ast::def { alt def_like { - dl_def(def) { ret def; } + 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"; } } @@ -445,7 +445,7 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { // If broken, stop here. if broken { - ret; + return; } // Next, go through all the paths. We will find items that we didn't know @@ -561,7 +561,7 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) id: did, disr_val: disr_val}); disr_val += 1; } - ret infos; + return infos; } // NB: These types are duplicated in resolve.rs @@ -591,10 +591,10 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ { let self_ty_kind = string[0]; alt self_ty_kind as char { - 'r' => { ret ast::sty_by_ref; } - 'v' => { ret ast::sty_value; } - '@' => { ret ast::sty_box(get_mutability(string[1])); } - '~' => { ret ast::sty_uniq(get_mutability(string[1])); } + 'r' => { return ast::sty_by_ref; } + 'v' => { return ast::sty_value; } + '@' => { return ast::sty_box(get_mutability(string[1])); } + '~' => { return ast::sty_uniq(get_mutability(string[1])); } '&' => { let mutability = get_mutability(string[1]); @@ -609,7 +609,7 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ { region = ast::re_named(@region_string); } - ret ast::sty_region(@{ id: 0, node: region }, mutability); + return ast::sty_region(@{ id: 0, node: region }, mutability); } _ => { fail fmt!{"unknown self type code: `%c`", self_ty_kind as char}; @@ -698,14 +698,14 @@ fn get_method_names_if_trait(cdata: cmd, node_id: ast::node_id) let item = lookup_item(node_id, cdata.data); if item_family(item) != 'I' { - ret none; + return none; } let resulting_method_names = @dvec(); for ebml::tagged_docs(item, tag_item_trait_method) |method| { (*resulting_method_names).push(item_name(method)); } - ret some(resulting_method_names); + return some(resulting_method_names); } fn get_item_attrs(cdata: cmd, @@ -769,39 +769,39 @@ fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { let pos = io::u64_from_be_bytes(desc, 0u, 4u) as uint; let pathbytes = vec::slice::<u8>(desc, 4u, vec::len::<u8>(desc)); let path = str::from_bytes(pathbytes); - ret {path: path, pos: pos}; + return {path: path, pos: pos}; } fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { - if id.crate != ast::local_crate { ret ~"external"; } + if id.crate != ast::local_crate { return ~"external"; } let it = alt maybe_find_item(id.node, items) { some(it) { it } none { fail (fmt!{"describe_def: item not found %?", id}); } }; - ret item_family_to_str(item_family(it)); + return item_family_to_str(item_family(it)); } fn item_family_to_str(fam: char) -> ~str { alt check fam { - 'c' { ret ~"const"; } - 'f' { ret ~"fn"; } - 'u' { ret ~"unsafe fn"; } - 'p' { ret ~"pure fn"; } - 'F' { ret ~"foreign fn"; } - 'U' { ret ~"unsafe foreign fn"; } - 'P' { ret ~"pure foreign fn"; } - 'y' { ret ~"type"; } - 'T' { ret ~"foreign type"; } - 't' { ret ~"type"; } - 'm' { ret ~"mod"; } - 'n' { ret ~"foreign mod"; } - 'v' { ret ~"enum"; } - 'i' { ret ~"impl"; } - 'I' { ret ~"trait"; } - 'C' { ret ~"class"; } - 'S' { ret ~"struct"; } - 'g' { ret ~"public field"; } - 'j' { ret ~"private field"; } + 'c' { return ~"const"; } + 'f' { return ~"fn"; } + 'u' { return ~"unsafe fn"; } + 'p' { return ~"pure fn"; } + 'F' { return ~"foreign fn"; } + 'U' { return ~"unsafe foreign fn"; } + 'P' { return ~"pure foreign fn"; } + 'y' { return ~"type"; } + 'T' { return ~"foreign type"; } + 't' { return ~"type"; } + 'm' { return ~"mod"; } + 'n' { return ~"foreign mod"; } + 'v' { return ~"enum"; } + 'i' { return ~"impl"; } + 'I' { return ~"trait"; } + 'C' { return ~"class"; } + 'S' { return ~"struct"; } + 'g' { return ~"public field"; } + 'j' { return ~"private field"; } } } @@ -827,7 +827,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] { let subitems = get_meta_items(meta_item_doc); vec::push(items, attr::mk_list_item(@n, subitems)); }; - ret items; + return items; } fn get_attributes(md: ebml::doc) -> ~[ast::attribute] { @@ -848,7 +848,7 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] { } option::none { } } - ret attrs; + return attrs; } fn list_meta_items(meta_items: ebml::doc, out: io::writer) { @@ -868,7 +868,7 @@ fn list_crate_attributes(md: ebml::doc, hash: @~str, out: io::writer) { } fn get_crate_attributes(data: @~[u8]) -> ~[ast::attribute] { - ret get_attributes(ebml::doc(data)); + return get_attributes(ebml::doc(data)); } type crate_dep = {cnum: ast::crate_num, name: ast::ident, @@ -889,7 +889,7 @@ fn get_crate_deps(data: @~[u8]) -> ~[crate_dep] { hash: @docstr(depdoc, tag_crate_dep_hash)}); crate_num += 1; }; - ret deps; + return deps; } fn list_crate_deps(data: @~[u8], out: io::writer) { @@ -906,12 +906,12 @@ fn list_crate_deps(data: @~[u8], out: io::writer) { fn get_crate_hash(data: @~[u8]) -> @~str { let cratedoc = ebml::doc(data); let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash); - ret @str::from_bytes(ebml::doc_data(hashdoc)); + return @str::from_bytes(ebml::doc_data(hashdoc)); } fn get_crate_vers(data: @~[u8]) -> @~str { let attrs = decoder::get_crate_attributes(data); - ret alt attr::last_meta_item_value_str_by_name( + return alt attr::last_meta_item_value_str_by_name( attr::find_linkage_metas(attrs), ~"vers") { some(ver) { ver } none { @~"0.0" } @@ -968,7 +968,7 @@ fn get_crate_module_paths(bytes: @~[u8]) -> ~[(ast::def_id, ~str)] { // unified later by using the mods map vec::push(res, (did, path)); } - ret do vec::filter(res) |x| { + return do vec::filter(res) |x| { let (_, xp) = x; mods.contains_key(xp) } @@ -989,11 +989,11 @@ fn list_crate_metadata(bytes: @~[u8], out: io::writer) { // crate to the correct local crate number. fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { if did.crate == ast::local_crate { - ret {crate: cdata.cnum, node: did.node}; + return {crate: cdata.cnum, node: did.node}; } alt cdata.cnum_map.find(did.crate) { - option::some(n) { ret {crate: n, node: did.node}; } + 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 c82869d164c..6dd4e0142de 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -248,7 +248,7 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate) encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index); encode_reexport_paths(ebml_w, ecx, index); ebml_w.end_tag(); - ret index; + return index; } fn encode_reexport_paths(ebml_w: ebml::writer, @@ -273,7 +273,7 @@ fn encode_family(ebml_w: ebml::writer, c: char) { ebml_w.end_tag(); } -fn def_to_str(did: def_id) -> ~str { ret fmt!{"%d:%d", did.crate, did.node}; } +fn def_to_str(did: def_id) -> ~str { fmt!{"%d:%d", did.crate, did.node} } fn encode_type_param_bounds(ebml_w: ebml::writer, ecx: @encode_ctxt, params: ~[ty_param]) { @@ -617,7 +617,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, false } }; - if !must_write && !reachable(ecx, item.id) { ret; } + if !must_write && !reachable(ecx, item.id) { return; } fn add_to_index_(item: @item, ebml_w: ebml::writer, index: @mut ~[entry<int>]) { @@ -854,7 +854,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer, nitem: @foreign_item, index: @mut ~[entry<int>], path: ast_map::path, abi: foreign_abi) { - if !reachable(ecx, nitem.id) { ret; } + if !reachable(ecx, nitem.id) { return; } vec::push(*index, {val: nitem.id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); @@ -922,7 +922,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, with *visit::default_visitor() })); ebml_w.end_tag(); - ret *index; + return *index; } @@ -941,7 +941,7 @@ fn create_index<T: copy>(index: ~[entry<T>], hash_fn: fn@(T) -> uint) -> for buckets.each |bucket| { vec::push(buckets_frozen, @*bucket); } - ret buckets_frozen; + return buckets_frozen; } fn encode_index<T>(ebml_w: ebml::writer, buckets: ~[@~[entry<T>]], @@ -1047,7 +1047,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { let meta_items = vec::append(~[name_item, vers_item], other_items); let link_item = attr::mk_list_item(@~"link", meta_items); - ret attr::mk_attr(link_item); + return attr::mk_attr(link_item); } let mut attrs: ~[attribute] = ~[]; @@ -1070,7 +1070,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { if !found_link_attr { vec::push(attrs, synthesize_link_attr(ecx, ~[])); } - ret attrs; + return attrs; } fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) { @@ -1100,7 +1100,7 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) { } // mut -> immutable hack for vec::map - ret vec::slice(deps, 0u, vec::len(deps)); + return vec::slice(deps, 0u, vec::len(deps)); } // We're just going to write a list of crate 'name-hash-version's, with @@ -1189,7 +1189,7 @@ fn encoded_ty(tcx: ty::ctxt, t: ty::t) -> ~str { abbrevs: tyencode::ac_no_abbrevs}; let buf = io::mem_buffer(); tyencode::enc_ty(io::mem_buffer_writer(buf), cx, t); - ret io::mem_buffer_str(buf); + return io::mem_buffer_str(buf); } diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index 6bd002c356e..65dd8a5a3e8 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -85,7 +85,7 @@ fn search<T: copy>(filesearch: filesearch, pick: pick<T>) -> option<T> { } if option::is_some(rslt) { break; } } - ret rslt; + return rslt; } fn relative_target_lib_path(target_triple: ~str) -> ~[path] { @@ -97,7 +97,7 @@ fn make_target_lib_path(sysroot: path, let path = vec::append(~[sysroot], relative_target_lib_path(target_triple)); let path = path::connect_many(path); - ret path; + return path; } fn get_default_sysroot() -> path { diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index 12d47cb86cf..c3949acb0af 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -38,7 +38,7 @@ type ctxt = { fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { alt find_library_crate(cx) { - some(t) { ret t; } + some(t) { return t; } none { cx.diag.span_fatal( cx.span, fmt!{"can't find crate for `%s`", *cx.ident}); @@ -52,12 +52,12 @@ fn find_library_crate(cx: ctxt) -> option<{ident: ~str, data: @~[u8]}> { } fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} { - if cx.static { ret {prefix: ~"lib", suffix: ~".rlib"}; } + if cx.static { return {prefix: ~"lib", suffix: ~".rlib"}; } alt cx.os { - os_win32 { ret {prefix: ~"", suffix: ~".dll"}; } - os_macos { ret {prefix: ~"lib", suffix: ~".dylib"}; } - os_linux { ret {prefix: ~"lib", suffix: ~".so"}; } - os_freebsd { ret {prefix: ~"lib", suffix: ~".so"}; } + os_win32 { return {prefix: ~"", suffix: ~".dll"}; } + os_macos { return {prefix: ~"lib", suffix: ~".dylib"}; } + os_linux { return {prefix: ~"lib", suffix: ~".so"}; } + os_freebsd { return {prefix: ~"lib", suffix: ~".so"}; } } } @@ -143,7 +143,7 @@ fn crate_matches(crate_data: @~[u8], metas: ~[@ast::meta_item], let linkage_metas = attr::find_linkage_metas(attrs); if hash.is_not_empty() { let chash = decoder::get_crate_hash(crate_data); - if *chash != hash { ret false; } + if *chash != hash { return false; } } metadata_matches(linkage_metas, metas) } @@ -163,10 +163,10 @@ fn metadata_matches(extern_metas: ~[@ast::meta_item], debug!{"looking for %s", pprust::meta_item_to_str(*needed)}; if !attr::contains(extern_metas, needed) { debug!{"missing %s", pprust::meta_item_to_str(*needed)}; - ret false; + return false; } } - ret true; + return true; } fn get_metadata_section(os: os, @@ -174,10 +174,10 @@ fn get_metadata_section(os: os, let mb = str::as_c_str(filename, |buf| { llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf) }); - if mb as int == 0 { ret option::none::<@~[u8]>; } + if mb as int == 0 { return option::none::<@~[u8]>; } let of = alt mk_object_file(mb) { option::some(of) { of } - _ { ret option::none::<@~[u8]>; } + _ { return option::none::<@~[u8]>; } }; let si = mk_section_iter(of.llof); while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False { @@ -188,12 +188,12 @@ fn get_metadata_section(os: os, let csz = llvm::LLVMGetSectionSize(si.llsi) as uint; unsafe { let cvbuf: *u8 = unsafe::reinterpret_cast(cbuf); - ret some(@vec::unsafe::from_buf(cvbuf, csz)); + return some(@vec::unsafe::from_buf(cvbuf, csz)); } } llvm::LLVMMoveToNextSection(si.llsi); } - ret option::none::<@~[u8]>; + return option::none::<@~[u8]>; } fn meta_section_name(os: os) -> ~str { diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index fad9d2d942f..df7bea1bd0e 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -26,18 +26,18 @@ fn peek(st: @pstate) -> char { fn next(st: @pstate) -> char { let ch = st.data[st.pos] as char; st.pos = st.pos + 1u; - ret ch; + return ch; } fn next_byte(st: @pstate) -> u8 { let b = st.data[st.pos]; st.pos = st.pos + 1u; - ret b; + return b; } fn parse_ident(st: @pstate, last: char) -> ast::ident { - fn is_last(b: char, c: char) -> bool { ret c == b; } - ret parse_ident_(st, |a| is_last(last, a) ); + fn is_last(b: char, c: char) -> bool { return c == b; } + return parse_ident_(st, |a| is_last(last, a) ); } fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) -> @@ -46,7 +46,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) -> while !is_last(peek(st)) { rslt += str::from_byte(next_byte(st)); } - ret @rslt; + return @rslt; } @@ -65,14 +65,14 @@ fn parse_ret_ty(st: @pstate, conv: conv_did) -> (ast::ret_style, ty::t) { fn parse_path(st: @pstate) -> @ast::path { let mut idents: ~[ast::ident] = ~[]; - fn is_last(c: char) -> bool { ret c == '(' || c == ':'; } + fn is_last(c: char) -> bool { return c == '(' || c == ':'; } vec::push(idents, parse_ident_(st, is_last)); loop { alt peek(st) { ':' { next(st); next(st); } c { if c == '(' { - ret @{span: ast_util::dummy_sp(), + return @{span: ast_util::dummy_sp(), global: false, idents: idents, rp: none, types: ~[]}; } else { vec::push(idents, parse_ident_(st, is_last)); } @@ -82,7 +82,7 @@ fn parse_path(st: @pstate) -> @ast::path { } fn parse_ty_rust_fn(st: @pstate, conv: conv_did) -> ty::t { - ret ty::mk_fn(st.tcx, parse_ty_fn(st, conv)); + return ty::mk_fn(st.tcx, parse_ty_fn(st, conv)); } fn parse_proto(c: char) -> ast::proto { @@ -103,7 +103,7 @@ fn parse_vstore(st: @pstate) -> ty::vstore { if '0' <= c && c <= '9' { let n = parse_int(st) as uint; assert next(st) == '|'; - ret ty::vstore_fixed(n); + return ty::vstore_fixed(n); } alt check next(st) { @@ -123,7 +123,7 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } st.pos = st.pos + 1u; - ret {self_r: self_r, + return {self_r: self_r, self_ty: self_ty, tps: params}; } @@ -178,70 +178,70 @@ fn parse_str(st: @pstate, term: char) -> ~str { result += str::from_byte(next_byte(st)); } next(st); - ret result; + return result; } fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { alt check next(st) { - 'n' { ret ty::mk_nil(st.tcx); } - 'z' { ret ty::mk_bot(st.tcx); } - 'b' { ret ty::mk_bool(st.tcx); } - 'i' { ret ty::mk_int(st.tcx); } - 'u' { ret ty::mk_uint(st.tcx); } - 'l' { ret ty::mk_float(st.tcx); } + 'n' { return ty::mk_nil(st.tcx); } + 'z' { return ty::mk_bot(st.tcx); } + 'b' { return ty::mk_bool(st.tcx); } + 'i' { return ty::mk_int(st.tcx); } + 'u' { return ty::mk_uint(st.tcx); } + 'l' { return ty::mk_float(st.tcx); } 'M' { alt check next(st) { - 'b' { ret ty::mk_mach_uint(st.tcx, ast::ty_u8); } - 'w' { ret ty::mk_mach_uint(st.tcx, ast::ty_u16); } - 'l' { ret ty::mk_mach_uint(st.tcx, ast::ty_u32); } - 'd' { ret ty::mk_mach_uint(st.tcx, ast::ty_u64); } - 'B' { ret ty::mk_mach_int(st.tcx, ast::ty_i8); } - 'W' { ret ty::mk_mach_int(st.tcx, ast::ty_i16); } - 'L' { ret ty::mk_mach_int(st.tcx, ast::ty_i32); } - 'D' { ret ty::mk_mach_int(st.tcx, ast::ty_i64); } - 'f' { ret ty::mk_mach_float(st.tcx, ast::ty_f32); } - 'F' { ret ty::mk_mach_float(st.tcx, ast::ty_f64); } + '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); } + 'd' { return ty::mk_mach_uint(st.tcx, ast::ty_u64); } + 'B' { return ty::mk_mach_int(st.tcx, ast::ty_i8); } + 'W' { return ty::mk_mach_int(st.tcx, ast::ty_i16); } + 'L' { return ty::mk_mach_int(st.tcx, ast::ty_i32); } + 'D' { return ty::mk_mach_int(st.tcx, ast::ty_i64); } + 'f' { return ty::mk_mach_float(st.tcx, ast::ty_f32); } + 'F' { return ty::mk_mach_float(st.tcx, ast::ty_f64); } } } - 'c' { ret ty::mk_char(st.tcx); } + 'c' { return ty::mk_char(st.tcx); } 't' { assert (next(st) == '['); let def = parse_def(st, conv); let substs = parse_substs(st, conv); assert next(st) == ']'; - ret ty::mk_enum(st.tcx, def, substs); + return ty::mk_enum(st.tcx, def, substs); } 'x' { assert next(st) == '['; let def = parse_def(st, conv); let substs = parse_substs(st, conv); assert next(st) == ']'; - ret ty::mk_trait(st.tcx, def, substs); + return ty::mk_trait(st.tcx, def, substs); } 'p' { let did = parse_def(st, conv); - ret ty::mk_param(st.tcx, parse_int(st) as uint, did); + return ty::mk_param(st.tcx, parse_int(st) as uint, did); } 's' { - ret ty::mk_self(st.tcx); + return ty::mk_self(st.tcx); } - '@' { ret ty::mk_box(st.tcx, parse_mt(st, conv)); } - '~' { ret ty::mk_uniq(st.tcx, parse_mt(st, conv)); } - '*' { ret ty::mk_ptr(st.tcx, parse_mt(st, conv)); } + '@' { return ty::mk_box(st.tcx, parse_mt(st, conv)); } + '~' { return ty::mk_uniq(st.tcx, parse_mt(st, conv)); } + '*' { return ty::mk_ptr(st.tcx, parse_mt(st, conv)); } '&' { let r = parse_region(st); let mt = parse_mt(st, conv); - ret ty::mk_rptr(st.tcx, r, mt); + return ty::mk_rptr(st.tcx, r, mt); } - 'U' { ret ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)); } + 'U' { return ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)); } 'V' { let mt = parse_mt(st, conv); let v = parse_vstore(st); - ret ty::mk_evec(st.tcx, mt, v); + return ty::mk_evec(st.tcx, mt, v); } 'v' { let v = parse_vstore(st); - ret ty::mk_estr(st.tcx, v); + return ty::mk_estr(st.tcx, v); } 'R' { assert (next(st) == '['); @@ -251,29 +251,29 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { vec::push(fields, {ident: name, mt: parse_mt(st, conv)}); } st.pos = st.pos + 1u; - ret ty::mk_rec(st.tcx, fields); + return ty::mk_rec(st.tcx, fields); } 'T' { assert (next(st) == '['); let mut params = ~[]; while peek(st) != ']' { vec::push(params, parse_ty(st, conv)); } st.pos = st.pos + 1u; - ret ty::mk_tup(st.tcx, params); + return ty::mk_tup(st.tcx, params); } 'f' { parse_ty_rust_fn(st, conv) } 'X' { - ret ty::mk_var(st.tcx, ty::tv_vid(parse_int(st) as uint)); + return ty::mk_var(st.tcx, ty::tv_vid(parse_int(st) as uint)); } - 'Y' { ret ty::mk_type(st.tcx); } + 'Y' { return ty::mk_type(st.tcx); } 'C' { let ck = alt check next(st) { '&' { ty::ck_block } '@' { ty::ck_box } '~' { ty::ck_uniq } }; - ret ty::mk_opaque_closure_ptr(st.tcx, ck); + return ty::mk_opaque_closure_ptr(st.tcx, ck); } '#' { let pos = parse_hex(st); @@ -281,12 +281,12 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { let len = parse_hex(st); assert (next(st) == '#'); alt st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) { - some(tt) { ret tt; } + some(tt) { return tt; } none { let ps = @{pos: pos with *st}; let tt = parse_ty(ps, conv); st.tcx.rcache.insert({cnum: st.crate, pos: pos, len: len}, tt); - ret tt; + return tt; } } } @@ -304,7 +304,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { debug!{"parsed a def_id %?", did}; let substs = parse_substs(st, conv); assert (next(st) == ']'); - ret ty::mk_class(st.tcx, did, substs); + return ty::mk_class(st.tcx, did, substs); } c { error!{"unexpected char in type string: %c", c}; fail;} } @@ -317,21 +317,21 @@ fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { '?' { next(st); m = ast::m_const; } _ { m = ast::m_imm; } } - ret {ty: parse_ty(st, conv), mutbl: m}; + return {ty: parse_ty(st, conv), mutbl: m}; } fn parse_def(st: @pstate, conv: conv_did) -> ast::def_id { let mut def = ~[]; while peek(st) != '|' { vec::push(def, next_byte(st)); } st.pos = st.pos + 1u; - ret conv(parse_def_id(def)); + return conv(parse_def_id(def)); } fn parse_int(st: @pstate) -> int { let mut n = 0; loop { let cur = peek(st); - if cur < '0' || cur > '9' { ret n; } + if cur < '0' || cur > '9' { return n; } st.pos = st.pos + 1u; n *= 10; n += (cur as int) - ('0' as int); @@ -342,7 +342,7 @@ fn parse_hex(st: @pstate) -> uint { let mut n = 0u; loop { let cur = peek(st); - if (cur < '0' || cur > '9') && (cur < 'a' || cur > 'f') { ret n; } + if (cur < '0' || cur > '9') && (cur < 'a' || cur > 'f') { return n; } st.pos = st.pos + 1u; n *= 16u; if '0' <= cur && cur <= '9' { @@ -378,7 +378,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { } st.pos += 1u; // eat the ']' let (ret_style, ret_ty) = parse_ret_ty(st, conv); - ret {purity: purity, proto: proto, inputs: inputs, output: ret_ty, + return {purity: purity, proto: proto, inputs: inputs, output: ret_ty, ret_style: ret_style}; } @@ -405,7 +405,7 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id { none { fail (fmt!{"internal error: parse_def_id: id expected, but \ found %?", def_part}); } }; - ret {crate: crate_num, node: def_num}; + return {crate: crate_num, node: def_num}; } fn parse_bounds_data(data: @~[u8], start: uint, diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 7bcf6d77841..02a6b0f826a 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -35,8 +35,8 @@ enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap<ty::t, ty_abbrev>), } fn cx_uses_abbrevs(cx: @ctxt) -> bool { alt cx.abbrevs { - ac_no_abbrevs { ret false; } - ac_use_abbrevs(_) { ret true; } + ac_no_abbrevs { return false; } + ac_use_abbrevs(_) { return true; } } } @@ -56,7 +56,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { } ac_use_abbrevs(abbrevs) { alt abbrevs.find(t) { - some(a) { w.write_str(*a.s); ret; } + some(a) { w.write_str(*a.s); return; } none { let pos = w.tell(); alt ty::type_def_id(t) { @@ -79,7 +79,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { let mut n = u; let mut len = 0u; while n != 0u { len += 1u; n = n >> 4u; } - ret len; + return len; } let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len); if abbrev_len < len { @@ -89,7 +89,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { let a = {pos: pos, len: len, s: @s}; abbrevs.insert(t, a); } - ret; + return; } } } diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 5ec3c3882ac..8f672d19047 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -147,12 +147,12 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, fn reserve_id_range(sess: session, from_id_range: ast_util::id_range) -> ast_util::id_range { // Handle the case of an empty range: - if ast_util::empty(from_id_range) { ret from_id_range; } + if ast_util::empty(from_id_range) { return from_id_range; } let cnt = from_id_range.max - from_id_range.min; let to_id_min = sess.parse_sess.next_id; let to_id_max = sess.parse_sess.next_id + cnt; sess.parse_sess.next_id = to_id_max; - ret {min: to_id_min, max: to_id_min}; + return {min: to_id_min, max: to_id_min}; } impl translation_routines for extended_decode_ctxt { @@ -972,7 +972,7 @@ fn test_more() { roundtrip(#ast[item]{ fn foo(x: uint, y: uint) -> uint { let z = x + y; - ret z; + return z; } }); } @@ -983,13 +983,13 @@ fn test_simplification() { let item_in = ast::ii_item(#ast[item] { fn new_int_alist<B: copy>() -> alist<int, B> { fn eq_int(&&a: int, &&b: int) -> bool { a == b } - ret {eq_fn: eq_int, mut data: ~[]}; + return {eq_fn: eq_int, mut data: ~[]}; } }); let item_out = simplify_ast(item_in); let item_exp = ast::ii_item(#ast[item] { fn new_int_alist<B: copy>() -> alist<int, B> { - ret {eq_fn: eq_int, mut data: ~[]}; + return {eq_fn: eq_int, mut data: ~[]}; } }); alt (item_out, item_exp) { diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index c94326d668a..3f4a32bff86 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -267,7 +267,7 @@ fn check_crate(tcx: ty::ctxt, make_stat(bccx, bccx.req_pure_paths)}); } - ret (bccx.root_map, bccx.mutbl_map); + return (bccx.root_map, bccx.mutbl_map); fn make_stat(bccx: borrowck_ctxt, stat: uint) -> ~str { let stat_f = stat as float; @@ -410,12 +410,12 @@ fn save_and_restore<T:copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U { let old_save_and_restore_t = save_and_restore_t; let u <- f(); save_and_restore_t = old_save_and_restore_t; - ret u; + return u; } /// Creates and returns a new root_map fn root_map() -> root_map { - ret hashmap(root_map_key_hash, root_map_key_eq); + return hashmap(root_map_key_hash, root_map_key_eq); fn root_map_key_eq(k1: root_map_key, k2: root_map_key) -> bool { k1.id == k2.id && k1.derefs == k2.derefs diff --git a/src/rustc/middle/borrowck/categorization.rs b/src/rustc/middle/borrowck/categorization.rs index 36b35dbbdbc..ebcb380b4e9 100644 --- a/src/rustc/middle/borrowck/categorization.rs +++ b/src/rustc/middle/borrowck/categorization.rs @@ -133,12 +133,12 @@ impl public_methods for borrowck_ctxt { alt expr.node { ast::expr_unary(ast::deref, e_base) { if self.method_map.contains_key(expr.id) { - ret self.cat_rvalue(expr, expr_ty); + return self.cat_rvalue(expr, expr_ty); } let base_cmt = self.cat_expr(e_base); alt self.cat_deref(expr, base_cmt, 0u, true) { - some(cmt) { ret cmt; } + some(cmt) { return cmt; } none { tcx.sess.span_bug( e_base.span, @@ -150,7 +150,7 @@ impl public_methods for borrowck_ctxt { ast::expr_field(base, f_name, _) { if self.method_map.contains_key(expr.id) { - ret self.cat_method_ref(expr, expr_ty); + return self.cat_method_ref(expr, expr_ty); } let base_cmt = self.cat_autoderef(base); @@ -159,7 +159,7 @@ impl public_methods for borrowck_ctxt { ast::expr_index(base, _) { if self.method_map.contains_key(expr.id) { - ret self.cat_rvalue(expr, expr_ty); + return self.cat_rvalue(expr, expr_ty); } self.cat_index(expr, base) @@ -183,7 +183,7 @@ impl public_methods for borrowck_ctxt { ast::expr_lit(*) | ast::expr_break | ast::expr_mac(*) | ast::expr_again | ast::expr_rec(*) | ast::expr_struct(*) | ast::expr_unary_move(*) { - ret self.cat_rvalue(expr, expr_ty); + return self.cat_rvalue(expr, expr_ty); } } } @@ -297,7 +297,7 @@ impl public_methods for borrowck_ctxt { } fn cat_discr(cmt: cmt, alt_id: ast::node_id) -> cmt { - ret @{cat:cat_discr(cmt, alt_id) with *cmt}; + return @{cat:cat_discr(cmt, alt_id) with *cmt}; } /// inherited mutability: used in cases where the mutability of a @@ -388,7 +388,7 @@ impl public_methods for borrowck_ctxt { } }; - ret alt deref_kind(self.tcx, base_cmt.ty) { + return alt 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 @@ -461,7 +461,7 @@ impl private_methods for borrowck_ctxt { loop { ctr += 1u; alt self.cat_deref(base, cmt, ctr, false) { - none { ret cmt; } + none { return cmt; } some(cmt1) { cmt = cmt1; } } } @@ -476,7 +476,7 @@ fn field_mutbl(tcx: ty::ctxt, ty::ty_rec(fields) { for fields.each |f| { if f.ident == f_name { - ret some(f.mt.mutbl); + return some(f.mt.mutbl); } } } @@ -487,12 +487,12 @@ fn field_mutbl(tcx: ty::ctxt, ast::class_mutable { ast::m_mutbl } ast::class_immutable { ast::m_imm } }; - ret some(m); + return some(m); } } } _ { } } - ret none; + return none; } diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index 4306d457378..79c562ae5b8 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -85,7 +85,7 @@ impl methods for check_loan_ctxt { fn purity(scope_id: ast::node_id) -> option<purity_cause> { let default_purity = alt self.declared_purity { // an unsafe declaration overrides all - ast::unsafe_fn { ret none; } + ast::unsafe_fn { return none; } // otherwise, remember what was declared as the // default, but we must scan for requirements @@ -103,11 +103,11 @@ impl methods for check_loan_ctxt { loop { alt pure_map.find(scope_id) { none {} - some(e) {ret some(pc_cmt(e));} + some(e) {return some(pc_cmt(e));} } alt region_map.find(scope_id) { - none { ret default_purity; } + none { return default_purity; } some(next_scope_id) { scope_id = next_scope_id; } } } @@ -123,13 +123,13 @@ impl methods for check_loan_ctxt { for req_loan_map.find(scope_id).each |loanss| { for (*loanss).each |loans| { for (*loans).each |loan| { - if !f(loan) { ret; } + if !f(loan) { return; } } } } alt region_map.find(scope_id) { - none { ret; } + none { return; } some(next_scope_id) { scope_id = next_scope_id; } } } @@ -140,7 +140,7 @@ impl methods for check_loan_ctxt { f: fn(loan) -> bool) { for self.walk_loans(scope_id) |loan| { if loan.lp == lp { - if !f(loan) { ret; } + if !f(loan) { return; } } } } @@ -182,11 +182,14 @@ impl methods for check_loan_ctxt { let is_fn_arg = did.crate == ast::local_crate && (*self.fn_args).contains(did.node); - if is_fn_arg { ret; } // case (a) above + if is_fn_arg { return; } // case (a) above } ast::expr_fn_block(*) | ast::expr_fn(*) | ast::expr_loop_body(*) | ast::expr_do_body(*) { - if self.is_stack_closure(expr.id) { ret; } // case (b) above + if self.is_stack_closure(expr.id) { + // case (b) above + return; + } } _ {} } @@ -198,7 +201,7 @@ impl methods for check_loan_ctxt { alt ty::get(callee_ty).struct { ty::ty_fn(fn_ty) { alt fn_ty.purity { - ast::pure_fn { ret; } // case (c) above + ast::pure_fn { return; } // case (c) above ast::impure_fn | ast::unsafe_fn | ast::extern_fn { self.report_purity_error( pc, callee_span, @@ -207,7 +210,7 @@ impl methods for check_loan_ctxt { } } } - _ { ret; } // case (d) above + _ { return; } // case (d) above } } @@ -223,7 +226,7 @@ impl methods for check_loan_ctxt { } fn is_allowed_pure_arg(expr: @ast::expr) -> bool { - ret alt expr.node { + return alt expr.node { ast::expr_path(_) { let def = self.tcx().def_map.get(expr.id); let did = ast_util::def_id_of_def(def); @@ -239,7 +242,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) { - none { ret; } + none { return; } some(loanss) { loanss } }; @@ -310,7 +313,7 @@ impl methods for check_loan_ctxt { self.bccx.span_err( ex.span, at.ing_form(self.bccx.cmt_to_str(cmt))); - ret; + return; } } } @@ -360,7 +363,7 @@ impl methods for check_loan_ctxt { loan.cmt.span, fmt!{"loan of %s granted here", self.bccx.cmt_to_str(loan.cmt)}); - ret; + return; } } } @@ -428,7 +431,7 @@ impl methods for check_loan_ctxt { self.bccx.span_err( cmt.span, fmt!{"moving out of %s", self.bccx.cmt_to_str(cmt)}); - ret; + return; } } @@ -436,7 +439,7 @@ impl methods for check_loan_ctxt { // check for a conflicting loan: let lp = alt cmt.lp { - none { ret; } + none { return; } some(lp) { lp } }; for self.walk_loans_of(cmt.id, lp) |loan| { @@ -448,7 +451,7 @@ impl methods for check_loan_ctxt { loan.cmt.span, fmt!{"loan of %s granted here", self.bccx.cmt_to_str(loan.cmt)}); - ret; + return; } } @@ -458,14 +461,14 @@ impl methods for check_loan_ctxt { fn check_last_use(expr: @ast::expr) { let cmt = self.bccx.cat_expr(expr); let lp = alt cmt.lp { - none { ret; } + none { return; } some(lp) { lp } }; for self.walk_loans_of(cmt.id, lp) |_loan| { debug!{"Removing last use entry %? due to outstanding loan", expr.id}; self.bccx.last_use_map.remove(expr.id); - ret; + return; } } diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index f08a06f3419..673cfa379a8 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -55,7 +55,7 @@ fn gather_loans(bccx: borrowck_ctxt, crate: @ast::crate) -> req_maps { visit_fn: req_loans_in_fn, with *visit::default_visitor()}); visit::visit_crate(*crate, glcx, v); - ret glcx.req_maps; + return glcx.req_maps; } fn req_loans_in_fn(fk: visit::fn_kind, diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index e1e97c0dc6f..99bdc44eb5d 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -310,7 +310,7 @@ impl private_methods for &preserve_ctxt { // would be sort of pointless to avoid rooting the inner // box by rooting an outer box, as it would just keep more // memory live than necessary, so we set root_ub to none. - ret err({cmt:cmt, code:err_root_not_permitted}); + return err({cmt:cmt, code:err_root_not_permitted}); } let root_region = ty::re_scope(self.root_ub); @@ -327,10 +327,10 @@ impl private_methods for &preserve_ctxt { #debug["Elected to root"]; let rk = {id: base.id, derefs: derefs}; self.bccx.root_map.insert(rk, scope_id); - ret ok(pc_ok); + return ok(pc_ok); } else { #debug["Unable to root"]; - ret err({cmt:cmt, + return err({cmt:cmt, code:err_out_of_root_scope(root_region, self.scope_region)}); } @@ -338,7 +338,7 @@ impl private_methods for &preserve_ctxt { // we won't be able to root long enough _ => { - ret err({cmt:cmt, + return err({cmt:cmt, code:err_out_of_root_scope(root_region, self.scope_region)}); } diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index b45d7d66e9e..2a08018ebba 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -121,5 +121,5 @@ fn compute_capture_vars(tcx: ty::ctxt, let mut result = ~[]; for cap_map.each_value |cap_var| { vec::push(result, cap_var); } - ret result; + return result; } diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 4093c0fcc6e..3986cb38bbf 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -31,13 +31,13 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) { let pat_ty = node_id_to_type(tcx, scrut.id); if type_is_empty(tcx, pat_ty) && arms.is_empty() { // Vacuously exhaustive - ret; + return; } alt ty::get(pat_ty).struct { ty_enum(did, _) { if (*enum_variants(tcx, did)).is_empty() && arms.is_empty() { - ret; + return; } } _ { /* We assume only enum types can be uninhabited */ } @@ -79,7 +79,7 @@ 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()]) { - not_useful { ret; } // This is good, wildcard pattern isn't reachable + not_useful { return; } // This is good, wildcard pattern isn't reachable useful_ { none } useful(ty, ctor) { alt ty::get(ty).struct { @@ -132,8 +132,8 @@ enum ctor { // Note: is_useful doesn't work on empty types, as the paper notes. // So it assumes that v is non-empty. fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { - if m.len() == 0u { ret useful_; } - if m[0].len() == 0u { ret not_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) { some(r) { r[0] } none { v[0] } }; @@ -160,7 +160,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { alt is_useful_specialized(tcx, m, v, variant(va.id), va.args.len(), left_ty) { not_useful {} - u { ret u; } + u { return u; } } } not_useful @@ -234,9 +234,9 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { alt 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]) { ret none; } + if !is_wild(tcx, r[0]) { return none; } } - ret some(single); + return some(single); } ty::ty_enum(eid, _) { let mut found = ~[]; @@ -249,7 +249,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { if found.len() != (*variants).len() { for vec::each(*variants) |v| { if !found.contains(variant(v.id)) { - ret some(variant(v.id)); + return some(variant(v.id)); } } fail; @@ -346,7 +346,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, let (c_lo, c_hi) = alt check ctor_id { val(v) { (v, v) } range(lo, hi) { (lo, hi) } - single { ret some(vec::tail(r)); } + single { return some(vec::tail(r)); } }; let v_lo = eval_const_expr(tcx, lo), v_hi = eval_const_expr(tcx, hi); @@ -373,7 +373,7 @@ 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) { some(def_variant(enum_id, var_id)) { - if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { ret true; } + if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { return true; } } _ {} } @@ -386,16 +386,16 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool { pat_lit(_) | pat_range(_, _) => { true } pat_rec(fields, _) => { for fields.each |it| { - if is_refutable(tcx, it.pat) { ret true; } + if is_refutable(tcx, it.pat) { return true; } } false } pat_tup(elts) => { - for elts.each |elt| { if is_refutable(tcx, elt) { ret true; } } + for elts.each |elt| { if is_refutable(tcx, elt) { return true; } } false } pat_enum(_, some(args)) => { - for args.each |p| { if is_refutable(tcx, p) { ret true; } }; + for args.each |p| { if is_refutable(tcx, p) { return true; } }; false } pat_enum(_,_) => { false } diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 3be041f4e9a..7f1fd250c91 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -64,7 +64,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, expr_unary(deref, _){ sess.span_err(e.span, ~"disallowed operator in constant expression"); - ret; + return; } expr_lit(@{node: lit_str(_), _}) { sess.span_err(e.span, @@ -106,7 +106,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, _ { sess.span_err(e.span, ~"constant contains unimplemented expression type"); - ret; + return; } } } diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index d9765618d0f..29d44ede215 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -77,7 +77,7 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk) let v = visit::mk_vt(@{visit_item: ignore_item, visit_expr: walk_expr with *visit::default_visitor()}); v.visit_block(blk, 1, v); - ret @*refs; + return @*refs; } // Build a map from every function and for-each body to a set of the @@ -100,17 +100,17 @@ fn annotate_freevars(def_map: resolve3::DefMap, crate: @ast::crate) -> with *visit::default_simple_visitor()}); visit::visit_crate(*crate, (), visitor); - ret freevars; + return freevars; } fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { alt tcx.freevars.find(fid) { none { fail ~"get_freevars: " + int::str(fid) + ~" has no freevars"; } - some(d) { ret d; } + some(d) { return d; } } } fn has_freevars(tcx: ty::ctxt, fid: ast::node_id) -> bool { - ret vec::len(*get_freevars(tcx, fid)) != 0u; + return vec::len(*get_freevars(tcx, fid)) != 0u; } // Local Variables: diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 8707cabfdf7..dd83b01fbe0 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -100,7 +100,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { is_move: bool, var_t: ty::t, sp: span) { // all captured data must be sendable, regardless of whether it is // moved in or copied in. Note that send implies owned. - if !check_send(cx, var_t, sp) { ret; } + if !check_send(cx, var_t, sp) { return; } // copied in data must be copyable, but moved in data can be anything let is_implicit = fv.is_some(); @@ -115,7 +115,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { fn check_for_box(cx: ctx, id: node_id, fv: option<@freevar_entry>, is_move: bool, var_t: ty::t, sp: span) { // all captured data must be owned - if !check_owned(cx.tcx, var_t, sp) { ret; } + if !check_owned(cx.tcx, var_t, sp) { return; } // copied in data must be copyable, but moved in data can be anything let is_implicit = fv.is_some(); @@ -498,14 +498,14 @@ fn check_cast_for_escaping_regions( let target_ty = ty::expr_ty(cx.tcx, target); let target_substs = alt ty::get(target_ty).struct { ty::ty_trait(_, substs) => {substs} - _ => { ret; /* not a cast to a trait */ } + _ => { return; /* not a cast to a trait */ } }; // 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 { - some(ty::re_scope(*)) => { ret; /* case (1) */ } + some(ty::re_scope(*)) => { return; /* case (1) */ } none | some(ty::re_static) | some(ty::re_free(*)) => {} some(ty::re_bound(*)) | some(ty::re_var(*)) => { cx.tcx.sess.span_bug( diff --git a/src/rustc/middle/lang_items.rs b/src/rustc/middle/lang_items.rs index d14d2d5a0c6..f007774641d 100644 --- a/src/rustc/middle/lang_items.rs +++ b/src/rustc/middle/lang_items.rs @@ -119,7 +119,7 @@ class LanguageItemCollector { fn match_and_collect_item(item_def_id: def_id, key: ~str, value: ~str) { if !str_eq(key, ~"lang") { - ret; // Didn't match. + return; // Didn't match. } alt self.item_refs.find(value) { diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 2d103398b2e..ca39157f3bf 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -481,7 +481,7 @@ 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 { - visit::fk_fn_block(*) => { ret; } + visit::fk_fn_block(*) => { return; } _ => {} } diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 8a65a1b0567..7f18dae0db4 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -149,7 +149,7 @@ fn check_crate(tcx: ty::ctxt, last_use_map); visit::visit_crate(*crate, initial_maps, visitor); tcx.sess.abort_if_errors(); - ret last_use_map; + return last_use_map; } impl of to_str::to_str for live_node { @@ -291,7 +291,7 @@ class ir_maps { vk_local(_, name) | vk_arg(_, name, _) {name} vk_field(name) {@(~"self." + *name)} vk_self {@~"self"} - vk_implicit_ret {@~"<implicit-ret>"} + vk_implicit_return {@~"<implicit-ret>"} } } @@ -367,7 +367,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, } // Special nodes and variables: - // - exit_ln represents the end of the fn, either by ret or fail + // - exit_ln represents the end of the fn, either by return or fail // - implicit_ret_var is a pseudo-variable that represents // an implicit return let specials = { @@ -701,7 +701,7 @@ class liveness { fn merge_from_succ(ln: live_node, succ_ln: live_node, first_merge: bool) -> bool { - if ln == succ_ln { ret false; } + if ln == succ_ln { return false; } let mut changed = false; do self.indices2(ln, succ_ln) |idx, succ_idx| { @@ -717,16 +717,16 @@ class liveness { debug!{"merge_from_succ(ln=%s, succ=%s, first_merge=%b, changed=%b)", ln.to_str(), self.ln_str(succ_ln), first_merge, changed}; - ret changed; + return changed; fn copy_if_invalid(src: live_node, &dst: live_node) -> bool { if src.is_valid() { if !dst.is_valid() { dst = src; - ret true; + return true; } } - ret false; + return false; } } @@ -837,11 +837,11 @@ class liveness { fn propagate_through_stmt(stmt: @stmt, succ: live_node) -> live_node { alt stmt.node { stmt_decl(decl, _) { - ret self.propagate_through_decl(decl, succ); + return self.propagate_through_decl(decl, succ); } stmt_expr(expr, _) | stmt_semi(expr, _) { - ret self.propagate_through_expr(expr, succ); + return self.propagate_through_expr(expr, succ); } } } @@ -1275,15 +1275,15 @@ class liveness { alt def { def_self(_) { // Note: the field_map is empty unless we are in a ctor - ret self.ir.field_map.find(fld).map(|var| { + return self.ir.field_map.find(fld).map(|var| { let ln = self.live_node(expr.id, expr.span); (ln, var) }); } - _ { ret none; } + _ { return none; } } } - _ { ret none; } + _ { return none; } } } @@ -1347,7 +1347,7 @@ class liveness { let r <- f(); self.break_ln = bl; self.cont_ln = cl; - ret r; + return r; } } @@ -1558,7 +1558,7 @@ impl check_methods for @liveness { if self.ir.method_map.contains_key(expr.id) { // actually an rvalue, since this calls a method - ret vt.visit_expr(expr, self, vt); + return vt.visit_expr(expr, self, vt); } alt expr.node { @@ -1671,20 +1671,20 @@ impl check_methods for @liveness { move_span, fmt!{"illegal move from argument `%s`, which is not \ copy or move mode", *name}); - ret; + return; } vk_field(name) { self.tcx.sess.span_err( move_span, fmt!{"illegal move from field `%s`", *name}); - ret; + return; } vk_self { self.tcx.sess.span_err( move_span, ~"illegal move from self (cannot move out of a field of \ self)"); - ret; + return; } vk_local(*) | vk_implicit_ret { self.tcx.sess.span_bug( @@ -1790,9 +1790,9 @@ impl check_methods for @liveness { sp, fmt!{"unused variable: `%s`", *name}); } } - ret true; + return true; } - ret false; + return false; } fn warn_about_dead_assign(sp: span, ln: live_node, var: variable) { diff --git a/src/rustc/middle/pat_util.rs b/src/rustc/middle/pat_util.rs index 8415b5e1a32..70a432d78c9 100644 --- a/src/rustc/middle/pat_util.rs +++ b/src/rustc/middle/pat_util.rs @@ -18,7 +18,7 @@ fn pat_id_map(dm: resolve3::DefMap, pat: @pat) -> pat_id_map { do pat_bindings(dm, pat) |p_id, _s, n| { map.insert(path_to_ident(n), p_id); }; - ret map; + return map; } fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool { @@ -49,5 +49,5 @@ fn pat_bindings(dm: resolve3::DefMap, pat: @pat, fn pat_binding_ids(dm: resolve3::DefMap, pat: @pat) -> ~[node_id] { let mut found = ~[]; pat_bindings(dm, pat, |b_id, _sp, _pt| vec::push(found, b_id) ); - ret found; + return found; } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 809fd1c6fd6..ec0ad5cb770 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -89,11 +89,11 @@ fn scope_contains(region_map: region_map, superscope: ast::node_id, let mut subscope = subscope; while superscope != subscope { alt region_map.find(subscope) { - none { ret false; } + none { return false; } some(scope) { subscope = scope; } } } - ret true; + return true; } /// Determines whether one region is a subregion of another. This is @@ -129,7 +129,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, let mut scope = scope; loop { alt region_map.find(scope) { - none { ret result; } + none { return result; } some(superscope) { vec::push(result, superscope); scope = superscope; @@ -138,7 +138,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, } } - if scope_a == scope_b { ret some(scope_a); } + if scope_a == scope_b { return some(scope_a); } let a_ancestors = ancestors_of(region_map, scope_a); let b_ancestors = ancestors_of(region_map, scope_b); @@ -154,18 +154,18 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, // then the corresponding scope is a superscope of the other. if a_ancestors[a_index] != b_ancestors[b_index] { - ret none; + return none; } loop { // Loop invariant: a_ancestors[a_index] == b_ancestors[b_index] // for all indices between a_index and the end of the array - if a_index == 0u { ret some(scope_a); } - if b_index == 0u { ret some(scope_b); } + if a_index == 0u { return some(scope_a); } + if b_index == 0u { return some(scope_b); } a_index -= 1u; b_index -= 1u; if a_ancestors[a_index] != b_ancestors[b_index] { - ret some(a_ancestors[a_index + 1u]); + return some(a_ancestors[a_index + 1u]); } } } @@ -318,7 +318,7 @@ fn resolve_crate(sess: session, def_map: resolve3::DefMap, with *visit::default_visitor() }); visit::visit_crate(*crate, cx, visitor); - ret cx.region_map; + return cx.region_map; } // ___________________________________________________________________________ @@ -480,7 +480,7 @@ fn determine_rp_in_ty(ty: @ast::ty, // be region-parameterized. if cx.item_id is zero, then this type // is not a member of a type defn nor is it a constitutent of an // impl etc. So we can ignore it and its components. - if cx.item_id == 0 { ret; } + if cx.item_id == 0 { return; } // if this type directly references a region, either via a // region pointer like &r.ty or a region-parameterized path @@ -572,5 +572,5 @@ fn determine_rp_in_crate(sess: session, } // return final set - ret cx.region_paramd_items; + return cx.region_paramd_items; } diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index f66e3925fb0..ca52c5dcd34 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -231,7 +231,7 @@ enum EnumVariantOrConstResolution { type Atom = uint; fn Atom(n: uint) -> Atom { - ret n; + return n; } class AtomTable { @@ -249,7 +249,7 @@ class AtomTable { fn intern(string: @~str) -> Atom { alt self.atoms.find(string) { none { /* fall through */ } - some(atom) { ret atom; } + some(atom) { return atom; } } let atom = Atom(self.atom_count); @@ -257,17 +257,17 @@ class AtomTable { self.atoms.insert(string, atom); self.strings.push(string); - ret atom; + return atom; } fn atom_to_str(atom: Atom) -> @~str { - ret self.strings.get_elt(atom); + return self.strings.get_elt(atom); } fn atoms_to_strs(atoms: ~[Atom], f: fn(@~str) -> bool) { for atoms.each |atom| { if !f(self.atom_to_str(atom)) { - ret; + return; } } } @@ -287,13 +287,13 @@ class AtomTable { } // XXX: Shouldn't copy here. We need string builder functionality. - ret @result; + return @result; } } /// Creates a hash table of atoms. fn atom_hashmap<V:copy>() -> hashmap<Atom,V> { - ret hashmap::<Atom,V>(|a| a, |a, b| a == b); + return hashmap::<Atom,V>(|a| a, |a, b| a == b); } /** @@ -368,15 +368,15 @@ class ImportResolution { fn target_for_namespace(namespace: Namespace) -> option<Target> { alt namespace { - ModuleNS { ret copy self.module_target; } - TypeNS { ret copy self.type_target; } - ValueNS { ret copy self.value_target; } + ModuleNS { return copy self.module_target; } + TypeNS { return copy self.type_target; } + ValueNS { return copy self.value_target; } ImplNS { if (*self.impl_target).len() > 0u { - ret some(copy *(*self.impl_target).get_elt(0u)); + return some(copy *(*self.impl_target).get_elt(0u)); } - ret none; + return none; } } } @@ -453,7 +453,7 @@ class Module { } fn all_imports_resolved() -> bool { - ret self.imports.len() == self.resolved_import_count; + return self.imports.len() == self.resolved_import_count; } } @@ -462,8 +462,8 @@ class Module { pure fn is_none<T>(x: option<T>) -> bool { alt x { - none { ret true; } - some(_) { ret false; } + none { return true; } + some(_) { return false; } } } @@ -471,10 +471,10 @@ fn unused_import_lint_level(session: session) -> level { for session.opts.lint_opts.each |lint_option_pair| { let (lint_type, lint_level) = lint_option_pair; if lint_type == unused_imports { - ret lint_level; + return lint_level; } } - ret allow; + return allow; } // Records the definitions (at most one for each namespace) that a name is @@ -518,8 +518,8 @@ class NameBindings { /// Returns the module node if applicable. fn get_module_if_available() -> option<@Module> { alt self.module_def { - NoModuleDef { ret none; } - ModuleDef(module_) { ret some(module_); } + NoModuleDef { return none; } + ModuleDef(module_) { return some(module_); } } } @@ -534,40 +534,40 @@ class NameBindings { ~"get_module called on a node with no module definition!"; } ModuleDef(module_) { - ret module_; + return module_; } } } fn defined_in_namespace(namespace: Namespace) -> bool { alt namespace { - ModuleNS { ret self.module_def != NoModuleDef; } - TypeNS { ret self.type_def != none; } - ValueNS { ret self.value_def != none; } - ImplNS { ret self.impl_defs.len() >= 1u; } + ModuleNS { return self.module_def != NoModuleDef; } + TypeNS { return self.type_def != none; } + ValueNS { return self.value_def != none; } + ImplNS { return self.impl_defs.len() >= 1u; } } } fn def_for_namespace(namespace: Namespace) -> option<def> { alt namespace { TypeNS { - ret self.type_def; + return self.type_def; } ValueNS { - ret self.value_def; + return self.value_def; } ModuleNS { alt self.module_def { NoModuleDef { - ret none; + return none; } ModuleDef(module_) { alt module_.def_id { none { - ret none; + return none; } some(def_id) { - ret some(def_mod(def_id)); + return some(def_mod(def_id)); } } } @@ -578,9 +578,9 @@ class NameBindings { // necessarily the right def. if self.impl_defs.len() == 0u { - ret none; + return none; } - ret some(def_ty(self.impl_defs[0].did)); + return some(def_ty(self.impl_defs[0].did)); } } } @@ -766,7 +766,7 @@ class Resolver { -> @Module { alt reduced_graph_parent { ModuleReducedGraphParent(module_) { - ret module_; + return module_; } } } @@ -802,10 +802,10 @@ class Resolver { none { let child = @NameBindings(); module_.children.insert(name, child); - ret (child, new_parent); + return (child, new_parent); } some(child) { - ret (child, new_parent); + return (child, new_parent); } } } @@ -813,7 +813,7 @@ class Resolver { fn block_needs_anonymous_module(block: blk) -> bool { // If the block has view items, we need an anonymous module. if block.node.view_items.len() > 0u { - ret true; + return true; } // Check each statement. @@ -822,7 +822,7 @@ class Resolver { stmt_decl(declaration, _) { alt declaration.node { decl_item(_) { - ret true; + return true; } _ { // Keep searching. @@ -838,13 +838,13 @@ class Resolver { // If we found neither view items nor items, we don't need to create // an anonymous module. - ret false; + return false; } fn get_parent_link(parent: ReducedGraphParent, name: Atom) -> ParentLink { alt parent { ModuleReducedGraphParent(module_) { - ret ModuleParentLink(module_, name); + return ModuleParentLink(module_, name); } } } @@ -1483,7 +1483,7 @@ class Resolver { debug!{"(building reduced graph for impls in external \ module) no def ID for `%s`, skipping", self.module_to_str(module_)}; - ret; + return; } some(_) { // Continue. @@ -1623,7 +1623,7 @@ class Resolver { debug!{"(resolving imports for module) all imports resolved for \ %s", self.module_to_str(module_)}; - ret; + return; } let import_count = module_.imports.len(); @@ -1740,7 +1740,7 @@ class Resolver { } } - ret resolution_result; + return resolution_result; } fn resolve_single_import(module_: @Module, containing_module: @Module, @@ -1757,7 +1757,7 @@ class Resolver { if !self.name_is_exported(containing_module, source) { debug!{"(resolving single import) name `%s` is unexported", *(*self.atom_table).atom_to_str(source)}; - ret Failed; + return Failed; } // We need to resolve all four namespaces for this to succeed. @@ -1813,7 +1813,7 @@ class Resolver { if containing_module.glob_count > 0u { debug!{"(resolving single import) unresolved glob; \ bailing out"}; - ret Indeterminate; + return Indeterminate; } // Now search the exported imports within the containing @@ -1850,11 +1850,11 @@ class Resolver { alt (*import_resolution). target_for_namespace(namespace) { none { - ret UnboundResult; + return UnboundResult; } some(target) { import_resolution.used = true; - ret BoundResult(target.target_module, + return BoundResult(target.target_module, target.bindings); } } @@ -1865,9 +1865,9 @@ class Resolver { -> ImplNamespaceResult { if (*import_resolution.impl_target).len() == 0u { - ret UnboundImplResult; + return UnboundImplResult; } - ret BoundImplResult(import_resolution. + return BoundImplResult(import_resolution. impl_target); } @@ -1896,7 +1896,7 @@ class Resolver { // The import is unresolved. Bail out. debug!{"(resolving single import) unresolved import; \ bailing out"}; - ret Indeterminate; + return Indeterminate; } } } @@ -1958,7 +1958,7 @@ class Resolver { If this name wasn't found in any of the four namespaces, it's definitely unresolved */ - (none, none, none, v) if v.len() == 0 { ret Failed; } + (none, none, none, v) if v.len() == 0 { return Failed; } _ {} } @@ -1966,7 +1966,7 @@ class Resolver { import_resolution.outstanding_references -= 1u; debug!{"(resolving single import) successfully resolved import"}; - ret Success(()); + return Success(()); } /** @@ -1989,7 +1989,7 @@ class Resolver { if !(*containing_module).all_imports_resolved() { debug!{"(resolving glob import) target module has unresolved \ imports; bailing out"}; - ret Indeterminate; + return Indeterminate; } assert containing_module.glob_count == 0u; @@ -2125,7 +2125,7 @@ class Resolver { } debug!{"(resolving glob import) successfully resolved import"}; - ret Success(()); + return Success(()); } fn resolve_module_path_from_root(module_: @Module, @@ -2150,13 +2150,13 @@ class Resolver { Failed { self.session.span_err(span, ~"unresolved name"); - ret Failed; + return Failed; } Indeterminate { debug!{"(resolving module path for import) module \ resolution is indeterminate: %s", *(*self.atom_table).atom_to_str(name)}; - ret Indeterminate; + return Indeterminate; } Success(target) { alt target.bindings.module_def { @@ -2166,7 +2166,7 @@ class Resolver { fmt!{"not a module: %s", *(*self.atom_table). atom_to_str(name)}); - ret Failed; + return Failed; } ModuleDef(module_) { search_module = module_; @@ -2178,7 +2178,7 @@ class Resolver { index += 1u; } - ret Success(search_module); + return Success(search_module); } /** @@ -2207,19 +2207,19 @@ class Resolver { alt self.resolve_module_in_lexical_scope(module_, first_element) { Failed { self.session.span_err(span, ~"unresolved name"); - ret Failed; + return Failed; } Indeterminate { debug!{"(resolving module path for import) indeterminate; \ bailing"}; - ret Indeterminate; + return Indeterminate; } Success(resulting_module) { search_module = resulting_module; } } - ret self.resolve_module_path_from_root(search_module, + return self.resolve_module_path_from_root(search_module, module_path, 1u, xray, @@ -2244,7 +2244,7 @@ class Resolver { some(name_bindings) if (*name_bindings).defined_in_namespace(namespace) { - ret Success(Target(module_, name_bindings)); + return Success(Target(module_, name_bindings)); } some(_) | none { /* Not found; continue. */ } } @@ -2268,7 +2268,7 @@ class Resolver { } some(target) { import_resolution.used = true; - ret Success(copy target); + return Success(copy target); } } } @@ -2283,7 +2283,7 @@ class Resolver { // No more parents. This module was unresolved. debug!{"(resolving item in lexical scope) unresolved \ module"}; - ret Failed; + return Failed; } ModuleParentLink(parent_module_node, _) | BlockParentLink(parent_module_node, _) { @@ -2303,11 +2303,11 @@ class Resolver { debug!{"(resolving item in lexical scope) indeterminate \ higher scope; bailing"}; - ret Indeterminate; + return Indeterminate; } Success(target) { // We found the module. - ret Success(copy target); + return Success(copy target); } } } @@ -2322,28 +2322,28 @@ class Resolver { NoModuleDef { error!{"!!! (resolving module in lexical scope) module wasn't actually a module!"}; - ret Failed; + return Failed; } ModuleDef(module_) { - ret Success(module_); + return Success(module_); } } } Indeterminate { debug!{"(resolving module in lexical scope) indeterminate; \ bailing"}; - ret Indeterminate; + return Indeterminate; } Failed { debug!{"(resolving module in lexical scope) failed to \ resolve"}; - ret Failed; + return Failed; } } } fn name_is_exported(module_: @Module, name: Atom) -> bool { - ret module_.exported_names.size() == 0u || + return module_.exported_names.size() == 0u || module_.exported_names.contains_key(name); } @@ -2365,7 +2365,7 @@ class Resolver { if xray == NoXray && !self.name_is_exported(module_, name) { debug!{"(resolving name in module) name `%s` is unexported", *(*self.atom_table).atom_to_str(name)}; - ret Failed; + return Failed; } // First, check the direct children of the module. @@ -2374,7 +2374,7 @@ class Resolver { if (*name_bindings).defined_in_namespace(namespace) { debug!{"(resolving name in module) found node as child"}; - ret Success(Target(module_, name_bindings)); + return Success(Target(module_, name_bindings)); } some(_) | none { // Continue. @@ -2386,7 +2386,7 @@ class Resolver { if module_.glob_count > 0u { debug!{"(resolving name in module) module has glob; bailing out"}; - ret Indeterminate; + return Indeterminate; } // Otherwise, we check the list of resolved imports. @@ -2395,7 +2395,7 @@ class Resolver { if import_resolution.outstanding_references != 0u { debug!{"(resolving name in module) import unresolved; \ bailing out"}; - ret Indeterminate; + return Indeterminate; } alt (*import_resolution).target_for_namespace(namespace) { @@ -2408,7 +2408,7 @@ class Resolver { debug!{"(resolving name in module) resolved to \ import"}; import_resolution.used = true; - ret Success(copy target); + return Success(copy target); } } } @@ -2420,7 +2420,7 @@ class Resolver { // We're out of luck. debug!{"(resolving name in module) failed to resolve %s", *(*self.atom_table).atom_to_str(name)}; - ret Failed; + return Failed; } /** @@ -2468,7 +2468,7 @@ class Resolver { Indeterminate { debug!{"(resolving one-level renaming import) module result \ is indeterminate; bailing"}; - ret Indeterminate; + return Indeterminate; } Success(name_bindings) { debug!{"(resolving one-level renaming import) module result \ @@ -2491,7 +2491,7 @@ class Resolver { Indeterminate { debug!{"(resolving one-level renaming import) value result \ is indeterminate; bailing"}; - ret Indeterminate; + return Indeterminate; } Success(name_bindings) { debug!{"(resolving one-level renaming import) value result \ @@ -2514,7 +2514,7 @@ class Resolver { Indeterminate { debug!{"(resolving one-level renaming import) type result is \ indeterminate; bailing"}; - ret Indeterminate; + return Indeterminate; } Success(name_bindings) { debug!{"(resolving one-level renaming import) type result \ @@ -2554,7 +2554,7 @@ class Resolver { Indeterminate { debug!{"(resolving one-level renaming import) impl result is \ indeterminate; bailing"}; - ret Indeterminate; + return Indeterminate; } Success(name_bindings) { debug!{"(resolving one-level renaming import) impl result \ @@ -2569,7 +2569,7 @@ class Resolver { self.session.span_err(import_directive.span, ~"unresolved import"); - ret Failed; + return Failed; } // Otherwise, proceed and write in the bindings. @@ -2605,7 +2605,7 @@ class Resolver { } debug!{"(resolving one-level renaming import) successfully resolved"}; - ret Success(()); + return Success(()); } fn report_unresolved_imports(module_: @Module) { @@ -2663,7 +2663,7 @@ class Resolver { debug!{"(recording exports for module subtree) not recording \ exports for `%s`", self.module_to_str(module_)}; - ret; + return; } } @@ -2749,7 +2749,7 @@ class Resolver { debug!{"(building impl scopes for module subtree) not \ resolving implementations for `%s`", self.module_to_str(module_)}; - ret; + return; } } @@ -2903,7 +2903,7 @@ class Resolver { is_ty_param = false; } _ { - ret some(def_like); + return some(def_like); } } @@ -2947,7 +2947,7 @@ class Resolver { argument out of scope"); } - ret none; + return none; } } } @@ -2969,14 +2969,14 @@ class Resolver { argument out of scope"); } - ret none; + return none; } } rib_index += 1u; } - ret some(dl_def(def)); + return some(dl_def(def)); } fn search_ribs(ribs: @dvec<@Rib>, name: Atom, span: span, @@ -2992,7 +2992,7 @@ class Resolver { let rib = (*ribs).get_elt(i); alt rib.bindings.find(name) { some(def_like) { - ret self.upvarify(ribs, i, def_like, span, + return self.upvarify(ribs, i, def_like, span, allow_capturing_self); } none { @@ -3001,7 +3001,7 @@ class Resolver { } } - ret none; + return none; } // XXX: This shouldn't be unsafe! @@ -3595,7 +3595,7 @@ class Resolver { }; } fn check_consistent_bindings(arm: arm) { - if arm.pats.len() == 0 { ret; } + if arm.pats.len() == 0 { return; } let good = self.num_bindings(arm.pats[0]); for arm.pats.each() |p: @pat| { if self.num_bindings(p) != good { @@ -3890,13 +3890,13 @@ class Resolver { of name bindings with no def?!"; } some(def @ def_variant(*)) { - ret FoundEnumVariant(def); + return FoundEnumVariant(def); } some(def_const(*)) { - ret FoundConst; + return FoundConst; } some(_) { - ret EnumVariantOrConstNotFound; + return EnumVariantOrConstNotFound; } } } @@ -3906,7 +3906,7 @@ class Resolver { } Failed { - ret EnumVariantOrConstNotFound; + return EnumVariantOrConstNotFound; } } } @@ -3925,18 +3925,18 @@ class Resolver { } if path.global { - ret self.resolve_crate_relative_path(path, + return self.resolve_crate_relative_path(path, self.xray_context, namespace); } if path.idents.len() > 1u { - ret self.resolve_module_relative_path(path, + return self.resolve_module_relative_path(path, self.xray_context, namespace); } - ret self.resolve_identifier(path.idents.last(), + return self.resolve_identifier(path.idents.last(), namespace, check_ribs, path.span); @@ -3953,7 +3953,7 @@ class Resolver { namespace, span) { some(def) { - ret some(def); + return some(def); } none { // Continue. @@ -3961,7 +3961,7 @@ class Resolver { } } - ret self.resolve_item_by_identifier_in_lexical_scope(identifier, + return self.resolve_item_by_identifier_in_lexical_scope(identifier, namespace); } @@ -3976,7 +3976,7 @@ class Resolver { debug!{"(resolving definition of name in module) name `%s` is \ unexported", *(*self.atom_table).atom_to_str(name)}; - ret NoNameDefinition; + return NoNameDefinition; } // First, search children. @@ -3985,7 +3985,7 @@ class Resolver { alt (*child_name_bindings).def_for_namespace(namespace) { some(def) { // Found it. Stop the search here. - ret ChildNameDefinition(def); + return ChildNameDefinition(def); } none { // Continue. @@ -4006,23 +4006,23 @@ class Resolver { some(def) { // Found it. import_resolution.used = true; - ret ImportNameDefinition(def); + return ImportNameDefinition(def); } none { // This can happen with external impls, due to // the imperfect way we read the metadata. - ret NoNameDefinition; + return NoNameDefinition; } } } none { - ret NoNameDefinition; + return NoNameDefinition; } } } none { - ret NoNameDefinition; + return NoNameDefinition; } } } @@ -4037,7 +4037,7 @@ class Resolver { (*module_path_atoms).push((*self.atom_table).intern(ident)); } - ret module_path_atoms; + return module_path_atoms; } fn resolve_module_relative_path(path: @path, @@ -4058,7 +4058,7 @@ class Resolver { fmt!{"use of undeclared module `%s`", *(*self.atom_table).atoms_to_str ((*module_path_atoms).get())}); - ret none; + return none; } Indeterminate { @@ -4083,10 +4083,10 @@ class Resolver { ((*module_path_atoms).get()), *(*self.atom_table).atom_to_str (name)}); - ret none; + return none; } ChildNameDefinition(def) | ImportNameDefinition(def) { - ret some(def); + return some(def); } } } @@ -4112,7 +4112,7 @@ class Resolver { fmt!{"use of undeclared module `::%s`", *(*self.atom_table).atoms_to_str ((*module_path_atoms).get())}); - ret none; + return none; } Indeterminate { @@ -4137,10 +4137,10 @@ class Resolver { ((*module_path_atoms).get()), *(*self.atom_table).atom_to_str (name)}); - ret none; + return none; } ChildNameDefinition(def) | ImportNameDefinition(def) { - ret some(def); + return some(def); } } } @@ -4174,10 +4174,10 @@ class Resolver { local: %?", *(*self.atom_table).atom_to_str(name), def}; - ret some(def); + return some(def); } some(dl_field) | some(dl_impl(_)) | none { - ret none; + return none; } } } @@ -4203,7 +4203,7 @@ class Resolver { debug!{"(resolving item path in lexical scope) \ resolved `%s` to item", *(*self.atom_table).atom_to_str(name)}; - ret some(def); + return some(def); } } } @@ -4211,7 +4211,7 @@ class Resolver { fail ~"unexpected indeterminate result"; } Failed { - ret none; + return none; } } } @@ -4452,7 +4452,7 @@ class Resolver { } } - ret found_traits; + return found_traits; } fn add_trait_info_if_containing_method(found_traits: @dvec<def_id>, @@ -4494,7 +4494,7 @@ class Resolver { fn check_for_unused_imports_if_necessary() { if self.unused_import_lint_level == allow { - ret; + return; } let root_module = (*self.graph_root).get_module(); @@ -4517,7 +4517,7 @@ class Resolver { debug!{"(checking for unused imports in module subtree) not \ checking for unused imports for `%s`", self.module_to_str(module_)}; - ret; + return; } } @@ -4590,7 +4590,7 @@ class Resolver { } if atoms.len() == 0u { - ret ~"???"; + return ~"???"; } let mut string = ~""; @@ -4607,7 +4607,7 @@ class Resolver { i -= 1u; } - ret string; + return string; } fn dump_module(module_: @Module) { @@ -4696,7 +4696,7 @@ fn resolve_crate(session: session, lang_items: LanguageItems, crate: @crate) let resolver = @Resolver(session, lang_items, crate); (*resolver).resolve(resolver); - ret { + return { def_map: resolver.def_map, exp_map: resolver.export_map, impl_map: resolver.impl_map, diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index 62b7c247784..072ec43dbb9 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -54,17 +54,19 @@ fn trans_opt(bcx: block, o: opt) -> opt_result { let cell = empty_dest_cell(); bcx = tvec::trans_estr(bcx, s, ast::vstore_uniq, by_val(cell)); add_clean_temp(bcx, *cell, strty); - ret single_result(rslt(bcx, *cell)); + return single_result(rslt(bcx, *cell)); } _ { - ret single_result( + return single_result( rslt(bcx, consts::const_expr(ccx, l))); } } } - var(disr_val, _) { ret single_result(rslt(bcx, C_int(ccx, disr_val))); } + var(disr_val, _) { + return single_result(rslt(bcx, C_int(ccx, disr_val))); + } range(l1, l2) { - ret range_result(rslt(bcx, consts::const_expr(ccx, l1)), + return range_result(rslt(bcx, consts::const_expr(ccx, l1)), rslt(bcx, consts::const_expr(ccx, l2))); } } @@ -74,7 +76,7 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt { let vdef = ast_util::variant_def_ids(tcx.def_map.get(pat_id)); let variants = ty::enum_variants(tcx, vdef.enm); for vec::each(*variants) |v| { - if vdef.var == v.id { ret var(v.disr_val, vdef); } + if vdef.var == v.id { return var(v.disr_val, vdef); } } core::unreachable(); } @@ -110,11 +112,11 @@ type match_ = ~[match_branch]; fn has_nested_bindings(m: match_, col: uint) -> bool { for vec::each(m) |br| { alt br.pats[col].node { - ast::pat_ident(_, _, some(_)) { ret true; } + ast::pat_ident(_, _, some(_)) { return true; } _ {} } } - ret false; + return false; } fn expand_nested_bindings(bcx: block, m: match_, col: uint, val: ValueRef) @@ -175,7 +177,7 @@ fn enter_match(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef, none { } } } - ret result; + return result; } fn enter_default(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) @@ -275,7 +277,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] { fn add_to_set(tcx: ty::ctxt, &&set: dvec<opt>, val: opt) { - if set.any(|l| opt_eq(tcx, l, val)) {ret;} + if set.any(|l| opt_eq(tcx, l, val)) {return;} set.push(val); } @@ -294,7 +296,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] { } } } - ret vec::from_mut(dvec::unwrap(found)); + return vec::from_mut(dvec::unwrap(found)); } fn extract_variant_args(bcx: block, pat_id: ast::node_id, @@ -320,7 +322,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, GEP_enum(bcx, blobptr, vdefs_tg, vdefs_var, enum_ty_substs, i) }; - ret {vals: args, bcx: bcx}; + return {vals: args, bcx: bcx}; } fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] { @@ -337,7 +339,7 @@ fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] { _ { } } } - ret fields; + return fields; } fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) { @@ -354,7 +356,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) { let ty = node_id_type(bcx, pat_id); let val = load_if_immediate(bcx, val, ty); root_value(bcx, val, ty, scope_id); - ret; // if we kept going, we'd only be rooting same value again + return; // if we kept going, we'd only be rooting same value again } } } @@ -362,23 +364,23 @@ 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 { ast::pat_box(_) { ret true; } _ { } } + alt br.pats[col].node { ast::pat_box(_) { return true; } _ { } } } - ret false; + return false; } fn any_uniq_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { ast::pat_uniq(_) { ret true; } _ { } } + alt br.pats[col].node { ast::pat_uniq(_) { return true; } _ { } } } - ret false; + return false; } fn any_tup_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { ast::pat_tup(_) { ret true; } _ { } } + alt br.pats[col].node { ast::pat_tup(_) { return true; } _ { } } } - ret false; + return false; } type exit_node = {bound: bind_map, from: BasicBlockRef, to: BasicBlockRef}; @@ -403,13 +405,13 @@ fn pick_col(m: match_) -> uint { for vec::each(scores) |score| { // Irrefutable columns always go first, they'd only be duplicated in // the branches. - if score == 0u { ret i; } + if score == 0u { return i; } // If no irrefutable ones are found, we pick the one with the biggest // branching factor. if score > max_score { max_score = score; best_col = i; } i += 1u; } - ret best_col; + return best_col; } fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], @@ -421,7 +423,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let _icx = bcx.insn_ctxt(~"alt::compile_submatch"); let mut bcx = bcx; let tcx = bcx.tcx(), dm = tcx.def_map; - if m.len() == 0u { Br(bcx, option::get(chk)()); ret; } + if m.len() == 0u { Br(bcx, option::get(chk)()); return; } if m[0].pats.len() == 0u { let data = m[0].data; alt data.guard { @@ -464,7 +466,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], to: data.bodycx.llbb}); } Br(bcx, data.bodycx.llbb); - ret; + return; } let col = pick_col(m); @@ -496,7 +498,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], } compile_submatch(bcx, enter_rec(bcx, dm, m, col, rec_fields, val), vec::append(rec_vals, vals_left), chk, exits); - ret; + return; } if any_tup_pat(m, col) { @@ -512,7 +514,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], } compile_submatch(bcx, enter_tup(bcx, dm, m, col, val, n_tup_elts), vec::append(tup_vals, vals_left), chk, exits); - ret; + return; } // Unbox in case of a box field @@ -523,7 +525,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], GEPi(bcx, box_no_addrspace, ~[0u, abi::box_field_body]); compile_submatch(bcx, enter_box(bcx, dm, m, col, val), vec::append(~[unboxed], vals_left), chk, exits); - ret; + return; } if any_uniq_pat(m, col) { @@ -533,7 +535,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], GEPi(bcx, box_no_addrspace, ~[0u, abi::box_field_body]); compile_submatch(bcx, enter_uniq(bcx, dm, m, col, val), vec::append(~[unboxed], vals_left), chk, exits); - ret; + return; } // Decide what kind of branch we need @@ -676,7 +678,7 @@ fn make_phi_bindings(bcx: block, map: ~[exit_node], if !success { Unreachable(bcx); } - ret success; + return success; } // Copies by-value bindings into their homes. @@ -746,7 +748,7 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], let mut bodies = ~[], matches = ~[]; let {bcx, val, _} = trans_temp_expr(bcx, expr); - if bcx.unreachable { ret bcx; } + if bcx.unreachable { return bcx; } for vec::each(arms) |a| { let body = scope_block(bcx, a.body.info(), ~"case_body"); @@ -762,11 +764,11 @@ 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) { ret bb; } _ { } } + alt *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); - ret fail_cx.llbb; + return fail_cx.llbb; } let t = node_id_type(bcx, expr.id); let mk_fail = alt mode { @@ -819,7 +821,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, // Necessary since bind_irrefutable_pat is called outside trans_alt alt pat.node { ast::pat_ident(_, _,inner) { - if pat_is_variant(bcx.tcx().def_map, pat) { ret bcx; } + if pat_is_variant(bcx.tcx().def_map, pat) { return bcx; } if make_copy { let ty = node_id_type(bcx, pat.id); let llty = type_of::type_of(ccx, ty); @@ -873,7 +875,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, } ast::pat_wild | ast::pat_lit(_) | ast::pat_range(_, _) { } } - ret bcx; + return bcx; } // Local Variables: diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index ef92891418a..c864dec860e 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -74,7 +74,7 @@ fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str { } fn empty_dest_cell() -> @mut ValueRef { - ret @mut llvm::LLVMGetUndef(T_nil()); + return @mut llvm::LLVMGetUndef(T_nil()); } fn dup_for_join(dest: dest) -> dest { @@ -148,7 +148,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], _ {} } } - ret out; + return out; } // Used to put an immediate value in a dest. @@ -158,7 +158,7 @@ fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { by_val(cell) { *cell = val; } save_in(addr) { Store(bcx, val, addr); } } - ret bcx; + return bcx; } fn get_dest_addr(dest: dest) -> ValueRef { @@ -182,11 +182,11 @@ fn decl_fn(llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, llvm::LLVMGetOrInsertFunction(llmod, buf, llty) }); lib::llvm::SetFunctionCallConv(llfn, cc); - ret llfn; + return llfn; } fn decl_cdecl_fn(llmod: ModuleRef, name: ~str, llty: TypeRef) -> ValueRef { - ret decl_fn(llmod, name, lib::llvm::CCallConv, llty); + return decl_fn(llmod, name, lib::llvm::CCallConv, llty); } @@ -196,24 +196,24 @@ fn decl_internal_cdecl_fn(llmod: ModuleRef, name: ~str, llty: TypeRef) -> ValueRef { let llfn = decl_cdecl_fn(llmod, name, llty); lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage); - ret llfn; + return llfn; } fn get_extern_fn(externs: hashmap<~str, ValueRef>, llmod: ModuleRef, name: ~str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { - if externs.contains_key(name) { ret externs.get(name); } + if externs.contains_key(name) { return externs.get(name); } let f = decl_fn(llmod, name, cc, ty); externs.insert(name, f); - ret f; + return f; } fn get_extern_const(externs: hashmap<~str, ValueRef>, llmod: ModuleRef, name: ~str, ty: TypeRef) -> ValueRef { - if externs.contains_key(name) { ret externs.get(name); } + if externs.contains_key(name) { return externs.get(name); } let c = str::as_c_str(name, |buf| llvm::LLVMAddGlobal(llmod, ty, buf)); externs.insert(name, c); - ret c; + return c; } fn get_simple_extern_fn(cx: block, @@ -225,7 +225,7 @@ fn get_simple_extern_fn(cx: block, let inputs = vec::from_elem(n_args as uint, ccx.int_type); let output = ccx.int_type; let t = T_fn(inputs, output); - ret get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t); + return get_extern_fn(externs, llmod, name, lib::llvm::CCallConv, t); } fn trans_foreign_call(cx: block, externs: hashmap<~str, ValueRef>, @@ -239,7 +239,7 @@ fn trans_foreign_call(cx: block, externs: hashmap<~str, ValueRef>, for vec::each(args) |a| { vec::push(call_args, a); } - ret Call(cx, llforeign, call_args); + return Call(cx, llforeign, call_args); } fn trans_free(cx: block, v: ValueRef) -> block { @@ -256,13 +256,13 @@ fn trans_unique_free(cx: block, v: ValueRef) -> block { fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { let _icx = cx.insn_ctxt(~"umax"); let cond = ICmp(cx, lib::llvm::IntULT, a, b); - ret Select(cx, cond, b, a); + return Select(cx, cond, b, a); } fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { let _icx = cx.insn_ctxt(~"umin"); let cond = ICmp(cx, lib::llvm::IntULT, a, b); - ret Select(cx, cond, a, b); + return Select(cx, cond, a, b); } fn alloca(cx: block, t: TypeRef) -> ValueRef { @@ -275,11 +275,11 @@ fn alloca_zeroed(cx: block, t: TypeRef) -> ValueRef { fn alloca_maybe_zeroed(cx: block, t: TypeRef, zero: bool) -> ValueRef { let _icx = cx.insn_ctxt(~"alloca"); - if cx.unreachable { ret llvm::LLVMGetUndef(t); } + if cx.unreachable { return llvm::LLVMGetUndef(t); } let initcx = raw_block(cx.fcx, false, cx.fcx.llstaticallocas); let p = Alloca(initcx, t); if zero { Store(initcx, C_null(t), p); } - ret p; + return p; } fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) -> block { @@ -288,13 +288,14 @@ fn zero_mem(cx: block, llptr: ValueRef, t: ty::t) -> block { let ccx = cx.ccx(); let llty = type_of(ccx, t); Store(bcx, C_null(llty), llptr); - ret bcx; + return bcx; } fn arrayalloca(cx: block, t: TypeRef, v: ValueRef) -> ValueRef { let _icx = cx.insn_ctxt(~"arrayalloca"); - if cx.unreachable { ret llvm::LLVMGetUndef(t); } - ret ArrayAlloca(raw_block(cx.fcx, false, cx.fcx.llstaticallocas), t, v); + if cx.unreachable { return llvm::LLVMGetUndef(t); } + return ArrayAlloca( + raw_block(cx.fcx, false, cx.fcx.llstaticallocas), t, v); } // Given a pointer p, returns a pointer sz(p) (i.e., inc'd by sz bytes). @@ -376,7 +377,7 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, let rval = alloca_zeroed(bcx, T_ptr(T_i8())); let bcx = trans_rtcall(bcx, rtcall, ~[tydesc, size], save_in(rval)); let retval = {bcx: bcx, val: PointerCast(bcx, Load(bcx, rval), llty)}; - ret retval; + return retval; } // malloc_raw: expects an unboxed type and returns a pointer to @@ -394,7 +395,7 @@ fn malloc_general_dyn(bcx: block, t: ty::t, heap: heap, size: ValueRef) let {bcx: bcx, val: llbox} = malloc_raw_dyn(bcx, t, heap, size); let non_gc_box = non_gc_box_cast(bcx, llbox); let body = GEPi(bcx, non_gc_box, ~[0u, abi::box_field_body]); - ret {bcx: bcx, box: llbox, body: body}; + return {bcx: bcx, box: llbox, body: body}; } fn malloc_general(bcx: block, t: ty::t, heap: heap) @@ -510,7 +511,7 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { mut free_glue: none, mut visit_glue: none}; log(debug, ~"--- declare_tydesc " + ppaux::ty_to_str(ccx.tcx, t)); - ret inf; + return inf; } type glue_helper = fn@(block, ValueRef, ty::t); @@ -529,7 +530,7 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef, note_unique_llvm_symbol(ccx, fn_nm); let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty); set_glue_inlining(llfn, t); - ret llfn; + return llfn; } fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, @@ -551,7 +552,7 @@ fn make_generic_glue_inner(ccx: @crate_ctxt, t: ty::t, let llval0 = BitCast(bcx, llrawptr0, llty); helper(bcx, llval0, t); finish_fn(fcx, lltop); - ret llfn; + return llfn; } fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, @@ -559,7 +560,7 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, -> ValueRef { let _icx = ccx.insn_ctxt(~"make_generic_glue"); if !ccx.sess.trans_stats() { - ret make_generic_glue_inner(ccx, t, llfn, helper); + return make_generic_glue_inner(ccx, t, llfn, helper); } let start = time::get_time(); @@ -567,7 +568,7 @@ fn make_generic_glue(ccx: @crate_ctxt, t: ty::t, llfn: ValueRef, let end = time::get_time(); log_fn_time(ccx, ~"glue " + name + ~" " + ty_to_short_str(ccx.tcx, t), start, end); - ret llval; + return llval; } fn emit_tydescs(ccx: @crate_ctxt) { @@ -712,7 +713,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) { make_free_glue(bcx, v, tvec::expand_boxed_vec_ty(bcx.tcx(), t)); - ret; + return; } ty::ty_fn(_) { closure::make_fn_glue(bcx, v, t, free_ty) @@ -879,13 +880,13 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, let f = |a| compare_scalar_values(cx, lhs, rhs, a, op); alt ty::get(t).struct { - ty::ty_nil { ret rslt(cx, f(nil_type)); } - ty::ty_bool | ty::ty_ptr(_) { ret rslt(cx, f(unsigned_int)); } - ty::ty_int(_) { ret rslt(cx, f(signed_int)); } - ty::ty_uint(_) { ret rslt(cx, f(unsigned_int)); } - ty::ty_float(_) { ret rslt(cx, f(floating_point)); } + 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)); } + ty::ty_uint(_) { return rslt(cx, f(unsigned_int)); } + ty::ty_float(_) { return rslt(cx, f(floating_point)); } ty::ty_type { - ret rslt(trans_fail(cx, none, + return rslt(trans_fail(cx, none, ~"attempt to compare values of type type"), C_nil()); } @@ -912,8 +913,8 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, // We don't need to do actual comparisons for nil. // () == () holds but () < () does not. alt op { - ast::eq | ast::le | ast::ge { ret C_bool(true); } - ast::ne | ast::lt | ast::gt { ret C_bool(false); } + ast::eq | ast::le | ast::ge { return C_bool(true); } + ast::ne | ast::lt | ast::gt { return C_bool(false); } // refinements would be nice _ { die(); } } @@ -928,7 +929,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, ast::ge { lib::llvm::RealOGE } _ { die(); } }; - ret FCmp(cx, cmp, lhs, rhs); + return FCmp(cx, cmp, lhs, rhs); } signed_int { let cmp = alt op { @@ -940,7 +941,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, ast::ge { lib::llvm::IntSGE } _ { die(); } }; - ret ICmp(cx, cmp, lhs, rhs); + return ICmp(cx, cmp, lhs, rhs); } unsigned_int { let cmp = alt op { @@ -952,7 +953,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, ast::ge { lib::llvm::IntUGE } _ { die(); } }; - ret ICmp(cx, cmp, lhs, rhs); + return ICmp(cx, cmp, lhs, rhs); } } } @@ -961,7 +962,7 @@ type val_pair_fn = fn@(block, ValueRef, ValueRef) -> block; type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> block; fn load_inbounds(cx: block, p: ValueRef, idxs: ~[uint]) -> ValueRef { - ret Load(cx, GEPi(cx, p, idxs)); + return Load(cx, GEPi(cx, p, idxs)); } fn store_inbounds(cx: block, v: ValueRef, p: ValueRef, @@ -979,7 +980,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, tps: ~[ty::t], tid: ast::def_id, f: val_and_ty_fn) -> block { let _icx = cx.insn_ctxt(~"iter_variant"); - if variant.args.len() == 0u { ret cx; } + if variant.args.len() == 0u { return cx; } let fn_ty = variant.ctor_ty; let ccx = cx.ccx(); let mut cx = cx; @@ -996,7 +997,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, } _ { cx.tcx().sess.bug(~"iter_variant: not a function type"); } } - ret cx; + return cx; } /* @@ -1027,7 +1028,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, // Cast the enums to types we can GEP into. if n_variants == 1u { - ret iter_variant(cx, av, variants[0], + return iter_variant(cx, av, variants[0], substs.tps, tid, f); } @@ -1056,7 +1057,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, substs.tps, tid, f); Br(variant_cx, next_cx.llbb); } - ret next_cx; + return next_cx; } ty::ty_class(did, substs) { // Take the drop bit into account @@ -1073,7 +1074,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, } _ { cx.sess().unimpl(~"type in iter_structural_ty"); } } - ret cx; + return cx; } fn lazily_emit_all_tydesc_glue(ccx: @crate_ctxt, @@ -1154,7 +1155,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, field: uint, static_ti: option<@tydesc_info>) { let _icx = cx.insn_ctxt(~"call_tydesc_glue_full"); - if cx.unreachable { ret; } + if cx.unreachable { return; } let mut static_glue_fn = none; alt static_ti { @@ -1196,7 +1197,7 @@ fn call_tydesc_glue(++cx: block, v: ValueRef, t: ty::t, field: uint) let _icx = cx.insn_ctxt(~"call_tydesc_glue"); let ti = get_tydesc(cx.ccx(), t); call_tydesc_glue_full(cx, v, ti.tydesc, field, some(ti)); - ret cx; + return cx; } fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, @@ -1217,23 +1218,23 @@ fn call_cmp_glue(bcx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, let llcmpresultptr = alloca(bcx, T_i1()); Call(bcx, llfn, ~[llcmpresultptr, lltydesc, llrawlhsptr, llrawrhsptr, llop]); - ret Load(bcx, llcmpresultptr); + return Load(bcx, llcmpresultptr); } fn take_ty(cx: block, v: ValueRef, t: ty::t) -> block { let _icx = cx.insn_ctxt(~"take_ty"); if ty::type_needs_drop(cx.tcx(), t) { - ret call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue); + return call_tydesc_glue(cx, v, t, abi::tydesc_field_take_glue); } - ret cx; + return cx; } fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { let _icx = cx.insn_ctxt(~"drop_ty"); if ty::type_needs_drop(cx.tcx(), t) { - ret call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue); + return call_tydesc_glue(cx, v, t, abi::tydesc_field_drop_glue); } - ret cx; + return cx; } fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { @@ -1276,9 +1277,9 @@ fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block { let _icx = cx.insn_ctxt(~"free_ty"); if ty::type_needs_drop(cx.tcx(), t) { - ret call_tydesc_glue(cx, v, t, abi::tydesc_field_free_glue); + return call_tydesc_glue(cx, v, t, abi::tydesc_field_free_glue); } - ret cx; + return cx; } fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, @@ -1317,10 +1318,10 @@ 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) { ret true; } + if ty::type_is_structural(t) { return true; } alt ty::get(t).struct { - ty::ty_param(*) { ret true; } - _ { ret false; } + ty::ty_param(*) { return true; } + _ { return false; } } } @@ -1348,18 +1349,18 @@ fn copy_val_no_check(bcx: block, action: copy_action, dst: ValueRef, let mut bcx = bcx; if ty::type_is_scalar(t) { Store(bcx, src, dst); - ret bcx; + return bcx; } - if ty::type_is_nil(t) || ty::type_is_bot(t) { ret bcx; } + if ty::type_is_nil(t) || ty::type_is_bot(t) { return bcx; } if ty::type_is_boxed(t) || ty::type_is_unique(t) { if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); } Store(bcx, src, dst); - ret take_ty(bcx, dst, t); + return take_ty(bcx, dst, t); } if type_is_structural_or_param(t) { if action == DROP_EXISTING { bcx = drop_ty(bcx, dst, t); } memmove_ty(bcx, dst, src, t); - ret take_ty(bcx, dst, t); + return take_ty(bcx, dst, t); } ccx.sess.bug(~"unexpected type in trans::copy_val_no_check: " + ppaux::ty_to_str(ccx.tcx, t)); @@ -1381,24 +1382,24 @@ fn move_val(cx: block, action: copy_action, dst: ValueRef, if ty::type_is_scalar(t) { if src.kind == lv_owned { src_val = Load(cx, src_val); } Store(cx, src_val, dst); - ret cx; + return cx; } else if ty::type_is_nil(t) || ty::type_is_bot(t) { - ret cx; + return cx; } else if ty::type_is_boxed(t) || ty::type_is_unique(t) { if src.kind == lv_owned { src_val = Load(cx, src_val); } if action == DROP_EXISTING { cx = drop_ty(cx, dst, t); } Store(cx, src_val, dst); - if src.kind == lv_owned { ret zero_mem(cx, src.val, t); } + if src.kind == lv_owned { return zero_mem(cx, src.val, t); } // If we're here, it must be a temporary. revoke_clean(cx, src_val); - ret cx; + return cx; } else if type_is_structural_or_param(t) { if action == DROP_EXISTING { cx = drop_ty(cx, dst, t); } memmove_ty(cx, dst, src_val, t); - if src.kind == lv_owned { ret zero_mem(cx, src_val, t); } + if src.kind == lv_owned { return zero_mem(cx, src_val, t); } // If we're here, it must be a temporary. revoke_clean(cx, src_val); - ret cx; + return cx; } cx.sess().bug(~"unexpected type in trans::move_val: " + ppaux::ty_to_str(tcx, t)); @@ -1415,14 +1416,14 @@ fn store_temp_expr(cx: block, action: copy_action, dst: ValueRef, } else { src.val }; - ret copy_val(cx, action, dst, v, t); + return copy_val(cx, action, dst, v, t); } - ret move_val(cx, action, dst, src, t); + return move_val(cx, action, dst, src, t); } fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block { let _icx = cx.insn_ctxt(~"trans_lit"); - if dest == ignore { ret cx; } + if dest == ignore { return cx; } alt lit.node { ast::lit_str(s) { tvec::trans_estr(cx, s, ast::vstore_fixed(none), dest) } @@ -1440,7 +1441,7 @@ fn trans_boxed_expr(bcx: block, contents: @ast::expr, add_clean_free(bcx, box, heap); let bcx = trans_expr_save_in(bcx, contents, body); revoke_clean(bcx, box); - ret store_in_dest(bcx, box, dest); + return store_in_dest(bcx, box, dest); } fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, @@ -1450,7 +1451,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, alt bcx.ccx().maps.method_map.find(un_expr.id) { some(mentry) { let fty = node_id_type(bcx, un_expr.callee_id); - ret trans_call_inner( + return trans_call_inner( bcx, un_expr.info(), fty, expr_ty(bcx, un_expr), |bcx| impl::trans_method_callee(bcx, un_expr.callee_id, e, @@ -1460,7 +1461,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, _ {} } - if dest == ignore { ret trans_expr(bcx, e, ignore); } + if dest == ignore { return trans_expr(bcx, e, ignore); } let e_ty = expr_ty(bcx, e); alt op { ast::not { @@ -1496,7 +1497,7 @@ fn trans_addr_of(cx: block, e: @ast::expr, dest: dest) -> block { if (kind == lv_temporary && is_immediate) || kind == lv_owned_imm { val = do_spill(bcx, val, ety); } - ret store_in_dest(bcx, val, dest); + return store_in_dest(bcx, val, dest); } fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, @@ -1504,7 +1505,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, let _icx = cx.insn_ctxt(~"trans_compare"); if ty::type_is_scalar(rhs_t) { let rs = compare_scalar_types(cx, lhs, rhs, rhs_t, op); - ret rslt(rs.bcx, rs.val); + return rslt(rs.bcx, rs.val); } // Determine the operation we need. @@ -1598,7 +1599,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, -> block { let mut cx = cx; let _icx = cx.insn_ctxt(~"trans_eager_binop"); - if dest == ignore { ret cx; } + if dest == ignore { return cx; } let intype = { if ty::type_is_bot(lhs_t) { rhs_t } else { lhs_t } @@ -1662,7 +1663,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, cmpr.val } }; - ret store_in_dest(cx, val, dest); + return store_in_dest(cx, val, dest); } fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, @@ -1694,7 +1695,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, }, arg_exprs(~[src]), save_in(target)); - ret move_val(bcx, DROP_EXISTING, lhs_res.val, + return move_val(bcx, DROP_EXISTING, lhs_res.val, {bcx: bcx, val: target, kind: lv_owned}, dty); } @@ -1702,7 +1703,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, } let {bcx, val: rhs_val} = trans_temp_expr(lhs_res.bcx, src); - ret trans_eager_binop(bcx, ex.span, + return trans_eager_binop(bcx, ex.span, op, Load(bcx, lhs_res.val), t, rhs_val, t, save_in(lhs_res.val)); } @@ -1784,7 +1785,7 @@ fn autoderef(cx: block, e_id: ast::node_id, // we should have, or we asked to deref as many times as we can assert derefs == max || max == uint::max_value; - ret {bcx: cx, val: v1, ty: t1}; + return {bcx: cx, val: v1, ty: t1}; } // refinement types would obviate the need for this @@ -1798,7 +1799,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, trans_temp_expr(bcx, a) } }; - if past_lhs.unreachable { ret past_lhs; } + if past_lhs.unreachable { return past_lhs; } let join = sub_block(bcx, ~"join"), before_rhs = sub_block(bcx, ~"rhs"); alt op { @@ -1811,11 +1812,11 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, } }; - if past_rhs.unreachable { ret store_in_dest(join, lhs, dest); } + if past_rhs.unreachable { return store_in_dest(join, lhs, dest); } Br(past_rhs, join.llbb); let phi = Phi(join, T_bool(), ~[lhs, rhs], ~[past_lhs.llbb, past_rhs.llbb]); - ret store_in_dest(join, phi, dest); + return store_in_dest(join, phi, dest); } fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, @@ -1825,7 +1826,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, alt bcx.ccx().maps.method_map.find(ex.id) { some(origin) { let fty = node_id_type(bcx, ex.callee_id); - ret trans_call_inner( + return trans_call_inner( bcx, ex.info(), fty, expr_ty(bcx, ex), |bcx| { @@ -1839,16 +1840,16 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, // First couple cases are lazy: alt op { ast::and { - ret trans_lazy_binop(bcx, lazy_and, lhs, rhs, dest); + return trans_lazy_binop(bcx, lazy_and, lhs, rhs, dest); } ast::or { - ret trans_lazy_binop(bcx, lazy_or, lhs, rhs, dest); + return trans_lazy_binop(bcx, lazy_or, lhs, rhs, dest); } _ { // Remaining cases are eager: let lhs_res = trans_temp_expr(bcx, lhs); let rhs_res = trans_temp_expr(lhs_res.bcx, rhs); - ret trans_eager_binop(rhs_res.bcx, ex.span, + return trans_eager_binop(rhs_res.bcx, ex.span, op, lhs_res.val, expr_ty(bcx, lhs), rhs_res.val, expr_ty(bcx, rhs), dest); @@ -1890,7 +1891,7 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, _ { else_cx } }; let else_bcx = trans_block_cleanups(else_bcx, else_cx); - ret join_returns(cx, + return join_returns(cx, ~[then_bcx, else_bcx], ~[then_dest, else_dest], dest); } @@ -1908,7 +1909,7 @@ fn trans_while(cx: block, cond: @ast::expr, body: ast::blk) CondBr(cond_bcx, cond_res.val, body_cx.llbb, next_cx.llbb); let body_end = trans_block(body_cx, body, ignore); cleanup_and_Br(body_end, body_cx, cond_cx.llbb); - ret next_cx; + return next_cx; } fn trans_loop(cx:block, body: ast::blk) -> block { @@ -1918,7 +1919,7 @@ fn trans_loop(cx:block, body: ast::blk) -> block { let body_end = trans_block(body_cx, body, ignore); cleanup_and_Br(body_end, body_cx, body_cx.llbb); Br(cx, body_cx.llbb); - ret next_cx; + return next_cx; } enum lval_kind { @@ -1943,19 +1944,19 @@ fn null_env_ptr(bcx: block) -> ValueRef { } fn lval_from_local_var(bcx: block, r: local_var_result) -> lval_result { - ret { bcx: bcx, val: r.val, kind: r.kind }; + return { bcx: bcx, val: r.val, kind: r.kind }; } fn lval_owned(bcx: block, val: ValueRef) -> lval_result { - ret {bcx: bcx, val: val, kind: lv_owned}; + return {bcx: bcx, val: val, kind: lv_owned}; } fn lval_temp(bcx: block, val: ValueRef) -> lval_result { - ret {bcx: bcx, val: val, kind: lv_temporary}; + return {bcx: bcx, val: val, kind: lv_temporary}; } fn lval_no_env(bcx: block, val: ValueRef, kind: lval_kind) -> lval_maybe_callee { - ret {bcx: bcx, val: val, kind: kind, env: is_closure}; + return {bcx: bcx, val: val, kind: kind, env: is_closure}; } fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) @@ -1964,12 +1965,12 @@ fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) alt ty::get(t).struct { ty::ty_fn(_) { let llty = type_of_fn_from_ty(ccx, t); - ret get_extern_fn(ccx.externs, ccx.llmod, name, + return get_extern_fn(ccx.externs, ccx.llmod, name, lib::llvm::CCallConv, llty); } _ { let llty = type_of(ccx, t); - ret get_extern_const(ccx.externs, ccx.llmod, name, llty); + return get_extern_const(ccx.externs, ccx.llmod, name, llty); } }; } @@ -2084,7 +2085,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, some(val) { debug!{"leaving monomorphic fn %s", ty::item_path_str(ccx.tcx, fn_id)}; - ret {val: val, must_cast: must_cast}; + return {val: val, must_cast: must_cast}; } none {} } @@ -2105,7 +2106,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, { (pt, i.ident, i.span) } ast_map::node_foreign_item(_, abi, _) { // Foreign externs don't have to be monomorphized. - ret {val: get_item_val(ccx, fn_id.node), + return {val: get_item_val(ccx, fn_id.node), must_cast: true}; } ast_map::node_ctor(nm, _, ct, _, pt) { (pt, nm, ct.span) } @@ -2330,7 +2331,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, val = PointerCast(bcx, val, T_ptr(type_of_fn_from_ty( ccx, node_id_type(bcx, id)))); } - ret {bcx: bcx, val: val, kind: lv_owned, env: null_env}; + return {bcx: bcx, val: val, kind: lv_owned, env: null_env}; } let mut val = if fn_id.crate == ast::local_crate { @@ -2351,7 +2352,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, ast::extern_fn { // Extern functions are just opaque pointers let val = PointerCast(bcx, val, T_ptr(T_i8())); - ret lval_no_env(bcx, val, lv_owned_imm); + return lval_no_env(bcx, val, lv_owned_imm); } _ { /* fall through */ } } @@ -2359,7 +2360,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, _ { /* fall through */ } } - ret {bcx: bcx, val: val, kind: lv_owned, env: null_env}; + return {bcx: bcx, val: val, kind: lv_owned, env: null_env}; } fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { @@ -2375,9 +2376,9 @@ fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { lib::llvm::SetLinkage(gvar, lib::llvm::ExternalLinkage); llvm::LLVMSetGlobalConstant(gvar, True); ccx.discrims.insert(vid, gvar); - ret gvar; + return gvar; } - some(llval) { ret llval; } + some(llval) { return llval; } } } @@ -2398,15 +2399,15 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { alt def { ast::def_upvar(nid, _, _) { assert (cx.fcx.llupvars.contains_key(nid)); - ret { val: cx.fcx.llupvars.get(nid), kind: lv_owned }; + return { val: cx.fcx.llupvars.get(nid), kind: lv_owned }; } ast::def_arg(nid, _) { assert (cx.fcx.llargs.contains_key(nid)); - ret take_local(cx.fcx.llargs, nid); + return take_local(cx.fcx.llargs, nid); } ast::def_local(nid, _) | ast::def_binding(nid) { assert (cx.fcx.lllocals.contains_key(nid)); - ret take_local(cx.fcx.lllocals, nid); + return take_local(cx.fcx.lllocals, nid); } ast::def_self(sid) { let slf = alt copy cx.fcx.llself { @@ -2414,7 +2415,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { none { cx.sess().bug(~"trans_local_var: reference to self \ out of context"); } }; - ret {val: slf, kind: lv_owned}; + return {val: slf, kind: lv_owned}; } _ { cx.sess().unimpl(fmt!{"unsupported def type in trans_local_def: %?", @@ -2429,7 +2430,7 @@ fn trans_path(cx: block, id: ast::node_id) alt cx.tcx().def_map.find(id) { none { cx.sess().bug(~"trans_path: unbound node ID"); } some(df) { - ret trans_var(cx, df, id); + return trans_var(cx, df, id); } } } @@ -2439,12 +2440,12 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { let ccx = cx.ccx(); alt def { ast::def_fn(did, _) { - ret lval_static_fn(cx, did, id); + return lval_static_fn(cx, did, id); } ast::def_variant(tid, vid) { if ty::enum_variant_with_id(ccx.tcx, tid, vid).args.len() > 0u { // N-ary variant. - ret lval_static_fn(cx, vid, id); + return lval_static_fn(cx, vid, id); } else { // Nullary variant. let enum_ty = node_id_type(cx, id); @@ -2453,22 +2454,22 @@ fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { let lldiscrim_gv = lookup_discriminant(ccx, vid); let lldiscrim = Load(cx, lldiscrim_gv); Store(cx, lldiscrim, lldiscrimptr); - ret lval_no_env(cx, llenumptr, lv_temporary); + return lval_no_env(cx, llenumptr, lv_temporary); } } ast::def_const(did) { if did.crate == ast::local_crate { - ret lval_no_env(cx, get_item_val(ccx, did.node), lv_owned); + return lval_no_env(cx, get_item_val(ccx, did.node), lv_owned); } else { let tp = node_id_type(cx, id); let val = trans_external_path(ccx, did, tp); - ret lval_no_env(cx, load_if_immediate(cx, val, tp), + return lval_no_env(cx, load_if_immediate(cx, val, tp), lv_owned_imm); } } _ { let loc = trans_local_var(cx, def); - ret lval_no_env(cx, loc.val, loc.kind); + return lval_no_env(cx, loc.val, loc.kind); } } } @@ -2514,7 +2515,7 @@ fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, } else { GEPi(bcx, val, ~[0u, ix]) }; - ret {bcx: bcx, val: val, kind: lv_owned}; + return {bcx: bcx, val: val, kind: lv_owned}; } @@ -2564,7 +2565,7 @@ fn trans_index(cx: block, ex: @ast::expr, base: @ast::expr, trans_fail(bcx, some(ex.span), ~"bounds check") }; let elt = InBoundsGEP(bcx, base, ~[ix_val]); - ret lval_owned(bcx, PointerCast(bcx, elt, T_ptr(llunitty))); + return lval_owned(bcx, PointerCast(bcx, elt, T_ptr(llunitty))); } fn expr_is_borrowed(bcx: block, e: @ast::expr) -> bool { @@ -2579,13 +2580,13 @@ 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 { - ast::expr_path(path) { ret trans_path(bcx, e.id); } + 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) { some(origin) { // An impl method - ret impl::trans_method_callee(bcx, e.id, base, origin); + return impl::trans_method_callee(bcx, e.id, base, origin); } _ { bcx.ccx().sess.span_bug(e.span, ~"trans_callee: weird expr"); @@ -2596,7 +2597,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { _ {} } let lv = trans_temp_lval(bcx, e); - ret lval_no_env(lv.bcx, lv.val, lv.kind); + return lval_no_env(lv.bcx, lv.val, lv.kind); } // Use this when you know you are compiling an lval. @@ -2604,7 +2605,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 { - ret alt cx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { + return alt cx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { // No need to root this lvalue. none { unrooted(cx, e) } @@ -2632,13 +2633,13 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { alt e.node { ast::expr_path(_) { let v = trans_path(cx, e.id); - ret lval_maybe_callee_to_lval(v, e.span); + return lval_maybe_callee_to_lval(v, e.span); } ast::expr_field(base, ident, _) { - ret trans_rec_field(cx, base, ident); + return trans_rec_field(cx, base, ident); } ast::expr_index(base, idx) { - ret trans_index(cx, e, base, idx); + return trans_index(cx, e, base, idx); } ast::expr_unary(ast::deref, base) { let ccx = cx.ccx(); @@ -2660,7 +2661,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { } ty::ty_ptr(_) | ty::ty_rptr(_,_) { sub.val } }; - ret lval_owned(sub.bcx, val); + return lval_owned(sub.bcx, val); } _ { cx.sess().span_bug(e.span, ~"non-lval in trans_lval"); } } @@ -2703,7 +2704,7 @@ fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, let _icx = bcx.insn_ctxt(~"int_cast"); let srcsz = llvm::LLVMGetIntTypeWidth(llsrctype); let dstsz = llvm::LLVMGetIntTypeWidth(lldsttype); - ret if dstsz == srcsz { + return if dstsz == srcsz { BitCast(bcx, llsrc, lldsttype) } else if srcsz > dstsz { TruncOrBitCast(bcx, llsrc, lldsttype) @@ -2717,7 +2718,7 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, let _icx = bcx.insn_ctxt(~"float_cast"); let srcsz = lib::llvm::float_width(llsrctype); let dstsz = lib::llvm::float_width(lldsttype); - ret if dstsz > srcsz { + return if dstsz > srcsz { FPExt(bcx, llsrc, lldsttype) } else if srcsz > dstsz { FPTrunc(bcx, llsrc, lldsttype) @@ -2746,7 +2747,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let ccx = cx.ccx(); let t_out = node_id_type(cx, id); alt ty::get(t_out).struct { - ty::ty_trait(_, _) { ret impl::trans_cast(cx, e, id, dest); } + ty::ty_trait(_, _) { return impl::trans_cast(cx, e, id, dest); } _ {} } let e_res = trans_temp_expr(cx, e); @@ -2801,7 +2802,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, } _ { ccx.sess.bug(~"translating unsupported cast.") } }; - ret store_in_dest(e_res.bcx, newval, dest); + return store_in_dest(e_res.bcx, newval, dest); } fn trans_loop_body(bcx: block, e: @ast::expr, ret_flag: option<ValueRef>, @@ -2923,7 +2924,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, } debug!{"--- trans_arg_expr passing %s", val_str(bcx.ccx().tn, val)}; - ret rslt(bcx, val); + return rslt(bcx, val); } // when invoking a method, an argument of type @T or ~T can be implicltly @@ -2939,7 +2940,7 @@ fn adapt_borrowed_value(lv: lval_result, ty: ty::t} { let bcx = lv.bcx; if !expr_is_borrowed(bcx, e) { - ret {lv:lv, ty:e_ty}; + return {lv:lv, ty:e_ty}; } alt ty::get(e_ty).struct { @@ -2947,7 +2948,7 @@ fn adapt_borrowed_value(lv: lval_result, let box_ptr = load_value_from_lval_result(lv, e_ty); let body_ptr = GEPi(bcx, box_ptr, ~[0u, abi::box_field_body]); let rptr_ty = ty::mk_rptr(bcx.tcx(), ty::re_static, mt); - ret {lv: lval_temp(bcx, body_ptr), ty: rptr_ty}; + return {lv: lval_temp(bcx, body_ptr), ty: rptr_ty}; } ty::ty_estr(_) | ty::ty_evec(_, _) { @@ -2977,7 +2978,7 @@ fn adapt_borrowed_value(lv: lval_result, {ty: unit_ty, mutbl: ast::m_imm}, ty::vstore_slice(ty::re_static)); - ret {lv: lval_temp(bcx, p), ty: slice_ty}; + return {lv: lval_temp(bcx, p), ty: slice_ty}; } _ { @@ -3056,7 +3057,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, revoke_clean(bcx, c) } - ret {bcx: bcx, + return {bcx: bcx, args: llargs, retslot: llretslot}; } @@ -3180,31 +3181,31 @@ fn trans_call_inner( fn invoke(bcx: block, llfn: ValueRef, llargs: ~[ValueRef]) -> block { let _icx = bcx.insn_ctxt(~"invoke_"); - if bcx.unreachable { ret bcx; } + if bcx.unreachable { return bcx; } if need_invoke(bcx) { log(debug, ~"invoking"); let normal_bcx = sub_block(bcx, ~"normal return"); Invoke(bcx, llfn, llargs, normal_bcx.llbb, get_landing_pad(bcx)); - ret normal_bcx; + return normal_bcx; } else { log(debug, ~"calling"); Call(bcx, llfn, llargs); - ret bcx; + return bcx; } } fn need_invoke(bcx: block) -> bool { if (bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0) { - ret false; + return false; } // Avoid using invoke if we are already inside a landing pad. if bcx.is_lpad { - ret false; + return false; } if have_cached_lpad(bcx) { - ret true; + return true; } // Walk the scopes to look for cleanups @@ -3216,7 +3217,7 @@ fn need_invoke(bcx: block) -> bool { alt cleanup { clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) { if cleanup_type == normal_exit_and_unwind { - ret true; + return true; } } } @@ -3226,7 +3227,7 @@ fn need_invoke(bcx: block) -> bool { } cur = alt cur.parent { some(next) { next } - none { ret false; } + none { return false; } } } } @@ -3239,7 +3240,7 @@ fn have_cached_lpad(bcx: block) -> bool { none { res = false; } } } - ret res; + return res; } fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) { @@ -3248,7 +3249,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) { alt bcx.kind { block_scope(inf) { if inf.cleanups.len() > 0u || is_none(bcx.parent) { - f(inf); ret; + f(inf); return; } } _ {} @@ -3271,7 +3272,8 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { } } } - alt cached { some(b) { ret b; } none {} } // Can't return from block above + // Can't return from block above + alt 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 +3305,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { // Unwind all parent scopes, and finish with a Resume instr cleanup_and_leave(pad_bcx, none, none); - ret pad_bcx.llbb; + return pad_bcx.llbb; } fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { @@ -3312,7 +3314,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { let addr = alt dest { ignore { for vec::each(elts) |ex| { bcx = trans_expr(bcx, ex, ignore); } - ret bcx; + return bcx; } save_in(pos) { pos } _ { bcx.tcx().sess.bug(~"trans_tup: weird dest"); } @@ -3326,7 +3328,7 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { vec::push(temp_cleanups, dst); } for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); } - ret bcx; + return bcx; } fn trans_rec(bcx: block, fields: ~[ast::field], @@ -3340,7 +3342,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], for vec::each(fields) |fld| { bcx = trans_expr(bcx, fld.node.expr, ignore); } - ret bcx; + return bcx; } save_in(pos) { pos } }; @@ -3377,7 +3379,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], // Now revoke the cleanups as we pass responsibility for the data // structure on to the caller for temp_cleanups.each |cleanup| { revoke_clean(bcx, cleanup); } - ret bcx; + return bcx; } fn trans_struct(block_context: block, span: span, fields: ~[ast::field], @@ -3399,7 +3401,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], field.node.expr, ignore); } - ret block_context; + return block_context; } save_in(destination_address) => { dest_address = destination_address; @@ -3470,7 +3472,7 @@ fn trans_expr_save_in(bcx: block, e: @ast::expr, dest: ValueRef) -> block { let t = expr_ty(bcx, e); let do_ignore = ty::type_is_bot(t) || ty::type_is_nil(t); - ret trans_expr(bcx, e, if do_ignore { ignore } else { save_in(dest) }); + return trans_expr(bcx, e, if do_ignore { ignore } else { save_in(dest) }); } // Call this to compile an expression that you need as an intermediate value, @@ -3482,22 +3484,22 @@ fn trans_temp_lval(bcx: block, e: @ast::expr) -> lval_result { let _icx = bcx.insn_ctxt(~"trans_temp_lval"); let mut bcx = bcx; if expr_is_lval(bcx, e) { - ret trans_lval(bcx, e); + return trans_lval(bcx, e); } else { let ty = expr_ty(bcx, e); if ty::type_is_nil(ty) || ty::type_is_bot(ty) { bcx = trans_expr(bcx, e, ignore); - ret {bcx: bcx, val: C_nil(), kind: lv_temporary}; + return {bcx: bcx, val: C_nil(), kind: lv_temporary}; } else if ty::type_is_immediate(ty) { let cell = empty_dest_cell(); bcx = trans_expr(bcx, e, by_val(cell)); add_clean_temp(bcx, *cell, ty); - ret {bcx: bcx, val: *cell, kind: lv_temporary}; + return {bcx: bcx, val: *cell, kind: lv_temporary}; } else { let scratch = alloc_ty(bcx, ty); let bcx = trans_expr_save_in(bcx, e, scratch); add_clean_temp(bcx, scratch, ty); - ret {bcx: bcx, val: scratch, kind: lv_temporary}; + return {bcx: bcx, val: scratch, kind: lv_temporary}; } } } @@ -3546,7 +3548,7 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id, let mut bcx_sid = bcx; loop { bcx_sid = alt bcx_sid.node_info { - some({id, _}) if id == scope_id { ret bcx_sid; } + some({id, _}) if id == scope_id { return bcx_sid; } _ { alt bcx_sid.parent { none { @@ -3570,10 +3572,10 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { debuginfo::update_source_pos(bcx, e.span); if expr_is_lval(bcx, e) { - ret lval_to_dps(bcx, e, dest); + return lval_to_dps(bcx, e, dest); } - ret alt bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { + return alt 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", @@ -3599,39 +3601,41 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { let tcx = bcx.tcx(); alt e.node { ast::expr_if(cond, thn, els) { - ret trans_if(bcx, cond, thn, els, dest); + return trans_if(bcx, cond, thn, els, dest); } ast::expr_alt(expr, arms, mode) { - ret alt::trans_alt(bcx, e, expr, arms, mode, dest); + return alt::trans_alt(bcx, e, expr, arms, mode, dest); } ast::expr_block(blk) { - ret do with_scope(bcx, blk.info(), ~"block-expr body") |bcx| { + return do with_scope(bcx, blk.info(), ~"block-expr body") |bcx| { trans_block(bcx, blk, dest) }; } ast::expr_rec(args, base) { - ret trans_rec(bcx, args, base, e.id, dest); + return trans_rec(bcx, args, base, e.id, dest); } ast::expr_struct(_, fields) { - ret trans_struct(bcx, e.span, fields, e.id, dest); + return trans_struct(bcx, e.span, fields, e.id, dest); } - ast::expr_tup(args) { ret trans_tup(bcx, args, dest); } - ast::expr_vstore(e, v) { ret tvec::trans_vstore(bcx, e, v, dest); } - ast::expr_lit(lit) { ret trans_lit(bcx, e, *lit, dest); } + ast::expr_tup(args) { return trans_tup(bcx, args, dest); } + ast::expr_vstore(e, v) { + return tvec::trans_vstore(bcx, e, v, dest); + } + ast::expr_lit(lit) { return trans_lit(bcx, e, *lit, dest); } ast::expr_vec(args, _) { - ret tvec::trans_evec(bcx, args, ast::vstore_fixed(none), + return tvec::trans_evec(bcx, args, ast::vstore_fixed(none), e.id, dest); } ast::expr_binary(op, lhs, rhs) { - ret trans_binary(bcx, op, lhs, rhs, dest, e); + return trans_binary(bcx, op, lhs, rhs, dest, e); } ast::expr_unary(op, x) { assert op != ast::deref; // lvals are handled above - ret trans_unary(bcx, op, x, e, dest); + return trans_unary(bcx, op, x, e, dest); } - ast::expr_addr_of(_, x) { ret trans_addr_of(bcx, x, dest); } + ast::expr_addr_of(_, x) { return trans_addr_of(bcx, x, dest); } ast::expr_fn(proto, decl, body, cap_clause) { - ret closure::trans_expr_fn(bcx, proto, decl, body, e.id, + return closure::trans_expr_fn(bcx, proto, decl, body, e.id, cap_clause, none, dest); } ast::expr_fn_block(decl, body, cap_clause) { @@ -3640,41 +3644,41 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { debug!{"translating fn_block %s with type %s", expr_to_str(e), ppaux::ty_to_str(tcx, expr_ty(bcx, e))}; - ret closure::trans_expr_fn(bcx, proto, decl, body, + return closure::trans_expr_fn(bcx, proto, decl, body, e.id, cap_clause, none, dest); } } } ast::expr_loop_body(blk) { - ret trans_loop_body(bcx, e, none, dest); + return trans_loop_body(bcx, e, none, dest); } ast::expr_do_body(blk) { - ret trans_expr(bcx, blk, dest); + return trans_expr(bcx, blk, dest); } ast::expr_copy(a) | ast::expr_unary_move(a) { if !expr_is_lval(bcx, a) { - ret trans_expr(bcx, a, dest); + return trans_expr(bcx, a, dest); } - else { ret lval_to_dps(bcx, a, dest); } + else { return lval_to_dps(bcx, a, dest); } } - ast::expr_cast(val, _) { ret trans_cast(bcx, val, e.id, dest); } + ast::expr_cast(val, _) { return trans_cast(bcx, val, e.id, dest); } ast::expr_call(f, args, _) { - ret trans_call(bcx, e, f, arg_exprs(args), e.id, dest); + return trans_call(bcx, e, f, arg_exprs(args), e.id, dest); } ast::expr_field(base, _, _) { - if dest == ignore { ret trans_expr(bcx, base, ignore); } + if dest == ignore { return trans_expr(bcx, base, ignore); } let callee = trans_callee(bcx, e), ty = expr_ty(bcx, e); let lv = lval_maybe_callee_to_lval(callee, e.span); revoke_clean(lv.bcx, lv.val); memmove_ty(lv.bcx, get_dest_addr(dest), lv.val, ty); - ret lv.bcx; + return lv.bcx; } ast::expr_index(base, idx) { // If it is here, it's not an lval, so this is a user-defined // index op let origin = bcx.ccx().maps.method_map.get(e.id); let fty = node_id_type(bcx, e.callee_id); - ret trans_call_inner( + return trans_call_inner( bcx, e.info(), fty, expr_ty(bcx, e), |bcx| impl::trans_method_callee(bcx, e.callee_id, base, @@ -3685,35 +3689,35 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { // These return nothing ast::expr_break { assert dest == ignore; - ret trans_break(bcx); + return trans_break(bcx); } ast::expr_again { assert dest == ignore; - ret trans_cont(bcx); + return trans_cont(bcx); } ast::expr_ret(ex) { assert dest == ignore; - ret trans_ret(bcx, ex); + return trans_ret(bcx, ex); } ast::expr_fail(expr) { assert dest == ignore; - ret trans_fail_expr(bcx, some(e.span), expr); + return trans_fail_expr(bcx, some(e.span), expr); } ast::expr_log(_, lvl, a) { assert dest == ignore; - ret trans_log(e, lvl, bcx, a); + return trans_log(e, lvl, bcx, a); } ast::expr_assert(a) { assert dest == ignore; - ret trans_check_expr(bcx, e, a, ~"Assertion"); + return trans_check_expr(bcx, e, a, ~"Assertion"); } ast::expr_while(cond, body) { assert dest == ignore; - ret trans_while(bcx, cond, body); + return trans_while(bcx, cond, body); } ast::expr_loop(body) { assert dest == ignore; - ret trans_loop(bcx, body); + return trans_loop(bcx, body); } ast::expr_assign(dst, src) { assert dest == ignore; @@ -3722,7 +3726,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { assert kind == lv_owned; let is_last_use = bcx.ccx().maps.last_use_map.contains_key(src.id); - ret store_temp_expr(bcx, DROP_EXISTING, addr, src_r, + return store_temp_expr(bcx, DROP_EXISTING, addr, src_r, expr_ty(bcx, src), is_last_use); } ast::expr_move(dst, src) { @@ -3731,7 +3735,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { let src_r = trans_temp_lval(bcx, src); let {bcx, val: addr, kind} = trans_lval(src_r.bcx, dst); assert kind == lv_owned; - ret move_val(bcx, DROP_EXISTING, addr, src_r, + return move_val(bcx, DROP_EXISTING, addr, src_r, expr_ty(bcx, src)); } ast::expr_swap(dst, src) { @@ -3744,12 +3748,12 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { // Swap through a temporary. let bcx = move_val(rhs_res.bcx, INIT, tmp_alloc, lhs_res, t); let bcx = move_val(bcx, INIT, lhs_res.val, rhs_res, t); - ret move_val(bcx, INIT, rhs_res.val, + return move_val(bcx, INIT, rhs_res.val, lval_owned(bcx, tmp_alloc), t); } ast::expr_assign_op(op, dst, src) { assert dest == ignore; - ret trans_assign_op(bcx, e, op, dst, src); + return trans_assign_op(bcx, e, op, dst, src); } ast::expr_new(pool, alloc_id, val) { // First, call pool->alloc(tydesc) to get back a void*. @@ -3832,16 +3836,16 @@ fn lval_result_to_dps(lv: lval_result, ty: ty::t, } ignore {} } - ret bcx; + return bcx; } fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef { if ty::type_is_bot(t) { - ret C_null(T_ptr(T_i8())); + return C_null(T_ptr(T_i8())); } let llptr = alloc_ty(bcx, t); Store(bcx, v, llptr); - ret llptr; + return llptr; } // Since this function does *not* root, it is the caller's responsibility to @@ -3852,19 +3856,19 @@ fn do_spill(bcx: block, v: ValueRef, t: ty::t) -> ValueRef { fn do_spill_noroot(++cx: block, v: ValueRef) -> ValueRef { let llptr = alloca(cx, val_ty(v)); Store(cx, v, llptr); - ret llptr; + return llptr; } fn spill_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef { let _icx = cx.insn_ctxt(~"spill_if_immediate"); - if ty::type_is_immediate(t) { ret do_spill(cx, v, t); } - ret v; + if ty::type_is_immediate(t) { return do_spill(cx, v, t); } + return v; } fn load_if_immediate(cx: block, v: ValueRef, t: ty::t) -> ValueRef { let _icx = cx.insn_ctxt(~"load_if_immediate"); - if ty::type_is_immediate(t) { ret Load(cx, v); } - ret v; + if ty::type_is_immediate(t) { return Load(cx, v); } + return v; } fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, @@ -3872,7 +3876,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, let _icx = bcx.insn_ctxt(~"trans_log"); let ccx = bcx.ccx(); if ty::type_is_bot(expr_ty(bcx, lvl)) { - ret trans_expr(bcx, lvl, ignore); + return trans_expr(bcx, lvl, ignore); } let modpath = vec::append( @@ -3946,21 +3950,21 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>, if ty::type_is_str(e_ty) { let body = tvec::get_bodyptr(bcx, expr_res.val); let data = tvec::get_dataptr(bcx, body); - ret trans_fail_value(bcx, sp_opt, data); + return trans_fail_value(bcx, sp_opt, data); } else if bcx.unreachable || ty::type_is_bot(e_ty) { - ret bcx; + return bcx; } else { bcx.sess().span_bug( expr.span, ~"fail called with unsupported type " + ppaux::ty_to_str(tcx, e_ty)); } } - _ { ret trans_fail(bcx, sp_opt, ~"explicit failure"); } + _ { return trans_fail(bcx, sp_opt, ~"explicit failure"); } } } fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: ~str) { - if !bcx.sess().trace() { ret; } + if !bcx.sess().trace() { return; } let _icx = bcx.insn_ctxt(~"trans_trace"); add_comment(bcx, trace_str); let V_trace_str = C_cstr(bcx.ccx(), trace_str); @@ -3987,7 +3991,7 @@ fn trans_fail(bcx: block, sp_opt: option<span>, fail_str: ~str) -> block { let _icx = bcx.insn_ctxt(~"trans_fail"); let V_fail_str = C_cstr(bcx.ccx(), fail_str); - ret trans_fail_value(bcx, sp_opt, V_fail_str); + return trans_fail_value(bcx, sp_opt, V_fail_str); } fn trans_fail_value(bcx: block, sp_opt: option<span>, @@ -4011,7 +4015,7 @@ fn trans_fail_value(bcx: block, sp_opt: option<span>, let args = ~[V_str, V_filename, C_int(ccx, V_line)]; let bcx = trans_rtcall(bcx, ~"fail", args, ignore); Unreachable(bcx); - ret bcx; + return bcx; } fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: dest) @@ -4023,7 +4027,7 @@ fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: dest) csearch::get_type(bcx.ccx().tcx, did).ty }; let rty = ty::ty_fn_ret(fty); - ret trans_call_inner( + return trans_call_inner( bcx, none, fty, rty, |bcx| lval_static_fn_inner(bcx, did, 0, ~[], none), arg_vals(args), dest); @@ -4054,21 +4058,21 @@ fn trans_break_cont(bcx: block, to_end: bool) Store(bcx, C_bool(!to_end), bcx.fcx.llretptr); cleanup_and_leave(bcx, none, some(bcx.fcx.llreturn)); Unreachable(bcx); - ret bcx; + return bcx; } }; } cleanup_and_Br(bcx, unwind, target.llbb); Unreachable(bcx); - ret bcx; + return bcx; } fn trans_break(cx: block) -> block { - ret trans_break_cont(cx, true); + return trans_break_cont(cx, true); } fn trans_cont(cx: block) -> block { - ret trans_break_cont(cx, false); + return trans_break_cont(cx, false); } fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { @@ -4097,7 +4101,7 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { } cleanup_and_leave(bcx, none, some(bcx.fcx.llreturn)); Unreachable(bcx); - ret bcx; + return bcx; } fn build_return(bcx: block) { @@ -4130,7 +4134,7 @@ fn init_local(bcx: block, local: @ast::local) -> block { } // Make a note to drop this slot on the way out. add_clean(bcx, llptr, ty); - ret alt::bind_irrefutable_pat(bcx, local.node.pat, llptr, false); + return alt::bind_irrefutable_pat(bcx, local.node.pat, llptr, false); } fn trans_stmt(cx: block, s: ast::stmt) -> block { @@ -4163,7 +4167,7 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { } } - ret bcx; + return bcx; } // You probably don't want to use this one. See the @@ -4182,7 +4186,7 @@ fn new_block(cx: fn_ctxt, parent: option<block>, +kind: block_kind, do option::iter(parent) |cx| { if cx.unreachable { Unreachable(bcx); } }; - ret bcx; + return bcx; } fn simple_block_scope() -> block_kind { @@ -4192,20 +4196,20 @@ fn simple_block_scope() -> block_kind { // Use this when you're at the top block of a function or the like. fn top_scope_block(fcx: fn_ctxt, opt_node_info: option<node_info>) -> block { - ret new_block(fcx, none, simple_block_scope(), false, + return new_block(fcx, none, simple_block_scope(), false, ~"function top level", opt_node_info); } fn scope_block(bcx: block, opt_node_info: option<node_info>, n: ~str) -> block { - ret new_block(bcx.fcx, some(bcx), simple_block_scope(), bcx.is_lpad, + return new_block(bcx.fcx, some(bcx), simple_block_scope(), bcx.is_lpad, n, opt_node_info); } fn loop_scope_block(bcx: block, loop_break: block, n: ~str, opt_node_info: option<node_info>) -> block { - ret new_block(bcx.fcx, some(bcx), block_scope({ + return new_block(bcx.fcx, some(bcx), block_scope({ loop_break: some(loop_break), mut cleanups: ~[], mut cleanup_paths: ~[], @@ -4242,7 +4246,7 @@ fn trans_block_cleanups(bcx: block, cleanup_cx: block) -> block { fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> block { let _icx = bcx.insn_ctxt(~"trans_block_cleanups"); - if bcx.unreachable { ret bcx; } + if bcx.unreachable { return bcx; } let mut bcx = bcx; alt check cleanup_cx.kind { block_scope({cleanups, _}) { @@ -4260,7 +4264,7 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> } } } - ret bcx; + return bcx; } // In the last argument, some(block) mean jump to this block, and none means @@ -4285,7 +4289,7 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, for vec::find(inf.cleanup_paths, |cp| cp.target == leave).each |cp| { Br(bcx, cp.dest); - ret; + return; } let sub_cx = sub_block(bcx, ~"cleanup"); Br(bcx, sub_cx.llbb); @@ -4373,7 +4377,7 @@ fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { if ty::type_has_params(t) { log(error, ppaux::ty_to_str(ccx.tcx, t)); } assert !ty::type_has_params(t); let val = alloca(bcx, llty); - ret val; + return val; } fn alloc_local(cx: block, local: @ast::local) -> block { @@ -4392,7 +4396,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block { } } cx.fcx.lllocals.insert(local.node.id, local_mem(val)); - ret cx; + return cx; } fn trans_block(bcx: block, b: ast::blk, dest: dest) @@ -4412,7 +4416,7 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest) } _ { assert dest == ignore || bcx.unreachable; } } - ret bcx; + return bcx; } // Creates the standard set of basic blocks for a function @@ -4438,7 +4442,7 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path, param_substs: option<param_substs>, sp: option<span>) -> fn_ctxt { let llbbs = mk_standard_basic_blocks(llfndecl); - ret @{llfn: llfndecl, + return @{llfn: llfndecl, llenv: llvm::LLVMGetParam(llfndecl, 1u as c_uint), llretptr: llvm::LLVMGetParam(llfndecl, 0u as c_uint), mut llstaticallocas: llbbs.sa, @@ -4459,7 +4463,7 @@ fn new_fn_ctxt_w_id(ccx: @crate_ctxt, path: path, fn new_fn_ctxt(ccx: @crate_ctxt, path: path, llfndecl: ValueRef, sp: option<span>) -> fn_ctxt { - ret new_fn_ctxt_w_id(ccx, path, llfndecl, -1, none, sp); + return new_fn_ctxt_w_id(ccx, path, llfndecl, -1, none, sp); } // NB: must keep 4 fns in sync: @@ -4534,7 +4538,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], } arg_n += 1u; } - ret bcx; + return bcx; } // Ties up the llstaticallocas -> llloadenv -> lltop edges, @@ -4886,7 +4890,7 @@ fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) { fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef { // Bit of a kludge: pick the fn typeref out of the pair. - ret struct_elt(llpairty, 0u); + return struct_elt(llpairty, 0u); } fn register_fn(ccx: @crate_ctxt, sp: span, path: path, @@ -4965,14 +4969,14 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, finish_fn(fcx, lltop); - ret llfdecl; + return llfdecl; } fn create_entry_fn(ccx: @crate_ctxt, rust_main: ValueRef) { #[cfg(windows)] - fn main_name() -> ~str { ret ~"WinMain@16"; } + fn main_name() -> ~str { return ~"WinMain@16"; } #[cfg(unix)] - fn main_name() -> ~str { ret ~"main"; } + fn main_name() -> ~str { return ~"main"; } let llfty = T_fn(~[ccx.int_type, ccx.int_type], ccx.int_type); let llfn = decl_cdecl_fn(ccx.llmod, main_name(), llfty); let llbb = str::as_c_str(~"top", |buf| { @@ -5002,7 +5006,7 @@ fn create_real_fn_pair(cx: block, llfnty: TypeRef, llfn: ValueRef, llenvptr: ValueRef) -> ValueRef { let pair = alloca(cx, T_fn_pair(cx.ccx(), llfnty)); fill_fn_pair(cx, pair, llfn, llenvptr); - ret pair; + return pair; } fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef, @@ -5191,11 +5195,11 @@ fn trans_constants(ccx: @crate_ctxt, crate: @ast::crate) { fn vp2i(cx: block, v: ValueRef) -> ValueRef { let ccx = cx.ccx(); - ret PtrToInt(cx, v, ccx.int_type); + return PtrToInt(cx, v, ccx.int_type); } fn p2i(ccx: @crate_ctxt, v: ValueRef) -> ValueRef { - ret llvm::LLVMConstPtrToInt(v, ccx.int_type); + return llvm::LLVMConstPtrToInt(v, ccx.int_type); } fn declare_intrinsics(llmod: ModuleRef) -> hashmap<~str, ValueRef> { @@ -5243,7 +5247,7 @@ fn declare_intrinsics(llmod: ModuleRef) -> hashmap<~str, ValueRef> { intrinsics.insert(~"llvm.memset.p0i8.i64", memset64); intrinsics.insert(~"llvm.trap", trap); intrinsics.insert(~"llvm.frameaddress", frameaddress); - ret intrinsics; + return intrinsics; } fn declare_dbg_intrinsics(llmod: ModuleRef, @@ -5360,7 +5364,7 @@ fn create_module_map(ccx: @crate_ctxt) -> ValueRef { let term = C_struct(~[C_int(ccx, 0), C_int(ccx, 0)]); vec::push(elts, term); llvm::LLVMSetInitializer(map, C_array(elttype, elts)); - ret map; + return map; } @@ -5381,7 +5385,7 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta, llvm::LLVMAddGlobal(llmod, maptype, buf) }); lib::llvm::SetLinkage(map, lib::llvm::ExternalLinkage); - ret map; + return map; } fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) { @@ -5411,7 +5415,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) let encode_inlined_item = |a,b,c,d| astencode::encode_inlined_item(a, b, c, d, cx.maps); - ret { + return { diag: cx.sess.diagnostic(), tcx: cx.tcx, reachable: cx.reachable, @@ -5437,7 +5441,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) vec::push(reexports, (path, def.id)); } } - ret reexports; + return reexports; } fn impl_map(cx: @crate_ctxt, @@ -5446,12 +5450,12 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) for list::each(cx.maps.impl_map.get(id)) |impls| { vec::push_all(result, (*impls).map(|i| (i.ident, i.did))); } - ret result; + return result; } } fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) { - if !cx.sess.building_library { ret; } + if !cx.sess.building_library { return; } let encode_parms = crate_ctxt_to_encode_parms(cx); let llmeta = C_bytes(encoder::encode_metadata(encode_parms, crate)); let llconst = C_struct(~[llmeta]); @@ -5631,7 +5635,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt, io::println(fmt!{"%-7u %s", v, k}); } } - ret (llmod, link_meta); + return (llmod, link_meta); } // // Local Variables: diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 5fa90ecece2..d664d11d1e4 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -12,7 +12,7 @@ import driver::session::session; fn B(cx: block) -> BuilderRef { let b = cx.fcx.ccx.builder.B; llvm::LLVMPositionBuilderAtEnd(b, cx.llbb); - ret b; + return b; } fn count_insn(cx: block, category: ~str) { @@ -60,11 +60,11 @@ fn count_insn(cx: block, category: ~str) { // terminated, we're saying that trying to add any further statements in the // block is an error. On the other hand, if something is unreachable, that // means that the block was terminated in some way that we don't want to check -// for (fail/break/ret statements, call to diverging functions, etc), and +// for (fail/break/return statements, call to diverging functions, etc), and // further instructions to the block should simply be ignored. fn RetVoid(cx: block) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; count_insn(cx, ~"retvoid"); @@ -72,7 +72,7 @@ fn RetVoid(cx: block) { } fn Ret(cx: block, V: ValueRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; count_insn(cx, ~"ret"); @@ -80,7 +80,7 @@ fn Ret(cx: block, V: ValueRef) { } fn AggregateRet(cx: block, RetVals: ~[ValueRef]) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; unsafe { @@ -90,7 +90,7 @@ fn AggregateRet(cx: block, RetVals: ~[ValueRef]) { } fn Br(cx: block, Dest: BasicBlockRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; count_insn(cx, ~"br"); @@ -99,7 +99,7 @@ fn Br(cx: block, Dest: BasicBlockRef) { fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef, Else: BasicBlockRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; count_insn(cx, ~"condbr"); @@ -108,19 +108,19 @@ fn CondBr(cx: block, If: ValueRef, Then: BasicBlockRef, fn Switch(cx: block, V: ValueRef, Else: BasicBlockRef, NumCases: uint) -> ValueRef { - if cx.unreachable { ret _Undef(V); } + if cx.unreachable { return _Undef(V); } assert !cx.terminated; cx.terminated = true; - ret llvm::LLVMBuildSwitch(B(cx), V, Else, NumCases as c_uint); + return llvm::LLVMBuildSwitch(B(cx), V, Else, NumCases as c_uint); } fn AddCase(S: ValueRef, OnVal: ValueRef, Dest: BasicBlockRef) { - if llvm::LLVMIsUndef(S) == lib::llvm::True { ret; } + if llvm::LLVMIsUndef(S) == lib::llvm::True { return; } llvm::LLVMAddCase(S, OnVal, Dest); } fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; count_insn(cx, ~"indirectbr"); @@ -131,12 +131,12 @@ fn IndirectBr(cx: block, Addr: ValueRef, NumDests: uint) { // lot more efficient) than doing str::as_c_str("", ...) every time. fn noname() -> *libc::c_char unsafe { const cnull: uint = 0u; - ret unsafe::reinterpret_cast(ptr::addr_of(cnull)); + return unsafe::reinterpret_cast(ptr::addr_of(cnull)); } fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], Then: BasicBlockRef, Catch: BasicBlockRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; debug!{"Invoke(%s with arguments (%s))", @@ -153,7 +153,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], Then: BasicBlockRef, Catch: BasicBlockRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } assert (!cx.terminated); cx.terminated = true; unsafe { @@ -166,7 +166,7 @@ fn FastInvoke(cx: block, Fn: ValueRef, Args: ~[ValueRef], } fn Unreachable(cx: block) { - if cx.unreachable { ret; } + if cx.unreachable { return; } cx.unreachable = true; if !cx.terminated { count_insn(cx, ~"unreachable"); @@ -175,223 +175,223 @@ fn Unreachable(cx: block) { } fn _Undef(val: ValueRef) -> ValueRef { - ret llvm::LLVMGetUndef(val_ty(val)); + return llvm::LLVMGetUndef(val_ty(val)); } /* Arithmetic */ fn Add(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"add"); - ret llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildAdd(B(cx), LHS, RHS, noname()); } fn NSWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"nswadd"); - ret llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildNSWAdd(B(cx), LHS, RHS, noname()); } fn NUWAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"nuwadd"); - ret llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildNUWAdd(B(cx), LHS, RHS, noname()); } fn FAdd(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"fadd"); - ret llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildFAdd(B(cx), LHS, RHS, noname()); } fn Sub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"sub"); - ret llvm::LLVMBuildSub(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildSub(B(cx), LHS, RHS, noname()); } fn NSWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"nwsub"); - ret llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildNSWSub(B(cx), LHS, RHS, noname()); } fn NUWSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"nuwsub"); - ret llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildNUWSub(B(cx), LHS, RHS, noname()); } fn FSub(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"sub"); - ret llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildFSub(B(cx), LHS, RHS, noname()); } fn Mul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"mul"); - ret llvm::LLVMBuildMul(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildMul(B(cx), LHS, RHS, noname()); } fn NSWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"nswmul"); - ret llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildNSWMul(B(cx), LHS, RHS, noname()); } fn NUWMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"nuwmul"); - ret llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildNUWMul(B(cx), LHS, RHS, noname()); } fn FMul(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"fmul"); - ret llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildFMul(B(cx), LHS, RHS, noname()); } fn UDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"udiv"); - ret llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildUDiv(B(cx), LHS, RHS, noname()); } fn SDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"sdiv"); - ret llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildSDiv(B(cx), LHS, RHS, noname()); } fn ExactSDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"extractsdiv"); - ret llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildExactSDiv(B(cx), LHS, RHS, noname()); } fn FDiv(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"fdiv"); - ret llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildFDiv(B(cx), LHS, RHS, noname()); } fn URem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"urem"); - ret llvm::LLVMBuildURem(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildURem(B(cx), LHS, RHS, noname()); } fn SRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"srem"); - ret llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildSRem(B(cx), LHS, RHS, noname()); } fn FRem(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"frem"); - ret llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildFRem(B(cx), LHS, RHS, noname()); } fn Shl(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"shl"); - ret llvm::LLVMBuildShl(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildShl(B(cx), LHS, RHS, noname()); } fn LShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"lshr"); - ret llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildLShr(B(cx), LHS, RHS, noname()); } fn AShr(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"ashr"); - ret llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildAShr(B(cx), LHS, RHS, noname()); } fn And(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"and"); - ret llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildAnd(B(cx), LHS, RHS, noname()); } fn Or(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"or"); - ret llvm::LLVMBuildOr(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildOr(B(cx), LHS, RHS, noname()); } fn Xor(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"xor"); - ret llvm::LLVMBuildXor(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildXor(B(cx), LHS, RHS, noname()); } fn BinOp(cx: block, Op: Opcode, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(LHS); } + if cx.unreachable { return _Undef(LHS); } count_insn(cx, ~"binop"); - ret llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname()); + return llvm::LLVMBuildBinOp(B(cx), Op, LHS, RHS, noname()); } fn Neg(cx: block, V: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(V); } + if cx.unreachable { return _Undef(V); } count_insn(cx, ~"neg"); - ret llvm::LLVMBuildNeg(B(cx), V, noname()); + return llvm::LLVMBuildNeg(B(cx), V, noname()); } fn NSWNeg(cx: block, V: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(V); } + if cx.unreachable { return _Undef(V); } count_insn(cx, ~"nswneg"); - ret llvm::LLVMBuildNSWNeg(B(cx), V, noname()); + return llvm::LLVMBuildNSWNeg(B(cx), V, noname()); } fn NUWNeg(cx: block, V: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(V); } + if cx.unreachable { return _Undef(V); } count_insn(cx, ~"nuwneg"); - ret llvm::LLVMBuildNUWNeg(B(cx), V, noname()); + return llvm::LLVMBuildNUWNeg(B(cx), V, noname()); } fn FNeg(cx: block, V: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(V); } + if cx.unreachable { return _Undef(V); } count_insn(cx, ~"fneg"); - ret llvm::LLVMBuildFNeg(B(cx), V, noname()); + return llvm::LLVMBuildFNeg(B(cx), V, noname()); } fn Not(cx: block, V: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(V); } + if cx.unreachable { return _Undef(V); } count_insn(cx, ~"not"); - ret llvm::LLVMBuildNot(B(cx), V, noname()); + return llvm::LLVMBuildNot(B(cx), V, noname()); } /* Memory */ fn Malloc(cx: block, Ty: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } count_insn(cx, ~"malloc"); - ret llvm::LLVMBuildMalloc(B(cx), Ty, noname()); + return llvm::LLVMBuildMalloc(B(cx), Ty, noname()); } fn ArrayMalloc(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } count_insn(cx, ~"arraymalloc"); - ret llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname()); + return llvm::LLVMBuildArrayMalloc(B(cx), Ty, Val, noname()); } fn Alloca(cx: block, Ty: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); } count_insn(cx, ~"alloca"); - ret llvm::LLVMBuildAlloca(B(cx), Ty, noname()); + return llvm::LLVMBuildAlloca(B(cx), Ty, noname()); } fn ArrayAlloca(cx: block, Ty: TypeRef, Val: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(Ty)); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(Ty)); } count_insn(cx, ~"arrayalloca"); - ret llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname()); + return llvm::LLVMBuildArrayAlloca(B(cx), Ty, Val, noname()); } fn Free(cx: block, PointerVal: ValueRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } count_insn(cx, ~"free"); llvm::LLVMBuildFree(B(cx), PointerVal); } @@ -402,14 +402,14 @@ fn Load(cx: block, PointerVal: ValueRef) -> ValueRef { let ty = val_ty(PointerVal); let eltty = if llvm::LLVMGetTypeKind(ty) == lib::llvm::Array { llvm::LLVMGetElementType(ty) } else { ccx.int_type }; - ret llvm::LLVMGetUndef(eltty); + return llvm::LLVMGetUndef(eltty); } count_insn(cx, ~"load"); - ret llvm::LLVMBuildLoad(B(cx), PointerVal, noname()); + return llvm::LLVMBuildLoad(B(cx), PointerVal, noname()); } fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } debug!{"Store %s -> %s", val_str(cx.ccx().tn, Val), val_str(cx.ccx().tn, Ptr)}; @@ -418,10 +418,10 @@ fn Store(cx: block, Val: ValueRef, Ptr: ValueRef) { } fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { count_insn(cx, ~"gep"); - ret llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), + return llvm::LLVMBuildGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), Indices.len() as c_uint, noname()); } } @@ -432,15 +432,15 @@ fn GEPi(cx: block, base: ValueRef, ixs: ~[uint]) -> ValueRef { let mut v: ~[ValueRef] = ~[]; for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); } count_insn(cx, ~"gepi"); - ret InBoundsGEP(cx, base, v); + return InBoundsGEP(cx, base, v); } fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); } unsafe { count_insn(cx, ~"inboundsgep"); - ret llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, + return llvm::LLVMBuildInBoundsGEP(B(cx), Pointer, vec::unsafe::to_ptr(Indices), Indices.len() as c_uint, noname()); @@ -448,168 +448,168 @@ fn InBoundsGEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> } fn StructGEP(cx: block, Pointer: ValueRef, Idx: uint) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_nil())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_nil())); } count_insn(cx, ~"structgep"); - ret llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname()); + return llvm::LLVMBuildStructGEP(B(cx), Pointer, Idx as c_uint, noname()); } fn GlobalString(cx: block, _Str: *libc::c_char) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } count_insn(cx, ~"globalstring"); - ret llvm::LLVMBuildGlobalString(B(cx), _Str, noname()); + return llvm::LLVMBuildGlobalString(B(cx), _Str, noname()); } fn GlobalStringPtr(cx: block, _Str: *libc::c_char) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_ptr(T_i8())); } + if cx.unreachable { return llvm::LLVMGetUndef(T_ptr(T_i8())); } count_insn(cx, ~"globalstringptr"); - ret llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname()); + return llvm::LLVMBuildGlobalStringPtr(B(cx), _Str, noname()); } /* Casts */ fn Trunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"trunc"); - ret llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildTrunc(B(cx), Val, DestTy, noname()); } fn ZExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"zext"); - ret llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildZExt(B(cx), Val, DestTy, noname()); } fn SExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"sext"); - ret llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildSExt(B(cx), Val, DestTy, noname()); } fn FPToUI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"fptoui"); - ret llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildFPToUI(B(cx), Val, DestTy, noname()); } fn FPToSI(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"fptosi"); - ret llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildFPToSI(B(cx), Val, DestTy, noname()); } fn UIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"uitofp"); - ret llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildUIToFP(B(cx), Val, DestTy, noname()); } fn SIToFP(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"sitofp"); - ret llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildSIToFP(B(cx), Val, DestTy, noname()); } fn FPTrunc(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"fptrunc"); - ret llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildFPTrunc(B(cx), Val, DestTy, noname()); } fn FPExt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"fpext"); - ret llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildFPExt(B(cx), Val, DestTy, noname()); } fn PtrToInt(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"ptrtoint"); - ret llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildPtrToInt(B(cx), Val, DestTy, noname()); } fn IntToPtr(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"inttoptr"); - ret llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildIntToPtr(B(cx), Val, DestTy, noname()); } fn BitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"bitcast"); - ret llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildBitCast(B(cx), Val, DestTy, noname()); } fn ZExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"zextorbitcast"); - ret llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildZExtOrBitCast(B(cx), Val, DestTy, noname()); } fn SExtOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"sextorbitcast"); - ret llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildSExtOrBitCast(B(cx), Val, DestTy, noname()); } fn TruncOrBitCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"truncorbitcast"); - ret llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildTruncOrBitCast(B(cx), Val, DestTy, noname()); } fn Cast(cx: block, Op: Opcode, Val: ValueRef, DestTy: TypeRef, _Name: *u8) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"cast"); - ret llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname()); + return llvm::LLVMBuildCast(B(cx), Op, Val, DestTy, noname()); } fn PointerCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"pointercast"); - ret llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildPointerCast(B(cx), Val, DestTy, noname()); } fn IntCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"intcast"); - ret llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildIntCast(B(cx), Val, DestTy, noname()); } fn FPCast(cx: block, Val: ValueRef, DestTy: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(DestTy); } + if cx.unreachable { return llvm::LLVMGetUndef(DestTy); } count_insn(cx, ~"fpcast"); - ret llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname()); + return llvm::LLVMBuildFPCast(B(cx), Val, DestTy, noname()); } /* Comparisons */ fn ICmp(cx: block, Op: IntPredicate, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } + if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } count_insn(cx, ~"icmp"); - ret llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname()); + return llvm::LLVMBuildICmp(B(cx), Op as c_uint, LHS, RHS, noname()); } fn FCmp(cx: block, Op: RealPredicate, LHS: ValueRef, RHS: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } + if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } count_insn(cx, ~"fcmp"); - ret llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname()); + return llvm::LLVMBuildFCmp(B(cx), Op as c_uint, LHS, RHS, noname()); } /* Miscellaneous instructions */ fn EmptyPhi(cx: block, Ty: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } + if cx.unreachable { return llvm::LLVMGetUndef(Ty); } count_insn(cx, ~"emptyphi"); - ret llvm::LLVMBuildPhi(B(cx), Ty, noname()); + return llvm::LLVMBuildPhi(B(cx), Ty, noname()); } fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef]) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } + if cx.unreachable { return llvm::LLVMGetUndef(Ty); } assert vals.len() == bbs.len(); let phi = EmptyPhi(cx, Ty); unsafe { @@ -617,12 +617,12 @@ fn Phi(cx: block, Ty: TypeRef, vals: ~[ValueRef], bbs: ~[BasicBlockRef]) llvm::LLVMAddIncoming(phi, vec::unsafe::to_ptr(vals), vec::unsafe::to_ptr(bbs), vals.len() as c_uint); - ret phi; + return phi; } } fn AddIncomingToPhi(phi: ValueRef, val: ValueRef, bb: BasicBlockRef) { - if llvm::LLVMIsUndef(phi) == lib::llvm::True { ret; } + if llvm::LLVMIsUndef(phi) == lib::llvm::True { return; } unsafe { let valptr = unsafe::reinterpret_cast(ptr::addr_of(val)); let bbptr = unsafe::reinterpret_cast(ptr::addr_of(bb)); @@ -636,7 +636,7 @@ fn _UndefReturn(cx: block, Fn: ValueRef) -> ValueRef { let retty = if llvm::LLVMGetTypeKind(ty) == lib::llvm::Integer { llvm::LLVMGetReturnType(ty) } else { ccx.int_type }; count_insn(cx, ~""); - ret llvm::LLVMGetUndef(retty); + return llvm::LLVMGetUndef(retty); } fn add_span_comment(bcx: block, sp: span, text: ~str) { @@ -666,7 +666,7 @@ fn add_comment(bcx: block, text: ~str) { } fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { - if cx.unreachable { ret _UndefReturn(cx, Fn); } + if cx.unreachable { return _UndefReturn(cx, Fn); } unsafe { count_insn(cx, ~"call"); @@ -674,103 +674,104 @@ fn Call(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { val_str(cx.ccx().tn, Fn), Args.map(|arg| val_str(cx.ccx().tn, arg))}; - ret llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), + return llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); } } fn FastCall(cx: block, Fn: ValueRef, Args: ~[ValueRef]) -> ValueRef { - if cx.unreachable { ret _UndefReturn(cx, Fn); } + if cx.unreachable { return _UndefReturn(cx, Fn); } unsafe { count_insn(cx, ~"fastcall"); let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); lib::llvm::SetInstructionCallConv(v, lib::llvm::FastCallConv); - ret v; + return v; } } fn CallWithConv(cx: block, Fn: ValueRef, Args: ~[ValueRef], Conv: CallConv) -> ValueRef { - if cx.unreachable { ret _UndefReturn(cx, Fn); } + if cx.unreachable { return _UndefReturn(cx, Fn); } unsafe { count_insn(cx, ~"callwithconv"); let v = llvm::LLVMBuildCall(B(cx), Fn, vec::unsafe::to_ptr(Args), Args.len() as c_uint, noname()); lib::llvm::SetInstructionCallConv(v, Conv); - ret v; + return v; } } fn Select(cx: block, If: ValueRef, Then: ValueRef, Else: ValueRef) -> ValueRef { - if cx.unreachable { ret _Undef(Then); } + if cx.unreachable { return _Undef(Then); } count_insn(cx, ~"select"); - ret llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname()); + return llvm::LLVMBuildSelect(B(cx), If, Then, Else, noname()); } fn VAArg(cx: block, list: ValueRef, Ty: TypeRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(Ty); } + if cx.unreachable { return llvm::LLVMGetUndef(Ty); } count_insn(cx, ~"vaarg"); - ret llvm::LLVMBuildVAArg(B(cx), list, Ty, noname()); + return llvm::LLVMBuildVAArg(B(cx), list, Ty, noname()); } fn ExtractElement(cx: block, VecVal: ValueRef, Index: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } + if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); } count_insn(cx, ~"extractelement"); - ret llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname()); + return llvm::LLVMBuildExtractElement(B(cx), VecVal, Index, noname()); } fn InsertElement(cx: block, VecVal: ValueRef, EltVal: ValueRef, Index: ValueRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } count_insn(cx, ~"insertelement"); llvm::LLVMBuildInsertElement(B(cx), VecVal, EltVal, Index, noname()); } fn ShuffleVector(cx: block, V1: ValueRef, V2: ValueRef, Mask: ValueRef) { - if cx.unreachable { ret; } + if cx.unreachable { return; } count_insn(cx, ~"shufflevector"); llvm::LLVMBuildShuffleVector(B(cx), V1, V2, Mask, noname()); } fn ExtractValue(cx: block, AggVal: ValueRef, Index: uint) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_nil()); } + if cx.unreachable { return llvm::LLVMGetUndef(T_nil()); } count_insn(cx, ~"extractvalue"); - ret llvm::LLVMBuildExtractValue(B(cx), AggVal, Index as c_uint, noname()); + return llvm::LLVMBuildExtractValue( + B(cx), AggVal, Index as c_uint, noname()); } fn InsertValue(cx: block, AggVal: ValueRef, EltVal: ValueRef, Index: uint) { - if cx.unreachable { ret; } + if cx.unreachable { return; } count_insn(cx, ~"insertvalue"); llvm::LLVMBuildInsertValue(B(cx), AggVal, EltVal, Index as c_uint, noname()); } fn IsNull(cx: block, Val: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } + if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } count_insn(cx, ~"isnull"); - ret llvm::LLVMBuildIsNull(B(cx), Val, noname()); + return llvm::LLVMBuildIsNull(B(cx), Val, noname()); } fn IsNotNull(cx: block, Val: ValueRef) -> ValueRef { - if cx.unreachable { ret llvm::LLVMGetUndef(T_i1()); } + if cx.unreachable { return llvm::LLVMGetUndef(T_i1()); } count_insn(cx, ~"isnotnull"); - ret llvm::LLVMBuildIsNotNull(B(cx), Val, noname()); + return llvm::LLVMBuildIsNotNull(B(cx), Val, noname()); } fn PtrDiff(cx: block, LHS: ValueRef, RHS: ValueRef) -> ValueRef { let ccx = cx.fcx.ccx; - if cx.unreachable { ret llvm::LLVMGetUndef(ccx.int_type); } + if cx.unreachable { return llvm::LLVMGetUndef(ccx.int_type); } count_insn(cx, ~"ptrdiff"); - ret llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname()); + return llvm::LLVMBuildPtrDiff(B(cx), LHS, RHS, noname()); } fn Trap(cx: block) { - if cx.unreachable { ret; } + if cx.unreachable { return; } let b = B(cx); let BB: BasicBlockRef = llvm::LLVMGetInsertBlock(b); let FN: ValueRef = llvm::LLVMGetBasicBlockParent(BB); @@ -791,7 +792,7 @@ fn LandingPad(cx: block, Ty: TypeRef, PersFn: ValueRef, NumClauses: uint) -> ValueRef { assert !cx.terminated && !cx.unreachable; count_insn(cx, ~"landingpad"); - ret llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, + return llvm::LLVMBuildLandingPad(B(cx), Ty, PersFn, NumClauses as c_uint, noname()); } @@ -804,7 +805,7 @@ fn Resume(cx: block, Exn: ValueRef) -> ValueRef { assert (!cx.terminated); cx.terminated = true; count_insn(cx, ~"resume"); - ret llvm::LLVMBuildResume(B(cx), Exn); + return llvm::LLVMBuildResume(B(cx), Exn); } // Atomic Operations diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index c216b890ace..804ee5ba83c 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -113,7 +113,7 @@ fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str { fn mk_tuplified_uniq_cbox_ty(tcx: ty::ctxt, cdata_ty: ty::t) -> ty::t { let cbox_ty = tuplify_box_ty(tcx, cdata_ty); - ret ty::mk_imm_uniq(tcx, cbox_ty); + return ty::mk_imm_uniq(tcx, cbox_ty); } // Given a closure ty, emits a corresponding tuple ty @@ -132,7 +132,7 @@ fn mk_closure_tys(tcx: ty::ctxt, } let cdata_ty = ty::mk_tup(tcx, bound_tys); debug!{"cdata_ty=%s", ty_to_str(tcx, cdata_ty)}; - ret cdata_ty; + return cdata_ty; } fn allocate_cbox(bcx: block, @@ -168,7 +168,7 @@ fn allocate_cbox(bcx: block, } }; - ret {bcx: bcx, val: val}; + return {bcx: bcx, val: val}; } type closure_result = { @@ -247,7 +247,7 @@ fn store_environment(bcx: block, } for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); } - ret {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx}; + return {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx}; } // Given a context and a list of upvars, build a closure. This just @@ -307,7 +307,7 @@ fn build_closure(bcx0: block, vec::push(env_vals, env_ref(nil_ret, ty::mk_nil_ptr(tcx), lv_owned)); } - ret store_environment(bcx, env_vals, ck); + return store_environment(bcx, env_vals, ck); } // Given an enclosing block context, a new function context, a closure type, @@ -361,7 +361,7 @@ fn trans_expr_fn(bcx: block, is_loop_body: option<option<ValueRef>>, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"closure::trans_expr_fn"); - if dest == ignore { ret bcx; } + if dest == ignore { return bcx; } let ccx = bcx.ccx(); let fty = node_id_type(bcx, id); let llfnty = type_of_fn_from_ty(ccx, fty); @@ -399,7 +399,7 @@ fn trans_expr_fn(bcx: block, }; fill_fn_pair(bcx, get_dest_addr(dest), llfn, closure); - ret bcx; + return bcx; } fn make_fn_glue( @@ -421,7 +421,7 @@ fn make_fn_glue( } }; - ret alt ty::get(t).struct { + return alt ty::get(t).struct { ty::ty_fn({proto: ast::proto_bare, _}) | ty::ty_fn({proto: ast::proto_block, _}) | ty::ty_fn({proto: ast::proto_any, _}) { bcx } @@ -439,8 +439,11 @@ fn make_opaque_cbox_take_glue( // Easy cases: let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue"); alt ck { - ty::ck_block { ret bcx; } - ty::ck_box { incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); ret bcx; } + ty::ck_block { return bcx; } + ty::ck_box { + incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); + return bcx; + } ty::ck_uniq { /* hard case: */ } } @@ -507,7 +510,7 @@ fn make_opaque_cbox_free_glue( -> block { let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue"); alt ck { - ty::ck_block { ret bcx; } + ty::ck_block { return bcx; } ty::ck_box | ty::ck_uniq { /* hard cases: */ } } @@ -537,3 +540,4 @@ fn make_opaque_cbox_free_glue( } } } + diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index bfb7676024a..ed977ec3bfb 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -24,7 +24,7 @@ import util::ppaux::ty_to_str; type namegen = fn@(~str) -> ~str; fn new_namegen() -> namegen { let i = @mut 0; - ret fn@(prefix: ~str) -> ~str { *i += 1; prefix + int::str(*i) }; + return fn@(prefix: ~str) -> ~str { *i += 1; prefix + int::str(*i) }; } type tydesc_info = @@ -247,7 +247,7 @@ fn cleanup_type(cx: ty::ctxt, ty: ty::t) -> cleantype { } fn add_clean(cx: block, val: ValueRef, ty: ty::t) { - if !ty::type_needs_drop(cx.tcx(), ty) { ret; } + if !ty::type_needs_drop(cx.tcx(), ty) { return; } debug!{"add_clean(%s, %s, %s)", cx.to_str(), val_str(cx.ccx().tn, val), ty_to_str(cx.ccx().tcx, ty)}; @@ -259,7 +259,7 @@ fn add_clean(cx: block, val: ValueRef, ty: ty::t) { } } fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { - if !ty::type_needs_drop(cx.tcx(), ty) { ret; } + if !ty::type_needs_drop(cx.tcx(), ty) { return; } debug!{"add_clean_temp(%s, %s, %s)", cx.to_str(), val_str(cx.ccx().tn, val), ty_to_str(cx.ccx().tcx, ty)}; @@ -267,9 +267,9 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { fn do_drop(bcx: block, val: ValueRef, ty: ty::t) -> block { if ty::type_is_immediate(ty) { - ret base::drop_ty_immediate(bcx, val, ty); + return base::drop_ty_immediate(bcx, val, ty); } else { - ret base::drop_ty(bcx, val, ty); + return base::drop_ty(bcx, val, ty); } } do in_scope_cx(cx) |info| { @@ -279,7 +279,7 @@ fn add_clean_temp(cx: block, val: ValueRef, ty: ty::t) { } } fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) { - if !ty::type_needs_drop(cx.tcx(), ty) { ret; } + if !ty::type_needs_drop(cx.tcx(), ty) { return; } debug!{"add_clean_temp_mem(%s, %s, %s)", cx.to_str(), val_str(cx.ccx().tn, val), ty_to_str(cx.ccx().tcx, ty)}; @@ -429,12 +429,14 @@ fn rslt(bcx: block, val: ValueRef) -> result { } fn ty_str(tn: type_names, t: TypeRef) -> ~str { - ret lib::llvm::type_to_str(tn, t); + return lib::llvm::type_to_str(tn, t); } -fn val_ty(v: ValueRef) -> TypeRef { ret llvm::LLVMTypeOf(v); } +fn val_ty(v: ValueRef) -> TypeRef { return llvm::LLVMTypeOf(v); } -fn val_str(tn: type_names, v: ValueRef) -> ~str { ret ty_str(tn, val_ty(v)); } +fn val_str(tn: type_names, v: ValueRef) -> ~str { + return ty_str(tn, val_ty(v)); +} // Returns the nth element of the given LLVM structure type. fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { @@ -442,14 +444,14 @@ fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { assert (n < elt_count); let elt_tys = vec::from_elem(elt_count, T_nil()); llvm::LLVMGetStructElementTypes(llstructty, to_ptr(elt_tys)); - ret llvm::LLVMGetElementType(elt_tys[n]); + return llvm::LLVMGetElementType(elt_tys[n]); } fn in_scope_cx(cx: block, f: fn(scope_info)) { let mut cur = cx; loop { alt cur.kind { - block_scope(inf) { f(inf); ret; } + block_scope(inf) { f(inf); return; } _ {} } cur = block_parent(cur); @@ -502,35 +504,35 @@ fn T_void() -> TypeRef { // of 10 nil values will have 10-bit size -- but it doesn't seem like we // have any other options until it's fixed upstream. - ret llvm::LLVMVoidType(); + return llvm::LLVMVoidType(); } fn T_nil() -> TypeRef { // NB: See above in T_void(). - ret llvm::LLVMInt1Type(); + return llvm::LLVMInt1Type(); } -fn T_metadata() -> TypeRef { ret llvm::LLVMMetadataType(); } +fn T_metadata() -> TypeRef { return llvm::LLVMMetadataType(); } -fn T_i1() -> TypeRef { ret llvm::LLVMInt1Type(); } +fn T_i1() -> TypeRef { return llvm::LLVMInt1Type(); } -fn T_i8() -> TypeRef { ret llvm::LLVMInt8Type(); } +fn T_i8() -> TypeRef { return llvm::LLVMInt8Type(); } -fn T_i16() -> TypeRef { ret llvm::LLVMInt16Type(); } +fn T_i16() -> TypeRef { return llvm::LLVMInt16Type(); } -fn T_i32() -> TypeRef { ret llvm::LLVMInt32Type(); } +fn T_i32() -> TypeRef { return llvm::LLVMInt32Type(); } -fn T_i64() -> TypeRef { ret llvm::LLVMInt64Type(); } +fn T_i64() -> TypeRef { return llvm::LLVMInt64Type(); } -fn T_f32() -> TypeRef { ret llvm::LLVMFloatType(); } +fn T_f32() -> TypeRef { return llvm::LLVMFloatType(); } -fn T_f64() -> TypeRef { ret llvm::LLVMDoubleType(); } +fn T_f64() -> TypeRef { return llvm::LLVMDoubleType(); } -fn T_bool() -> TypeRef { ret T_i1(); } +fn T_bool() -> TypeRef { return T_i1(); } fn T_int(targ_cfg: @session::config) -> TypeRef { - ret alt targ_cfg.arch { + return alt targ_cfg.arch { session::arch_x86 { T_i32() } session::arch_x86_64 { T_i64() } session::arch_arm { T_i32() } @@ -567,40 +569,40 @@ fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef { } fn T_float(targ_cfg: @session::config) -> TypeRef { - ret alt targ_cfg.arch { + return alt targ_cfg.arch { session::arch_x86 { T_f64() } session::arch_x86_64 { T_f64() } session::arch_arm { T_f64() } }; } -fn T_char() -> TypeRef { ret T_i32(); } +fn T_char() -> TypeRef { return T_i32(); } fn T_size_t(targ_cfg: @session::config) -> TypeRef { - ret T_int(targ_cfg); + return T_int(targ_cfg); } fn T_fn(inputs: ~[TypeRef], output: TypeRef) -> TypeRef unsafe { - ret llvm::LLVMFunctionType(output, to_ptr(inputs), + return llvm::LLVMFunctionType(output, to_ptr(inputs), inputs.len() as c_uint, False); } fn T_fn_pair(cx: @crate_ctxt, tfn: TypeRef) -> TypeRef { - ret T_struct(~[T_ptr(tfn), T_opaque_cbox_ptr(cx)]); + return T_struct(~[T_ptr(tfn), T_opaque_cbox_ptr(cx)]); } fn T_ptr(t: TypeRef) -> TypeRef { - ret llvm::LLVMPointerType(t, 0u as c_uint); + return llvm::LLVMPointerType(t, 0u as c_uint); } fn T_struct(elts: ~[TypeRef]) -> TypeRef unsafe { - ret llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False); + return llvm::LLVMStructType(to_ptr(elts), elts.len() as c_uint, False); } fn T_named_struct(name: ~str) -> TypeRef { let c = llvm::LLVMGetGlobalContext(); - ret str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf)); + return str::as_c_str(name, |buf| llvm::LLVMStructCreateNamed(c, buf)); } fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) unsafe { @@ -608,7 +610,7 @@ fn set_struct_body(t: TypeRef, elts: ~[TypeRef]) unsafe { elts.len() as c_uint, False); } -fn T_empty_struct() -> TypeRef { ret T_struct(~[]); } +fn T_empty_struct() -> TypeRef { return T_struct(~[]); } // A vtable is, in reality, a vtable pointer followed by zero or more pointers // to tydescs and other vtables that it closes over. But the types and number @@ -635,7 +637,7 @@ fn T_task(targ_cfg: @session::config) -> TypeRef { ~[t_int, t_int, t_int, t_int, t_int, t_int, t_int, t_int]; set_struct_body(t, elems); - ret t; + return t; } fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { @@ -647,15 +649,15 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { llvm::LLVMGetStructElementTypes(cx.tydesc_type, to_ptr::<TypeRef>(tydesc_elts)); let t = llvm::LLVMGetElementType(tydesc_elts[field]); - ret t; + return t; } fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { let s = ~"glue_fn"; - alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} } + alt name_has_type(cx.tn, s) { some(t) { return t; } _ {} } let t = T_tydesc_field(cx, abi::tydesc_field_drop_glue); associate_type(cx.tn, s, t); - ret t; + return t; } fn T_tydesc(targ_cfg: @session::config) -> TypeRef { @@ -672,27 +674,27 @@ fn T_tydesc(targ_cfg: @session::config) -> TypeRef { glue_fn_ty, glue_fn_ty, glue_fn_ty, glue_fn_ty, T_ptr(T_i8()), T_ptr(T_i8())]; set_struct_body(tydesc, elems); - ret tydesc; + return tydesc; } fn T_array(t: TypeRef, n: uint) -> TypeRef { - ret llvm::LLVMArrayType(t, n as c_uint); + return llvm::LLVMArrayType(t, n as c_uint); } // Interior vector. fn T_vec2(targ_cfg: @session::config, t: TypeRef) -> TypeRef { - ret T_struct(~[T_int(targ_cfg), // fill + return T_struct(~[T_int(targ_cfg), // fill T_int(targ_cfg), // alloc T_array(t, 0u)]); // elements } fn T_vec(ccx: @crate_ctxt, t: TypeRef) -> TypeRef { - ret T_vec2(ccx.sess.targ_cfg, t); + return T_vec2(ccx.sess.targ_cfg, t); } // Note that the size of this one is in bytes. fn T_opaque_vec(targ_cfg: @session::config) -> TypeRef { - ret T_vec2(targ_cfg, T_i8()); + return T_vec2(targ_cfg, T_i8()); } // Let T be the content of a box @T. tuplify_box_ty(t) returns the @@ -700,120 +702,120 @@ fn T_opaque_vec(targ_cfg: @session::config) -> TypeRef { // returns). fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { let ptr = ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm}); - ret ty::mk_tup(tcx, ~[ty::mk_uint(tcx), ty::mk_type(tcx), + return ty::mk_tup(tcx, ~[ty::mk_uint(tcx), ty::mk_type(tcx), ptr, ptr, t]); } fn T_box_header_fields(cx: @crate_ctxt) -> ~[TypeRef] { let ptr = T_ptr(T_i8()); - ret ~[cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr]; + return ~[cx.int_type, T_ptr(cx.tydesc_type), ptr, ptr]; } fn T_box_header(cx: @crate_ctxt) -> TypeRef { - ret T_struct(T_box_header_fields(cx)); + return T_struct(T_box_header_fields(cx)); } fn T_box(cx: @crate_ctxt, t: TypeRef) -> TypeRef { - ret T_struct(vec::append(T_box_header_fields(cx), ~[t])); + return T_struct(vec::append(T_box_header_fields(cx), ~[t])); } fn T_box_ptr(t: TypeRef) -> TypeRef { const box_addrspace: uint = 1u; - ret llvm::LLVMPointerType(t, box_addrspace as c_uint); + return llvm::LLVMPointerType(t, box_addrspace as c_uint); } fn T_opaque_box(cx: @crate_ctxt) -> TypeRef { - ret T_box(cx, T_i8()); + return T_box(cx, T_i8()); } fn T_opaque_box_ptr(cx: @crate_ctxt) -> TypeRef { - ret T_box_ptr(T_opaque_box(cx)); + return T_box_ptr(T_opaque_box(cx)); } fn T_unique(cx: @crate_ctxt, t: TypeRef) -> TypeRef { - ret T_struct(vec::append(T_box_header_fields(cx), ~[t])); + return T_struct(vec::append(T_box_header_fields(cx), ~[t])); } fn T_unique_ptr(t: TypeRef) -> TypeRef { const unique_addrspace: uint = 1u; - ret llvm::LLVMPointerType(t, unique_addrspace as c_uint); + return llvm::LLVMPointerType(t, unique_addrspace as c_uint); } fn T_port(cx: @crate_ctxt, _t: TypeRef) -> TypeRef { - ret T_struct(~[cx.int_type]); // Refcount + return T_struct(~[cx.int_type]); // Refcount } fn T_chan(cx: @crate_ctxt, _t: TypeRef) -> TypeRef { - ret T_struct(~[cx.int_type]); // Refcount + return T_struct(~[cx.int_type]); // Refcount } -fn T_taskptr(cx: @crate_ctxt) -> TypeRef { ret T_ptr(cx.task_type); } +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) { some(t) { ret t; } _ {} } + alt name_has_type(tn, s) { some(t) { return t; } _ {} } let t = T_i8(); associate_type(tn, s, t); - ret t; + return t; } -fn T_typaram_ptr(tn: type_names) -> TypeRef { ret T_ptr(T_typaram(tn)); } +fn T_typaram_ptr(tn: type_names) -> TypeRef { return T_ptr(T_typaram(tn)); } fn T_opaque_cbox_ptr(cx: @crate_ctxt) -> TypeRef { // closures look like boxes (even when they are fn~ or fn&) // see trans_closure.rs - ret T_opaque_box_ptr(cx); + return T_opaque_box_ptr(cx); } fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef { - ret cx.int_type; + return cx.int_type; } fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef { let s = ~"opaque_enum"; - alt name_has_type(cx.tn, s) { some(t) { ret t; } _ {} } + alt name_has_type(cx.tn, s) { some(t) { return t; } _ {} } let t = T_struct(~[T_enum_discrim(cx), T_i8()]); associate_type(cx.tn, s, t); - ret t; + return t; } fn T_opaque_enum_ptr(cx: @crate_ctxt) -> TypeRef { - ret T_ptr(T_opaque_enum(cx)); + return T_ptr(T_opaque_enum(cx)); } fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef { - ret T_struct(vec::from_elem::<TypeRef>(n, T_ptr(cx.tydesc_type))); + return T_struct(vec::from_elem::<TypeRef>(n, T_ptr(cx.tydesc_type))); } fn T_opaque_trait(cx: @crate_ctxt) -> TypeRef { T_struct(~[T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)]) } -fn T_opaque_port_ptr() -> TypeRef { ret T_ptr(T_i8()); } +fn T_opaque_port_ptr() -> TypeRef { return T_ptr(T_i8()); } -fn T_opaque_chan_ptr() -> TypeRef { ret T_ptr(T_i8()); } +fn T_opaque_chan_ptr() -> TypeRef { return T_ptr(T_i8()); } // LLVM constant constructors. -fn C_null(t: TypeRef) -> ValueRef { ret llvm::LLVMConstNull(t); } +fn C_null(t: TypeRef) -> ValueRef { return llvm::LLVMConstNull(t); } fn C_integral(t: TypeRef, u: u64, sign_extend: Bool) -> ValueRef { - ret llvm::LLVMConstInt(t, u, sign_extend); + return llvm::LLVMConstInt(t, u, sign_extend); } fn C_floating(s: ~str, t: TypeRef) -> ValueRef { - ret str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf)); + return str::as_c_str(s, |buf| llvm::LLVMConstRealOfString(t, buf)); } fn C_nil() -> ValueRef { // NB: See comment above in T_void(). - ret C_integral(T_i1(), 0u64, False); + return C_integral(T_i1(), 0u64, False); } fn C_bool(b: bool) -> ValueRef { @@ -821,29 +823,29 @@ fn C_bool(b: bool) -> ValueRef { } fn C_i32(i: i32) -> ValueRef { - ret C_integral(T_i32(), i as u64, True); + return C_integral(T_i32(), i as u64, True); } fn C_i64(i: i64) -> ValueRef { - ret C_integral(T_i64(), i as u64, True); + return C_integral(T_i64(), i as u64, True); } fn C_int(cx: @crate_ctxt, i: int) -> ValueRef { - ret C_integral(cx.int_type, i as u64, True); + return C_integral(cx.int_type, i as u64, True); } fn C_uint(cx: @crate_ctxt, i: uint) -> ValueRef { - ret C_integral(cx.int_type, i as u64, False); + return C_integral(cx.int_type, i as u64, False); } -fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i as u64, False); } +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) { - some(llval) { ret llval; } + some(llval) { return llval; } none { } } @@ -859,7 +861,7 @@ fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { cx.const_cstr_cache.insert(s, g); - ret g; + return g; } fn C_estr_slice(cx: @crate_ctxt, s: ~str) -> ValueRef { @@ -869,7 +871,7 @@ fn C_estr_slice(cx: @crate_ctxt, s: ~str) -> ValueRef { // Returns a Plain Old LLVM String: fn C_postr(s: ~str) -> ValueRef { - ret do str::as_c_str(s) |buf| { + return do str::as_c_str(s) |buf| { llvm::LLVMConstString(buf, str::len(s) as c_uint, False) }; } @@ -878,27 +880,27 @@ fn C_zero_byte_arr(size: uint) -> ValueRef unsafe { let mut i = 0u; let mut elts: ~[ValueRef] = ~[]; while i < size { vec::push(elts, C_u8(0u)); i += 1u; } - ret llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts), + return llvm::LLVMConstArray(T_i8(), vec::unsafe::to_ptr(elts), elts.len() as c_uint); } fn C_struct(elts: ~[ValueRef]) -> ValueRef unsafe { - ret llvm::LLVMConstStruct(vec::unsafe::to_ptr(elts), + return llvm::LLVMConstStruct(vec::unsafe::to_ptr(elts), elts.len() as c_uint, False); } fn C_named_struct(T: TypeRef, elts: ~[ValueRef]) -> ValueRef unsafe { - ret llvm::LLVMConstNamedStruct(T, vec::unsafe::to_ptr(elts), + return llvm::LLVMConstNamedStruct(T, vec::unsafe::to_ptr(elts), elts.len() as c_uint); } fn C_array(ty: TypeRef, elts: ~[ValueRef]) -> ValueRef unsafe { - ret llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts), + return llvm::LLVMConstArray(ty, vec::unsafe::to_ptr(elts), elts.len() as c_uint); } fn C_bytes(bytes: ~[u8]) -> ValueRef unsafe { - ret llvm::LLVMConstString( + return llvm::LLVMConstString( unsafe::reinterpret_cast(vec::unsafe::to_ptr(bytes)), bytes.len() as c_uint, False); } @@ -911,7 +913,7 @@ fn C_shape(ccx: @crate_ctxt, bytes: ~[u8]) -> ValueRef { llvm::LLVMSetInitializer(llglobal, llshape); llvm::LLVMSetGlobalConstant(llglobal, True); lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage); - ret llvm::LLVMConstPointerCast(llglobal, T_ptr(T_i8())); + return llvm::LLVMConstPointerCast(llglobal, T_ptr(T_i8())); } fn get_param(fndecl: ValueRef, param: uint) -> ValueRef { @@ -945,18 +947,18 @@ fn hash_mono_id(&&mi: mono_id) -> uint { fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { let cond = build::ICmp(cx, lib::llvm::IntULT, a, b); - ret build::Select(cx, cond, b, a); + return build::Select(cx, cond, b, a); } fn umin(cx: block, a: ValueRef, b: ValueRef) -> ValueRef { let cond = build::ICmp(cx, lib::llvm::IntULT, a, b); - ret build::Select(cx, cond, a, b); + return build::Select(cx, cond, a, b); } fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef { let mask = build::Sub(cx, align, C_int(cx.ccx(), 1)); let bumped = build::Add(cx, off, mask); - ret build::And(cx, bumped, build::Not(cx, mask)); + return build::And(cx, bumped, build::Not(cx, mask)); } fn path_str(p: path) -> ~str { diff --git a/src/rustc/middle/trans/consts.rs b/src/rustc/middle/trans/consts.rs index c9e2582f5b2..aeb8c8ce74a 100644 --- a/src/rustc/middle/trans/consts.rs +++ b/src/rustc/middle/trans/consts.rs @@ -51,7 +51,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); - ret alt b { + return alt b { ast::add { if is_float { llvm::LLVMConstFAdd(te1, te2) } else { llvm::LLVMConstAdd(te1, te2) } @@ -96,7 +96,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); - ret alt u { + return alt u { ast::box(_) | ast::uniq(_) | ast::deref { cx.sess.span_bug(e.span, diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 98e7129abba..1f1da98b528 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -130,7 +130,7 @@ enum debug_metadata { fn cast_safely<T: copy, U>(val: T) -> U unsafe { let val2 = val; - ret unsafe::transmute(val2); + return unsafe::transmute(val2); } fn md_from_metadata<T>(val: debug_metadata) -> T unsafe { @@ -153,11 +153,11 @@ fn cached_metadata<T: copy>(cache: metadata_cache, mdtag: int, for items.each |item| { let md: T = md_from_metadata::<T>(item); if eq(md) { - ret option::some(md); + return option::some(md); } } } - ret option::none; + return option::none; } fn create_compile_unit(cx: @crate_ctxt) @@ -167,7 +167,7 @@ fn create_compile_unit(cx: @crate_ctxt) let tg = CompileUnitTag; alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg, |md| md.data.name == crate_name) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} } @@ -189,7 +189,7 @@ fn create_compile_unit(cx: @crate_ctxt) let mdval = @{node: unit_node, data: {name: crate_name}}; update_cache(cache, tg, compile_unit_metadata(mdval)); - ret mdval; + return mdval; } fn get_cache(cx: @crate_ctxt) -> metadata_cache { @@ -210,7 +210,7 @@ fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> { let tg = FileDescriptorTag; alt cached_metadata::<@metadata<file_md>>( cache, tg, |md| md.data.path == full_path) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} } @@ -224,7 +224,7 @@ fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> { let val = llmdnode(file_md); let mdval = @{node: val, data: {path: full_path}}; update_cache(cache, tg, file_metadata(mdval)); - ret mdval; + return mdval; } fn line_from_span(cm: codemap::codemap, sp: span) -> uint { @@ -249,7 +249,7 @@ fn create_block(cx: block) -> @metadata<block_md> { /*alt cached_metadata::<@metadata<block_md>>( cache, tg, {|md| start == md.data.start && end == md.data.end}) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} }*/ @@ -272,7 +272,7 @@ fn create_block(cx: block) -> @metadata<block_md> { let val = llmdnode(lldata); let mdval = @{node: val, data: {start: start, end: end}}; //update_cache(cache, tg, block_metadata(mdval)); - ret mdval; + return mdval; } fn size_and_align_of(cx: @crate_ctxt, t: ty::t) -> (int, int) { @@ -287,7 +287,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) let tg = BasicTypeDescriptorTag; alt cached_metadata::<@metadata<tydesc_md>>( cache, tg, |md| ty::type_id(t) == md.data.hash) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} } @@ -333,7 +333,7 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; update_cache(cache, tg, tydesc_metadata(mdval)); add_named_metadata(cx, ~"llvm.dbg.ty", llnode); - ret mdval; + return mdval; } fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, @@ -343,7 +343,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, /*let cache = cx.llmetadata; alt cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| ty::hash_ty(t) == ty::hash_ty(md.data.hash)}) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} }*/ let (size, align) = size_and_align_of(cx, t); @@ -355,7 +355,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, let mdval = @{node: llnode, data: {hash: ty::type_id(t)}}; //update_cache(cache, tg, tydesc_metadata(mdval)); add_named_metadata(cx, ~"llvm.dbg.ty", llnode); - ret mdval; + return mdval; } type struct_ctxt = { @@ -368,7 +368,7 @@ type struct_ctxt = { }; fn finish_structure(cx: @struct_ctxt) -> ValueRef { - ret create_composite_type(StructureTypeTag, cx.name, cx.file, cx.line, + return create_composite_type(StructureTypeTag, cx.name, cx.file, cx.line, cx.total_size, cx.align, 0, option::none, option::some(cx.members)); } @@ -382,7 +382,7 @@ fn create_structure(file: @metadata<file_md>, name: ~str, line: int) mut total_size: 0, align: 64 //XXX different alignment per arch? }; - ret cx; + return cx; } fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int, @@ -398,7 +398,7 @@ fn create_derived_type(type_tag: int, file: ValueRef, name: ~str, line: int, lli64(offset), lli32(0), ty]; - ret llmdnode(lldata); + return llmdnode(lldata); } fn add_member(cx: @struct_ctxt, name: ~str, line: int, size: int, align: int, @@ -426,7 +426,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: ~[ast::ty_field], size as int, align as int, ty_md.node); } let mdval = @{node: finish_structure(scx), data:{hash: ty::type_id(t)}}; - ret mdval; + return mdval; } fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, @@ -436,7 +436,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, /*let cache = cx.llmetadata; alt cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| ty::hash_ty(outer) == ty::hash_ty(md.data.hash)}) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} }*/ let fname = filename_from_span(cx, span); @@ -455,7 +455,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, let mdval = @{node: llnode, data: {hash: ty::type_id(outer)}}; //update_cache(cache, tg, tydesc_metadata(mdval)); add_named_metadata(cx, ~"llvm.dbg.ty", llnode); - ret mdval; + return mdval; } fn create_composite_type(type_tag: int, name: ~str, file: ValueRef, line: int, @@ -485,7 +485,7 @@ fn create_composite_type(type_tag: int, name: ~str, file: ValueRef, line: int, lli32(0), // runtime language llnull() ]; - ret llmdnode(lldata); + return llmdnode(lldata); } fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, @@ -510,7 +510,7 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, add_member(scx, ~"data", 0, 0, // clang says the size should be 0 sys::min_align_of::<u8>() as int, data_ptr); let llnode = finish_structure(scx); - ret @{node: llnode, data: {hash: ty::type_id(vec_t)}}; + return @{node: llnode, data: {hash: ty::type_id(vec_t)}}; } fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) @@ -518,7 +518,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) /*let cache = get_cache(cx); alt cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| t == md.data.hash}) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} }*/ @@ -563,7 +563,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) cx.sess.span_bug(span, "t_to_ty: Can't handle this type"); } }; - ret @{node: ty, span: span}; + return @{node: ty, span: span}; } alt ty.node { @@ -574,7 +574,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) }; let md = create_ty(cx, inner_t, mt.ty); let box = create_boxed_type(cx, t, inner_t, ty.span, md); - ret create_pointer_type(cx, t, ty.span, box); + return create_pointer_type(cx, t, ty.span, box); } ast::ty_uniq(mt) { @@ -584,29 +584,29 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); } }; let md = create_ty(cx, inner_t, mt.ty); - ret create_pointer_type(cx, t, ty.span, md); + return create_pointer_type(cx, t, ty.span, md); } ast::ty_infer { let inferred = t_to_ty(cx, t, ty.span); - ret create_ty(cx, t, inferred); + return create_ty(cx, t, inferred); } ast::ty_rec(fields) { - ret create_record(cx, t, fields, ty.span); + return create_record(cx, t, fields, ty.span); } ast::ty_vec(mt) { let inner_t = ty::sequence_element_type(cx.tcx, t); let inner_ast_t = t_to_ty(cx, inner_t, mt.ty.span); let v = create_vec(cx, t, inner_t, ty.span, inner_ast_t); - ret create_pointer_type(cx, t, ty.span, v); + return create_pointer_type(cx, t, ty.span, v); } ast::ty_path(_, id) { alt cx.tcx.def_map.get(id) { ast::def_prim_ty(pty) { - ret create_basic_type(cx, t, pty, ty.span); + return create_basic_type(cx, t, pty, ty.span); } _ {} } @@ -631,7 +631,7 @@ fn create_var(type_tag: int, context: ValueRef, name: ~str, file: ValueRef, ret_ty, lli32(0) ]; - ret llmdnode(lldata); + return llmdnode(lldata); } fn create_local_var(bcx: block, local: @ast::local) @@ -641,7 +641,7 @@ fn create_local_var(bcx: block, local: @ast::local) let tg = AutoVariableTag; alt cached_metadata::<@metadata<local_var_md>>( cache, tg, |md| md.data.id == local.node.id) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} } @@ -681,7 +681,7 @@ fn create_local_var(bcx: block, local: @ast::local) let declargs = ~[llmdnode(~[llptr]), mdnode]; trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"), declargs); - ret mdval; + return mdval; } fn create_arg(bcx: block, arg: ast::arg, sp: span) @@ -691,7 +691,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let tg = ArgVariableTag; alt cached_metadata::<@metadata<argument_md>>( cache, ArgVariableTag, |md| md.data.id == arg.id) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} } @@ -712,12 +712,12 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let declargs = ~[llmdnode(~[llptr]), mdnode]; trans::build::Call(bcx, cx.intrinsics.get(~"llvm.dbg.declare"), declargs); - ret mdval; + return mdval; } fn update_source_pos(cx: block, s: span) { if !cx.sess().opts.debuginfo { - ret; + return; } let cm = cx.sess().codemap; let blockmd = create_block(cx); @@ -779,7 +779,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { let cache = get_cache(cx); alt cached_metadata::<@metadata<subprogram_md>>( cache, SubprogramTag, |md| md.data.id == id) { - option::some(md) { ret md; } + option::some(md) { return md; } option::none {} } @@ -824,5 +824,5 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { let mdval = @{node: val, data: {id: id}}; update_cache(cache, SubprogramTag, subprogram_metadata(mdval)); - ret mdval; + return mdval; } diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 5313cee2323..129e737bb29 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 { - ret alt c { + return alt c { sse_fs_class | sse_fv_class | sse_ds_class | sse_dv_class { true } _ { false } @@ -47,7 +47,7 @@ fn is_sse(++c: x86_64_reg_class) -> bool { fn is_ymm(cls: ~[x86_64_reg_class]) -> bool { let len = vec::len(cls); - ret (len > 2u && + return (len > 2u && is_sse(cls[0]) && cls[1] == sseup_class && cls[2] == sseup_class) || @@ -60,7 +60,7 @@ fn is_ymm(cls: ~[x86_64_reg_class]) -> bool { fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { fn align(off: uint, ty: TypeRef) -> uint { let a = ty_align(ty); - ret (off + a - 1u) / a * a; + return (off + a - 1u) / a * a; } fn struct_tys(ty: TypeRef) -> ~[TypeRef] { @@ -69,11 +69,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { do vec::as_buf(elts) |buf, _len| { llvm::LLVMGetStructElementTypes(ty, buf); } - ret elts; + return elts; } fn ty_align(ty: TypeRef) -> uint { - ret alt llvm::LLVMGetTypeKind(ty) as int { + return alt llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ { ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u } @@ -96,7 +96,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_size(ty: TypeRef) -> uint { - ret alt llvm::LLVMGetTypeKind(ty) as int { + return alt llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ { ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u } @@ -130,11 +130,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { i: uint, newv: x86_64_reg_class) { if cls[i] == newv { - ret; + return; } else if cls[i] == no_class { cls[i] = newv; } else if newv == no_class { - ret; + return; } else if cls[i] == memory_class || newv == memory_class { cls[i] = memory_class; } else if cls[i] == integer_class || newv == integer_class { @@ -180,7 +180,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { unify(cls, ix + i, memory_class); i += 1u; } - ret; + return; } alt llvm::LLVMGetTypeKind(ty) as int { @@ -229,25 +229,25 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { while i < e { if cls[i] != sseup_class { all_mem(cls); - ret; + return; } i += 1u; } } else { all_mem(cls); - ret + return } } else { while i < e { if cls[i] == memory_class { all_mem(cls); - ret; + return; } if cls[i] == x87up_class { // for darwin // cls[i] = sse_ds_class; all_mem(cls); - ret; + return; } if cls[i] == sseup_class { cls[i] = sse_int_class; @@ -268,11 +268,11 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { let cls = vec::to_mut(vec::from_elem(words, no_class)); if words > 4u { all_mem(cls); - ret vec::from_mut(cls); + return vec::from_mut(cls); } classify(ty, cls, 0u, 0u); fixup(ty, cls); - ret vec::from_mut(cls); + return vec::from_mut(cls); } fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { @@ -284,7 +284,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { } len += 1u; } - ret len; + return len; } let mut tys = ~[]; @@ -315,7 +315,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { } i += 1u; } - ret T_struct(tys); + return T_struct(tys); } type x86_64_llty = { @@ -334,7 +334,7 @@ fn x86_64_tys(atys: ~[TypeRef], rty: TypeRef, ret_def: bool) -> x86_64_tys { fn is_reg_ty(ty: TypeRef) -> bool { - ret alt llvm::LLVMGetTypeKind(ty) as int { + return alt llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ | 12 /* pointer */ | 2 /* float */ | @@ -344,13 +344,13 @@ fn x86_64_tys(atys: ~[TypeRef], } fn is_pass_byval(cls: ~[x86_64_reg_class]) -> bool { - ret cls[0] == memory_class || + return cls[0] == memory_class || cls[0] == x87_class || cls[0] == complex_x87_class; } fn is_ret_bysret(cls: ~[x86_64_reg_class]) -> bool { - ret cls[0] == memory_class; + return cls[0] == memory_class; } fn x86_64_ty(ty: TypeRef, @@ -369,7 +369,7 @@ fn x86_64_tys(atys: ~[TypeRef], llty = llreg_ty(cls); } } - ret ({ cast: cast, ty: llty }, ty_attr); + return ({ cast: cast, ty: llty }, ty_attr); } let mut arg_tys = ~[]; @@ -393,7 +393,7 @@ fn x86_64_tys(atys: ~[TypeRef], ty: T_void() }; } - ret { + return { arg_tys: arg_tys, ret_ty: ret_ty, attrs: attrs, @@ -417,13 +417,13 @@ fn decl_x86_64_fn(tys: x86_64_tys, _ {} } } - ret llfn; + return llfn; } fn link_name(i: @ast::foreign_item) -> ~str { alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { - none { ret *i.ident; } - option::some(ln) { ret *ln; } + none { return *i.ident; } + option::some(ln) { return *ln; } } } @@ -458,7 +458,7 @@ fn c_stack_tys(ccx: @crate_ctxt, } else { option::none }; - ret @{ + return @{ arg_tys: llargtys, ret_ty: llretty, ret_def: ret_def, @@ -501,7 +501,7 @@ fn build_shim_fn_(ccx: @crate_ctxt, build_return(bcx); finish_fn(fcx, lltop); - ret llshimfn; + return llshimfn; } type wrap_arg_builder = fn(bcx: block, tys: @c_stack_tys, @@ -631,7 +631,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, } } } - ret llargvals; + return llargvals; } fn build_ret(bcx: block, tys: @c_stack_tys, @@ -650,7 +650,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, } } if x86_64.sret || !tys.ret_def { - ret; + return; } let n = vec::len(tys.arg_tys); let llretptr = GEPi(bcx, llargbundle, ~[0u, n]); @@ -681,7 +681,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let llbasefn = base_fn(ccx, lname, tys, cc); // Name the shim function let shim_name = lname + ~"__c_stack_shim"; - ret build_shim_fn_(ccx, shim_name, llbasefn, tys, cc, + return build_shim_fn_(ccx, shim_name, llbasefn, tys, cc, build_args, build_ret); } @@ -734,7 +734,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let _icx = bcx.insn_ctxt(~"foreign::wrap::build_args"); let mut i = 0u; let n = vec::len(tys.arg_tys); - let implicit_args = first_real_arg; // ret + env + let implicit_args = first_real_arg; // return + env while i < n { let llargval = get_param(llwrapfn, i + implicit_args); store_inbounds(bcx, llargval, llargbundle, ~[0u, i]); @@ -1005,7 +1005,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let llty = type_of_fn_from_ty(ccx, t); let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty); trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id); - ret llfndecl; + return llfndecl; } fn build_shim_fn(ccx: @crate_ctxt, path: ast_map::path, @@ -1028,7 +1028,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, vec::push(llargvals, llargval); i += 1u; } - ret llargvals; + return llargvals; } fn build_ret(_bcx: block, _tys: @c_stack_tys, @@ -1040,7 +1040,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, let shim_name = link::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name(@~"__rust_stack_shim"))); - ret build_shim_fn_(ccx, shim_name, llrustfn, tys, + return build_shim_fn_(ccx, shim_name, llrustfn, tys, lib::llvm::CCallConv, build_args, build_ret); } @@ -1111,7 +1111,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, option::some(x86_64) { if x86_64.sret || !tys.ret_def { RetVoid(bcx); - ret; + return; } let n = vec::len(tys.arg_tys); let llretval = load_inbounds(bcx, llargbundle, ~[0u, n]); @@ -1153,7 +1153,7 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span, let _icx = ccx.insn_ctxt(~"foreign::register_foreign_fn"); let t = ty::node_id_to_type(ccx.tcx, node_id); let (llargtys, llretty, ret_ty) = c_arg_and_ret_lltys(ccx, node_id); - ret if ccx.sess.targ_cfg.arch == arch_x86_64 { + return if ccx.sess.targ_cfg.arch == arch_x86_64 { let ret_def = !ty::type_is_bot(ret_ty) && !ty::type_is_nil(ret_ty); let x86_64 = x86_64_tys(llargtys, llretty, ret_def); do decl_x86_64_fn(x86_64) |fnty| { diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index b42dce15fd5..6f254f867f6 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -18,7 +18,7 @@ import std::map::hashmap; fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident, methods: ~[@ast::method], tps: ~[ast::ty_param]) { let _icx = ccx.insn_ctxt(~"impl::trans_impl"); - if tps.len() > 0u { ret; } + if tps.len() > 0u { return; } let sub_path = vec::append_one(path, path_name(name)); for vec::each(methods) |m| { if m.tps.len() == 0u { @@ -45,7 +45,7 @@ fn trans_self_arg(bcx: block, base: @ast::expr, derefs: uint) -> result { // other arguments failing: assert temp_cleanups == ~[]; - ret result; + return result; } fn trans_method_callee(bcx: block, callee_id: ast::node_id, @@ -285,7 +285,7 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t], fn trans_cast(bcx: block, val: @ast::expr, id: ast::node_id, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"impl::trans_cast"); - if dest == ignore { ret trans_expr(bcx, val, ignore); } + if dest == ignore { return trans_expr(bcx, val, ignore); } let ccx = bcx.ccx(); let v_ty = expr_ty(bcx, val); let {bcx: bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty); diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 0250b17f6fe..a1db7e7b4bd 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -59,9 +59,9 @@ fn traverse_export(cx: ctx, exp_id: node_id) { } fn traverse_def_id(cx: ctx, did: def_id) { - if did.crate != local_crate { ret; } + if did.crate != local_crate { return; } let n = alt cx.tcx.items.find(did.node) { - none { ret; } // This can happen for self, for example + none { return; } // This can happen for self, for example some(n) { n } }; alt n { @@ -85,7 +85,7 @@ fn traverse_public_mod(cx: ctx, m: _mod) { } fn traverse_public_item(cx: ctx, item: @item) { - if cx.rmap.contains_key(item.id) { ret; } + if cx.rmap.contains_key(item.id) { return; } cx.rmap.insert(item.id, ()); alt item.node { item_mod(m) { traverse_public_mod(cx, m); } @@ -151,7 +151,7 @@ fn mk_ty_visitor() -> visit::vt<ctx> { } fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) { - if cx.rmap.contains_key(ty.id) { ret; } + if cx.rmap.contains_key(ty.id) { return; } cx.rmap.insert(ty.id, ()); alt ty.node { diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 82cb96f660d..5b833a91538 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -37,7 +37,7 @@ impl methods for reflector { let tr = type_of::type_of(self.bcx.ccx(), t); let s = shape::llsize_of_real(self.bcx.ccx(), tr); let a = shape::llalign_of_min(self.bcx.ccx(), tr); - ret ~[self.c_uint(s), + return ~[self.c_uint(s), self.c_uint(a)]; } @@ -306,5 +306,5 @@ fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t, }); r.visit_ty(t); Br(r.bcx, final.llbb); - ret final; + return final; } diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 152e6bfe0c3..33c2323b290 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -43,7 +43,7 @@ fn hash_nominal_id(&&ri: nominal_id) -> uint { h *= 33u; h += ty::type_id(t); } - ret h; + return h; } fn eq_nominal_id(&&mi: nominal_id, &&ni: nominal_id) -> bool { @@ -57,7 +57,7 @@ fn eq_nominal_id(&&mi: nominal_id, &&ni: nominal_id) -> bool { } fn new_nominal_id_hash<T: copy>() -> hashmap<nominal_id, T> { - ret hashmap(hash_nominal_id, eq_nominal_id); + return hashmap(hash_nominal_id, eq_nominal_id); } type enum_data = {did: ast::def_id, substs: ty::substs}; @@ -113,7 +113,7 @@ fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) -> lib::llvm::SetLinkage(llglobal, lib::llvm::InternalLinkage); } - ret llglobal; + return llglobal; } @@ -124,7 +124,7 @@ fn mk_global(ccx: @crate_ctxt, name: ~str, llval: ValueRef, internal: bool) -> fn round_up(size: u16, align: u8) -> u16 { assert (align >= 1u8); let alignment = align as u16; - ret size - 1u16 + alignment & !(alignment - 1u16); + return size - 1u16 + alignment & !(alignment - 1u16); } type size_align = {size: u16, align: u8}; @@ -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 { - ret alt tcx.sess.targ_cfg.arch { + return alt 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 { - ret alt tcx.sess.targ_cfg.arch { + return alt 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 { - ret alt tcx.sess.targ_cfg.arch { + return alt tcx.sess.targ_cfg.arch { session::arch_x86 { shape_f64 } session::arch_x86_64 { shape_f64 } session::arch_arm { shape_f64 } @@ -173,15 +173,15 @@ fn s_float(tcx: ty_ctxt) -> u8 { } fn s_variant_enum_t(tcx: ty_ctxt) -> u8 { - ret s_int(tcx); + return s_int(tcx); } fn s_tydesc(_tcx: ty_ctxt) -> u8 { - ret shape_tydesc; + return shape_tydesc; } fn s_send_tydesc(_tcx: ty_ctxt) -> u8 { - ret shape_send_tydesc; + return shape_send_tydesc; } fn mk_ctxt(llmod: ModuleRef) -> ctxt { @@ -190,7 +190,7 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt { lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf) }); - ret {mut next_tag_id: 0u16, + return {mut next_tag_id: 0u16, pad: 0u16, tag_id_to_index: new_nominal_id_hash(), tag_order: dvec(), @@ -367,7 +367,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> ~[u8] { let mut s = ~[]; for vec::each(v.args) |t| { s += shape_of(ccx, t); } - ret s; + return s; } fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { @@ -456,7 +456,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { header += data; header += lv_table; - ret mk_global(ccx, ~"tag_shapes", C_bytes(header), true); + return mk_global(ccx, ~"tag_shapes", C_bytes(header), true); /* tjc: Not annotating FIXMEs in this module because of #1498 */ fn largest_variants(ccx: @crate_ctxt, @@ -530,7 +530,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { if candidates[i] { vec::push(result, i); } i += 1u; } - ret result; + return result; } fn compute_static_enum_size(ccx: @crate_ctxt, largest_variants: ~[uint], @@ -563,7 +563,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef { if max_align < align { max_align = align; } } - ret {size: max_size, align: max_align}; + return {size: max_size, align: max_align}; } } @@ -577,7 +577,7 @@ fn gen_resource_shapes(ccx: @crate_ctxt) -> ValueRef { dtors += ~[trans::base::get_res_dtor(ccx, ri.did, id, ri.tps)]; } } - ret mk_global(ccx, ~"resource_shapes", C_struct(dtors), true); + return mk_global(ccx, ~"resource_shapes", C_struct(dtors), true); } fn gen_shape_tables(ccx: @crate_ctxt) { @@ -614,13 +614,13 @@ type tag_metrics = { // Returns the number of bytes clobbered by a Store to this type. fn llsize_of_store(cx: @crate_ctxt, t: TypeRef) -> uint { - ret llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint; + return llvm::LLVMStoreSizeOfType(cx.td.lltd, t) as uint; } // Returns the number of bytes between successive elements of type T in an // array of T. This is the "ABI" size. It includes any ABI-mandated padding. fn llsize_of_alloc(cx: @crate_ctxt, t: TypeRef) -> uint { - ret llvm::LLVMABISizeOfType(cx.td.lltd, t) as uint; + return llvm::LLVMABISizeOfType(cx.td.lltd, t) as uint; } // Returns, as near as we can figure, the "real" size of a type. As in, the @@ -644,7 +644,7 @@ fn llsize_of_real(cx: @crate_ctxt, t: TypeRef) -> uint { // (i.e. including alignment-padding), but goodness knows which alignment it // winds up using. Probably the ABI one? Not recommended. fn llsize_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { - ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t), cx.int_type, + return llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMSizeOf(t), cx.int_type, False); } @@ -653,22 +653,22 @@ fn llsize_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // packing the type into structs. This will be used for things like // allocations inside a stack frame, which LLVM has a free hand in. fn llalign_of_pref(cx: @crate_ctxt, t: TypeRef) -> uint { - ret llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint; + return llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, t) as uint; } // Returns the minimum alignment of a type required by the plattform. // This is the alignment that will be used for struct fields, arrays, // and similar ABI-mandated things. fn llalign_of_min(cx: @crate_ctxt, t: TypeRef) -> uint { - ret llvm::LLVMABIAlignmentOfType(cx.td.lltd, t) as uint; + return llvm::LLVMABIAlignmentOfType(cx.td.lltd, t) as uint; } // Returns the "default" alignment of t, which is calculated by casting // null to a record containing a single-bit followed by a t value, then // doing gep(0,1) to get at the trailing (and presumably padded) t cell. fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { - ret llvm::LLVMConstIntCast(lib::llvm::llvm::LLVMAlignOf(t), cx.int_type, - False); + return llvm::LLVMConstIntCast( + lib::llvm::llvm::LLVMAlignOf(t), cx.int_type, False); } // Computes the static size of a enum, without using mk_tup(), which is @@ -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) { ret cx.enum_sizes.get(t); } + if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); } alt ty::get(t).struct { ty::ty_enum(tid, substs) { // Compute max(variant sizes). @@ -695,7 +695,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { if max_size < this_size { max_size = this_size; } } cx.enum_sizes.insert(t, max_size); - ret max_size; + return max_size; } _ { cx.sess.bug(~"static_size_of_enum called on non-enum"); } } diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index bfd2f18bac9..213117f15f4 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -57,7 +57,7 @@ fn pointer_add(bcx: block, ptr: ValueRef, bytes: ValueRef) -> ValueRef { let _icx = bcx.insn_ctxt(~"tvec::pointer_add"); let old_ty = val_ty(ptr); let bptr = PointerCast(bcx, ptr, T_ptr(T_i8())); - ret PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty); + return PointerCast(bcx, InBoundsGEP(bcx, bptr, ~[bytes]), old_ty); } fn alloc_raw(bcx: block, unit_ty: ty::t, @@ -72,7 +72,7 @@ fn alloc_raw(bcx: block, unit_ty: ty::t, base::malloc_general_dyn(bcx, vecbodyty, heap, vecsize); Store(bcx, fill, GEPi(bcx, body, ~[0u, abi::vec_elt_fill])); Store(bcx, alloc, GEPi(bcx, body, ~[0u, abi::vec_elt_alloc])); - ret {bcx: bcx, val: box}; + return {bcx: bcx, val: box}; } fn alloc_uniq_raw(bcx: block, unit_ty: ty::t, fill: ValueRef, alloc: ValueRef) -> result { @@ -89,7 +89,7 @@ fn alloc_vec(bcx: block, unit_ty: ty::t, elts: uint, heap: heap) -> result { let alloc = if elts < 4u { Mul(bcx, C_int(ccx, 4), unit_sz) } else { fill }; let {bcx: bcx, val: vptr} = alloc_raw(bcx, unit_ty, fill, alloc, heap); - ret {bcx: bcx, val: vptr}; + return {bcx: bcx, val: vptr}; } fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { @@ -106,7 +106,7 @@ fn duplicate_uniq(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> result { let bcx = if ty::type_needs_drop(bcx.tcx(), unit_ty) { iter_vec_raw(bcx, new_data_ptr, vec_ty, fill, base::take_ty) } else { bcx }; - ret rslt(bcx, newptr); + return rslt(bcx, newptr); } fn make_drop_glue_unboxed(bcx: block, vptr: ValueRef, vec_ty: ty::t) -> @@ -127,7 +127,7 @@ fn trans_evec(bcx: block, args: ~[@ast::expr], for vec::each(args) |arg| { bcx = base::trans_expr(bcx, arg, base::ignore); } - ret bcx; + return bcx; } let vec_ty = node_id_type(bcx, id); @@ -205,13 +205,13 @@ fn trans_evec(bcx: block, args: ~[@ast::expr], alt vst { ast::vstore_fixed(_) { // We wrote into the destination in the fixed case. - ret bcx; + return bcx; } ast::vstore_slice(_) { - ret base::store_in_dest(bcx, Load(bcx, val), dest); + return base::store_in_dest(bcx, Load(bcx, val), dest); } _ { - ret base::store_in_dest(bcx, val, dest); + return base::store_in_dest(bcx, val, dest); } } } @@ -220,10 +220,10 @@ fn trans_vstore(bcx: block, e: @ast::expr, v: ast::vstore, dest: dest) -> block { alt e.node { ast::expr_lit(@{node: ast::lit_str(s), span: _}) { - ret trans_estr(bcx, s, v, dest); + return trans_estr(bcx, s, v, dest); } ast::expr_vec(es, mutbl) { - ret trans_evec(bcx, es, v, e.id, dest); + return trans_evec(bcx, es, v, e.id, dest); } _ { bcx.sess().span_bug(e.span, ~"vstore on non-sequence type"); @@ -269,7 +269,7 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) fn trans_estr(bcx: block, s: @~str, vstore: ast::vstore, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"tvec::trans_estr"); - if dest == base::ignore { ret bcx; } + if dest == base::ignore { return bcx; } let ccx = bcx.ccx(); let c = alt vstore { @@ -338,7 +338,7 @@ fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, ~[C_int(bcx.ccx(), 1)]), body_cx.llbb); Br(body_cx, header_cx.llbb); - ret next_cx; + return next_cx; } @@ -354,7 +354,7 @@ fn iter_vec_unboxed(bcx: block, body_ptr: ValueRef, vec_ty: ty::t, let _icx = bcx.insn_ctxt(~"tvec::iter_vec_unboxed"); let fill = get_fill(bcx, body_ptr); let dataptr = get_dataptr(bcx, body_ptr); - ret iter_vec_raw(bcx, dataptr, vec_ty, fill, f); + return iter_vec_raw(bcx, dataptr, vec_ty, fill, f); } // diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index d06bf94f5e1..79cd20bb36e 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -36,7 +36,7 @@ fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg], // ... then explicit args. vec::push_all(atys, type_of_explicit_args(cx, inputs)); - ret T_fn(atys, llvm::LLVMVoidType()); + return T_fn(atys, llvm::LLVMVoidType()); } // Given a function type and a count of ty params, construct an llvm type @@ -69,7 +69,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { debug!{"type_of %?: %?", t, ty::get(t)}; // Check the cache. - if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); } + if cx.lltypes.contains_key(t) { return cx.lltypes.get(t); } // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain @@ -188,7 +188,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { } }; - ret llty; + return llty; } // This should only be called from type_of, above, because it @@ -221,7 +221,7 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) }; common::set_struct_body(named_llty, lltys); - ret named_llty; + return named_llty; } fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { @@ -233,7 +233,7 @@ fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { (~"class", did, substs.tps) } }; - ret fmt!{ + return fmt!{ "%s %s[#%d]", name, util::ppaux::parameterized( diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 8ab6fbfc6eb..486ea2da835 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -36,7 +36,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) { - some(uses) { ret uses; } + some(uses) { return uses; } none {} } let fn_id_loc = if fn_id.crate == local_crate { fn_id } @@ -57,7 +57,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) if fn_id_loc.crate != local_crate { let uses = vec::from_mut(copy cx.uses); ccx.type_use_cache.insert(fn_id, uses); - ret uses; + return uses; } let map_node = alt ccx.tcx.items.find(fn_id_loc.node) { some(x) { x } diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index 27379552a8c..e51d4e4d454 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -28,7 +28,7 @@ fn content_ty(t: ty::t) -> ty::t { fn autoderef(bcx: block, v: ValueRef, t: ty::t) -> {v: ValueRef, t: ty::t} { let content_ty = content_ty(t); let v = opaque_box_body(bcx, content_ty, v); - ret {v: v, t: content_ty}; + return {v: v, t: content_ty}; } fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { @@ -52,5 +52,5 @@ fn duplicate(bcx: block, v: ValueRef, t: ty::t) -> result { let td = Load(bcx, src_tydesc_ptr); Store(bcx, td, dst_tydesc_ptr); - ret rslt(bcx, dst_box); + return rslt(bcx, dst_box); } diff --git a/src/rustc/middle/tstate/ann.rs b/src/rustc/middle/tstate/ann.rs index 7729c3ffc1d..cbd255341f5 100644 --- a/src/rustc/middle/tstate/ann.rs +++ b/src/rustc/middle/tstate/ann.rs @@ -41,14 +41,18 @@ type pre_and_post_state = {prestate: prestate, poststate: poststate}; type ts_ann = {conditions: pre_and_post, states: pre_and_post_state}; -fn true_precond(num_vars: uint) -> precond { ret create_tritv(num_vars); } +fn true_precond(num_vars: uint) -> precond { return create_tritv(num_vars); } -fn true_postcond(num_vars: uint) -> postcond { ret true_precond(num_vars); } +fn true_postcond(num_vars: uint) -> postcond { + return true_precond(num_vars); +} -fn empty_prestate(num_vars: uint) -> prestate { ret true_precond(num_vars); } +fn empty_prestate(num_vars: uint) -> prestate { + return true_precond(num_vars); +} fn empty_poststate(num_vars: uint) -> poststate { - ret true_precond(num_vars); + return true_precond(num_vars); } fn false_postcond(num_vars: uint) -> postcond { @@ -58,23 +62,23 @@ fn false_postcond(num_vars: uint) -> postcond { } fn empty_pre_post(num_vars: uint) -> pre_and_post { - ret {precondition: empty_prestate(num_vars), + return {precondition: empty_prestate(num_vars), postcondition: empty_poststate(num_vars)}; } fn empty_states(num_vars: uint) -> pre_and_post_state { - ret {prestate: true_precond(num_vars), + return {prestate: true_precond(num_vars), poststate: true_postcond(num_vars)}; } fn empty_ann(num_vars: uint) -> ts_ann { - ret {conditions: empty_pre_post(num_vars), + return {conditions: empty_pre_post(num_vars), states: empty_states(num_vars)}; } -fn get_pre(&&p: pre_and_post) -> precond { ret p.precondition; } +fn get_pre(&&p: pre_and_post) -> precond { return p.precondition; } -fn get_post(&&p: pre_and_post) -> postcond { ret p.postcondition; } +fn get_post(&&p: pre_and_post) -> postcond { return p.postcondition; } fn difference(p1: precond, p2: precond) -> bool { p1.difference(p2) } @@ -86,7 +90,7 @@ fn pps_len(p: pre_and_post) -> uint { // gratuitous check assert (p.precondition.nbits == p.postcondition.nbits); - ret p.precondition.nbits; + return p.precondition.nbits; } fn require(i: uint, p: pre_and_post) { @@ -102,54 +106,54 @@ fn require_and_preserve(i: uint, p: pre_and_post) { fn set_in_postcond(i: uint, p: pre_and_post) -> bool { // sets the ith bit in p's post - ret set_in_postcond_(i, p.postcondition); + return set_in_postcond_(i, p.postcondition); } fn set_in_postcond_(i: uint, p: postcond) -> bool { let was_set = p.get(i); p.set(i, ttrue); - ret was_set != ttrue; + return was_set != ttrue; } fn set_in_poststate(i: uint, s: pre_and_post_state) -> bool { // sets the ith bit in p's post - ret set_in_poststate_(i, s.poststate); + return set_in_poststate_(i, s.poststate); } fn set_in_poststate_(i: uint, p: poststate) -> bool { let was_set = p.get(i); p.set(i, ttrue); - ret was_set != ttrue; + return was_set != ttrue; } fn clear_in_poststate(i: uint, s: pre_and_post_state) -> bool { // sets the ith bit in p's post - ret clear_in_poststate_(i, s.poststate); + return clear_in_poststate_(i, s.poststate); } fn clear_in_poststate_(i: uint, s: poststate) -> bool { let was_set = s.get(i); s.set(i, tfalse); - ret was_set != tfalse; + return was_set != tfalse; } fn clear_in_prestate(i: uint, s: pre_and_post_state) -> bool { // sets the ith bit in p's pre - ret clear_in_prestate_(i, s.prestate); + return clear_in_prestate_(i, s.prestate); } fn clear_in_prestate_(i: uint, s: prestate) -> bool { let was_set = s.get(i); s.set(i, tfalse); - ret was_set != tfalse; + return was_set != tfalse; } fn clear_in_postcond(i: uint, s: pre_and_post) -> bool { // sets the ith bit in p's post let was_set = s.postcondition.get(i); s.postcondition.set(i, tfalse); - ret was_set != tfalse; + return was_set != tfalse; } // Sets all the bits in a's precondition to equal the @@ -195,12 +199,12 @@ fn extend_poststate(p: poststate, newv: poststate) -> bool { fn relax_prestate(i: uint, p: prestate) -> bool { let was_set = p.get(i); p.set(i, dont_care); - ret was_set != dont_care; + return was_set != dont_care; } // Clears the given bit in p fn relax_poststate(i: uint, p: poststate) -> bool { - ret relax_prestate(i, p); + return relax_prestate(i, p); } // Clears the given bit in p @@ -212,14 +216,14 @@ fn clear(p: precond) { p.clear(); } // Sets all the bits in p to true fn set(p: precond) { p.set_all(); } -fn ann_precond(a: ts_ann) -> precond { ret a.conditions.precondition; } +fn ann_precond(a: ts_ann) -> precond { return a.conditions.precondition; } -fn ann_prestate(a: ts_ann) -> prestate { ret a.states.prestate; } +fn ann_prestate(a: ts_ann) -> prestate { return a.states.prestate; } -fn ann_poststate(a: ts_ann) -> poststate { ret a.states.poststate; } +fn ann_poststate(a: ts_ann) -> poststate { return a.states.poststate; } fn pp_clone(p: pre_and_post) -> pre_and_post { - ret {precondition: clone(p.precondition), + return {precondition: clone(p.precondition), postcondition: clone(p.postcondition)}; } diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index 0f8185a0ee9..aa249fc3604 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -31,7 +31,7 @@ enum oper_type { /* logging funs */ fn def_id_to_str(d: def_id) -> ~str { - ret int::str(d.crate) + ~"," + int::str(d.node); + return int::str(d.crate) + ~"," + int::str(d.node); } fn comma_str(args: ~[@constr_arg_use]) -> ~str { @@ -45,11 +45,11 @@ fn comma_str(args: ~[@constr_arg_use]) -> ~str { carg_lit(l) { rslt += lit_to_str(l); } } } - ret rslt; + return rslt; } fn constraint_to_str(tcx: ty::ctxt, c: sp_constr) -> ~str { - ret fmt!{"%s(%s) - arising from %s", + return fmt!{"%s(%s) - arising from %s", path_to_str(c.node.path), comma_str(c.node.args), codemap::span_to_str(c.span, tcx.sess.codemap)}; @@ -69,7 +69,7 @@ fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str { } } } - ret s; + return s; } fn log_tritv(fcx: fn_ctxt, v: tritv::t) { @@ -86,7 +86,7 @@ fn first_difference_string(fcx: fn_ctxt, expected: tritv::t, actual: tritv::t) break; } } - ret s; + return s; } fn log_tritv_err(fcx: fn_ctxt, v: tritv::t) { @@ -100,7 +100,7 @@ fn tos(v: ~[uint]) -> ~str { rslt += ~"0"; } else if i == 1u { rslt += ~"1"; } else { rslt += ~"?"; } } - ret rslt; + return rslt; } fn log_cond(v: ~[uint]) { log(debug, tos(v)); } @@ -146,7 +146,7 @@ fn log_states_err(pp: pre_and_post_state) { fn print_ident(i: ident) { log(debug, ~" " + *i + ~" "); } fn print_idents(&idents: ~[ident]) { - if vec::len::<ident>(idents) == 0u { ret; } + if vec::len::<ident>(idents) == 0u { return; } log(debug, ~"an ident: " + *vec::pop::<ident>(idents)); print_idents(idents); } @@ -241,7 +241,7 @@ type crate_ctxt = {tcx: ty::ctxt, node_anns: node_ann_table, fm: fn_info_map}; fn get_fn_info(ccx: crate_ctxt, id: node_id) -> fn_info { assert (ccx.fm.contains_key(id)); - ret ccx.fm.get(id); + return ccx.fm.get(id); } fn add_node(ccx: crate_ctxt, i: node_id, a: ts_ann) { @@ -254,8 +254,8 @@ fn add_node(ccx: crate_ctxt, i: node_id, a: ts_ann) { fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option<ts_ann> { if i as uint < vec::len(*ccx.node_anns) { - ret some::<ts_ann>(ccx.node_anns[i]); - } else { ret none::<ts_ann>; } + return some::<ts_ann>(ccx.node_anns[i]); + } else { return none::<ts_ann>; } } @@ -266,20 +266,20 @@ fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann { error!{"node_id_to_ts_ann: no ts_ann for node_id %d", id}; fail; } - some(tt) { ret tt; } + some(tt) { return tt; } } } fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate { debug!{"node_id_to_poststate"}; - ret node_id_to_ts_ann(ccx, id).states.poststate; + return node_id_to_ts_ann(ccx, id).states.poststate; } fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { debug!{"stmt_to_ann"}; alt s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { - ret node_id_to_ts_ann(ccx, id); + return node_id_to_ts_ann(ccx, id); } } } @@ -288,25 +288,25 @@ fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { /* fails if e has no annotation */ fn expr_states(ccx: crate_ctxt, e: @expr) -> pre_and_post_state { debug!{"expr_states"}; - ret node_id_to_ts_ann(ccx, e.id).states; + return node_id_to_ts_ann(ccx, e.id).states; } /* fails if e has no annotation */ fn expr_pp(ccx: crate_ctxt, e: @expr) -> pre_and_post { debug!{"expr_pp"}; - ret node_id_to_ts_ann(ccx, e.id).conditions; + return node_id_to_ts_ann(ccx, e.id).conditions; } fn stmt_pp(ccx: crate_ctxt, s: stmt) -> pre_and_post { - ret stmt_to_ann(ccx, s).conditions; + return stmt_to_ann(ccx, s).conditions; } /* fails if b has no annotation */ fn block_pp(ccx: crate_ctxt, b: blk) -> pre_and_post { debug!{"block_pp"}; - ret node_id_to_ts_ann(ccx, b.node.id).conditions; + return node_id_to_ts_ann(ccx, b.node.id).conditions; } fn clear_pp(pp: pre_and_post) { @@ -321,84 +321,85 @@ fn clear_precond(ccx: crate_ctxt, id: node_id) { fn block_states(ccx: crate_ctxt, b: blk) -> pre_and_post_state { debug!{"block_states"}; - ret node_id_to_ts_ann(ccx, b.node.id).states; + return node_id_to_ts_ann(ccx, b.node.id).states; } fn stmt_states(ccx: crate_ctxt, s: stmt) -> pre_and_post_state { - ret stmt_to_ann(ccx, s).states; + return stmt_to_ann(ccx, s).states; } fn expr_precond(ccx: crate_ctxt, e: @expr) -> precond { - ret expr_pp(ccx, e).precondition; + return expr_pp(ccx, e).precondition; } fn expr_postcond(ccx: crate_ctxt, e: @expr) -> postcond { - ret expr_pp(ccx, e).postcondition; + return expr_pp(ccx, e).postcondition; } fn expr_prestate(ccx: crate_ctxt, e: @expr) -> prestate { - ret expr_states(ccx, e).prestate; + return expr_states(ccx, e).prestate; } fn expr_poststate(ccx: crate_ctxt, e: @expr) -> poststate { - ret expr_states(ccx, e).poststate; + return expr_states(ccx, e).poststate; } fn stmt_precond(ccx: crate_ctxt, s: stmt) -> precond { - ret stmt_pp(ccx, s).precondition; + return stmt_pp(ccx, s).precondition; } fn stmt_postcond(ccx: crate_ctxt, s: stmt) -> postcond { - ret stmt_pp(ccx, s).postcondition; + return stmt_pp(ccx, s).postcondition; } fn states_to_poststate(ss: pre_and_post_state) -> poststate { - ret ss.poststate; + return ss.poststate; } fn stmt_prestate(ccx: crate_ctxt, s: stmt) -> prestate { - ret stmt_states(ccx, s).prestate; + return stmt_states(ccx, s).prestate; } fn stmt_poststate(ccx: crate_ctxt, s: stmt) -> poststate { - ret stmt_states(ccx, s).poststate; + return stmt_states(ccx, s).poststate; } fn block_precond(ccx: crate_ctxt, b: blk) -> precond { - ret block_pp(ccx, b).precondition; + return block_pp(ccx, b).precondition; } fn block_postcond(ccx: crate_ctxt, b: blk) -> postcond { - ret block_pp(ccx, b).postcondition; + return block_pp(ccx, b).postcondition; } fn block_prestate(ccx: crate_ctxt, b: blk) -> prestate { - ret block_states(ccx, b).prestate; + return block_states(ccx, b).prestate; } fn block_poststate(ccx: crate_ctxt, b: blk) -> poststate { - ret block_states(ccx, b).poststate; + return block_states(ccx, b).poststate; } fn set_prestate_ann(ccx: crate_ctxt, id: node_id, pre: prestate) -> bool { debug!{"set_prestate_ann"}; - ret set_prestate(node_id_to_ts_ann(ccx, id), pre); + return set_prestate(node_id_to_ts_ann(ccx, id), pre); } fn extend_prestate_ann(ccx: crate_ctxt, id: node_id, pre: prestate) -> bool { debug!{"extend_prestate_ann"}; - ret extend_prestate(node_id_to_ts_ann(ccx, id).states.prestate, pre); + return extend_prestate(node_id_to_ts_ann(ccx, id).states.prestate, pre); } fn set_poststate_ann(ccx: crate_ctxt, id: node_id, post: poststate) -> bool { debug!{"set_poststate_ann"}; - ret set_poststate(node_id_to_ts_ann(ccx, id), post); + return set_poststate(node_id_to_ts_ann(ccx, id), post); } fn extend_poststate_ann(ccx: crate_ctxt, id: node_id, post: poststate) -> bool { debug!{"extend_poststate_ann"}; - ret extend_poststate(node_id_to_ts_ann(ccx, id).states.poststate, post); + return extend_poststate( + node_id_to_ts_ann(ccx, id).states.poststate, post); } fn set_pre_and_post(ccx: crate_ctxt, id: node_id, pre: precond, @@ -430,14 +431,14 @@ fn set_postcond_false(ccx: crate_ctxt, id: node_id) { } fn pure_exp(ccx: crate_ctxt, id: node_id, p: prestate) -> bool { - ret set_prestate_ann(ccx, id, p) | set_poststate_ann(ccx, id, p); + return set_prestate_ann(ccx, id, p) | set_poststate_ann(ccx, id, p); } -fn num_constraints(m: fn_info) -> uint { ret m.num_constraints; } +fn num_constraints(m: fn_info) -> uint { return m.num_constraints; } fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt { let na: ~[mut ts_ann] = ~[mut]; - ret {tcx: cx, node_anns: @mut na, fm: int_hash::<fn_info>()}; + return {tcx: cx, node_anns: @mut na, fm: int_hash::<fn_info>()}; } /* Use e's type to determine whether it returns. @@ -445,15 +446,15 @@ fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt { 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 { - ty::ty_fn(f) { ret f.ret_style; } - _ { ret return_val; } + 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 { - ty::ty_fn(f) { ret f.constraints; } - _ { ret ~[]; } + ty::ty_fn(f) { return f.constraints; } + _ { return ~[]; } } } @@ -463,12 +464,12 @@ fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def { error!{"node_id_to_def: node_id %d has no def", id}; fail; } - some(d) { ret d; } + some(d) { return d; } } } fn node_id_to_def(ccx: crate_ctxt, id: node_id) -> option<def> { - ret ccx.tcx.def_map.find(id); + return ccx.tcx.def_map.find(id); } fn norm_a_constraint(id: def_id, c: constraint) -> ~[norm_constraint] { @@ -480,7 +481,7 @@ fn norm_a_constraint(id: def_id, c: constraint) -> ~[norm_constraint] { def_id: id, args: pd.node.args})}); } - ret rslt; + return rslt; } @@ -491,7 +492,7 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] { for fcx.enclosing.constrs.each |key, val| { vec::push_all(rslt, norm_a_constraint(key, val)); }; - ret rslt; + return rslt; } // FIXME (#2539): Would rather take an immutable vec as an argument, @@ -499,12 +500,12 @@ fn constraints(fcx: fn_ctxt) -> ~[norm_constraint] { fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>, occ: ~[@constr_arg_use]) -> uint { debug!{"match_args: looking at %s", - constr_args_to_str(fn@(i: inst) -> ~str { ret *i.ident; }, occ)}; + constr_args_to_str(fn@(i: inst) -> ~str { *i.ident }, occ)}; for (*occs).each |pd| { log(debug, ~"match_args: candidate " + pred_args_to_str(pd)); - fn eq(p: inst, q: inst) -> bool { ret p.node == q.node; } - if ty::args_eq(eq, pd.node.args, occ) { ret pd.node.bit_num; } + fn eq(p: inst, q: inst) -> bool { return p.node == q.node; } + if ty::args_eq(eq, pd.node.args, occ) { return pd.node.bit_num; } } fcx.ccx.tcx.sess.bug(~"match_args: no match for occurring args"); } @@ -514,7 +515,7 @@ fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { none { tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t)); } - some(def_fn(i, _)) { ret i; } + some(def_fn(i, _)) { return i; } _ { tcx.sess.bug(~"node_id_for_constr: pred is not a function"); } } } @@ -525,7 +526,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { alt tcx.def_map.find(e.id) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_binding(nid)) | some(def_upvar(nid, _, _)) { - ret @respan(p.span, + return @respan(p.span, carg_ident({ident: p.idents[0], node: nid})); } some(what) { @@ -540,7 +541,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { } } } - expr_lit(l) { ret @respan(e.span, carg_lit(l)); } + expr_lit(l) { return @respan(e.span, carg_lit(l)); } _ { tcx.sess.span_fatal(e.span, ~"arguments to constrained functions must be " + @@ -562,7 +563,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr { expr_call(operator, args, _) { alt operator.node { expr_path(p) { - ret respan(e.span, + return respan(e.span, {path: p, def_id: def_id_for_constr(tcx, operator.id), args: exprs_to_constr_args(tcx, args)}); @@ -581,7 +582,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr { fn pred_args_to_str(p: pred_args) -> ~str { ~"<" + uint::str(p.node.bit_num) + ~", " + - constr_args_to_str(fn@(i: inst) -> ~str {ret *i.ident; }, + constr_args_to_str(fn@(i: inst) -> ~str {return *i.ident; }, p.node.args) + ~">" } @@ -592,7 +593,7 @@ fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) -> for c.node.args.each |a| { vec::push(rslt, substitute_arg(cx, actuals, a)); } - ret {path: c.node.path, + return {path: c.node.path, def_id: c.node.id, args: rslt}; } @@ -603,13 +604,13 @@ fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) -> alt a.node { carg_ident(i) { if i < num_actuals { - ret expr_to_constr_arg(cx, actuals[i]); + return expr_to_constr_arg(cx, actuals[i]); } else { cx.sess.span_fatal(a.span, ~"constraint argument out of bounds"); } } - carg_base { ret @respan(a.span, carg_base); } - carg_lit(l) { ret @respan(a.span, carg_lit(l)); } + carg_base { return @respan(a.span, carg_base); } + carg_lit(l) { return @respan(a.span, carg_lit(l)); } } } @@ -622,30 +623,30 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>], alt c.node { carg_ident(p) { alt n { - carg_ident(q) { if p.node != q.node { ret false; } } - _ { ret false; } + carg_ident(q) { if p.node != q.node { return false; } } + _ { return false; } } } - carg_base { if n != carg_base { ret false; } } + carg_base { if n != carg_base { return false; } } carg_lit(l) { alt n { - carg_lit(m) { if !const_eval::lit_eq(l, m) { ret false; } } - _ { ret false; } + carg_lit(m) { if !const_eval::lit_eq(l, m) { return false; } } + _ { return false; } } } } i += 1u; } - ret true; + return true; } fn find_instance_(pattern: ~[constr_arg_general_<inst>], descs: ~[pred_args]) -> option<uint> { for descs.each |d| { - if pred_args_matches(pattern, d) { ret some(d.node.bit_num); } + if pred_args_matches(pattern, d) { return some(d.node.bit_num); } } - ret none; + return none; } type inst = {ident: ident, node: node_id}; @@ -660,7 +661,7 @@ type subst = ~[{from: inst, to: inst}]; fn find_instances(_fcx: fn_ctxt, subst: subst, c: constraint) -> ~[{from: uint, to: uint}] { - if vec::len(subst) == 0u { ret ~[]; } + if vec::len(subst) == 0u { return ~[]; } let mut res = ~[]; do (*c.descs).swap |v| { let v <- vec::from_mut(v); @@ -676,14 +677,14 @@ fn find_instances(_fcx: fn_ctxt, subst: subst, } vec::to_mut(v) } - ret res; + return res; } fn find_in_subst(id: node_id, s: subst) -> option<inst> { for s.each |p| { - if id == p.from.node { ret some(p.to); } + if id == p.from.node { return some(p.to); } } - ret none; + return none; } fn find_in_subst_bool(s: subst, id: node_id) -> bool { @@ -721,7 +722,7 @@ fn replace(subst: subst, d: pred_args) -> ~[constr_arg_general_<inst>] { } } - ret rslt; + return rslt; } enum if_ty { if_check, plain_if, } @@ -738,7 +739,7 @@ fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) -> alt local_node_id_to_def(fcx, i) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_upvar(nid, _, _)) { - ret local_def(nid); + return local_def(nid); } some(_) { fcx.ccx.tcx.sess.span_fatal(sp, @@ -800,7 +801,7 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate, alt ty { oper_swap { subst = ~[{from: dest, to: src}, {from: src, to: dest}]; } oper_assign_op { - ret; // Don't do any propagation + return; // Don't do any propagation } _ { subst = ~[{from: src, to: dest}]; } } @@ -844,17 +845,17 @@ fn forget_in_poststate(fcx: fn_ctxt, p: poststate, dead_v: node_id) -> bool { changed |= clear_in_poststate_(c.bit_num, p); } } - ret changed; + return changed; } fn any_eq(v: ~[node_id], d: node_id) -> bool { - for v.each |i| { if i == d { ret true; } } + for v.each |i| { if i == d { return true; } } false } fn constraint_mentions(_fcx: fn_ctxt, c: norm_constraint, v: node_id) -> bool { - ret args_mention(c.c.node.args, any_eq, ~[v]); + return args_mention(c.c.node.args, any_eq, ~[v]); } fn args_mention<T>(args: ~[@constr_arg_use], @@ -862,9 +863,11 @@ fn args_mention<T>(args: ~[@constr_arg_use], s: ~[T]) -> bool { for args.each |a| { - alt a.node { carg_ident(p1) { if q(s, p1.node) { ret true; } } _ { } } + alt a.node { + carg_ident(p1) { if q(s, p1.node) { return true; } } _ { } + } } - ret false; + return false; } fn use_var(fcx: fn_ctxt, v: node_id) { @@ -906,13 +909,13 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg], carg_lit(l) { carg_lit(l) } })); } - ret actuals; + return actuals; } fn ast_constr_to_ts_constr(tcx: ty::ctxt, args: ~[arg], c: @constr) -> tsconstr { let tconstr = ty::ast_constr_to_constr(tcx, c); - ret {path: tconstr.node.path, + return {path: tconstr.node.path, def_id: tconstr.node.id, args: args_to_constr_args(tcx, args, tconstr.node.args)}; } @@ -920,7 +923,7 @@ fn ast_constr_to_ts_constr(tcx: ty::ctxt, args: ~[arg], c: @constr) -> fn ast_constr_to_sp_constr(tcx: ty::ctxt, args: ~[arg], c: @constr) -> sp_constr { let tconstr = ast_constr_to_ts_constr(tcx, args, c); - ret respan(c.span, tconstr); + return respan(c.span, tconstr); } type binding = {lhs: ~[dest], rhs: option<initializer>}; @@ -936,7 +939,7 @@ fn local_to_bindings(tcx: ty::ctxt, loc: @local) -> binding { fn locals_to_bindings(tcx: ty::ctxt, locals: ~[@local]) -> ~[binding] { let mut rslt = ~[]; for locals.each |loc| { vec::push(rslt, local_to_bindings(tcx, loc)); } - ret rslt; + return rslt; } fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { @@ -946,7 +949,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { ty::ty_fn({inputs: args, _}) { let mut modes = ~[]; for args.each |arg| { vec::push(modes, arg.mode); } - ret modes; + return modes; } _ { // Shouldn't happen; callee should be ty_fn. @@ -973,7 +976,7 @@ fn arg_bindings(ops: ~[init_op], es: ~[@expr]) -> ~[binding] { {lhs: ~[call], rhs: some({op: op, expr: es[i]})}); i += 1u; } - ret bindings; + return bindings; } // diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index 448b7a5231f..c6f46ba3888 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -49,7 +49,7 @@ fn find_locals(tcx: ty::ctxt, with *visitor}; visit::visit_fn(fk, f_decl, f_body, sp, id, cx, visit::mk_vt(visitor)); - ret cx; + return cx; } fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) -> @@ -68,7 +68,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) -> tbl.insert(d_id, {path:p, descs:rslt}); } } - ret next + 1u; + return next + 1u; } fn contains_constrained_calls(tcx: ty::ctxt, body: blk) -> bool { @@ -83,7 +83,7 @@ fn contains_constrained_calls(tcx: ty::ctxt, body: blk) -> bool { let vtor = visit::default_visitor::<cx>(); let vtor = @{visit_expr: visit_expr with *vtor}; visit::visit_block(body, cx, visit::mk_vt(vtor)); - ret cx.has; + return cx.has; fn visit_expr(e: @expr, &&cx: cx, v: visit::vt<cx>) { import syntax::print::pprust; diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 08f0736c1da..9315e69d289 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -48,7 +48,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) { } item_mod(m) { find_pre_post_mod(m); } item_foreign_mod(nm) { find_pre_post_foreign_mod(nm); } - item_ty(*) | item_enum(*) | item_trait(*) { ret; } + item_ty(*) | item_enum(*) | item_trait(*) { return; } item_class(*) { fail ~"find_pre_post_item: shouldn't be called on item_class"; } @@ -72,7 +72,7 @@ fn find_pre_post_exprs(fcx: fn_ctxt, args: ~[@expr], id: node_id) { for args.each |e| { do_one(fcx, e); } fn get_pp(ccx: crate_ctxt, &&e: @expr) -> pre_and_post { - ret expr_pp(ccx, e); + return expr_pp(ccx, e); } let pps = vec::map(args, |a| get_pp(fcx.ccx, a) ); @@ -396,7 +396,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { _ {} } find_pre_post_block(fcx, an_alt.body); - ret block_pp(fcx.ccx, an_alt.body); + return block_pp(fcx.ccx, an_alt.body); } let mut alt_pps = ~[]; for alts.each |a| { vec::push(alt_pps, do_an_alt(fcx, a)); } @@ -404,7 +404,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { &&next: pre_and_post) -> pre_and_post { union(pp.precondition, seq_preconds(fcx, ~[antec, next])); intersect(pp.postcondition, next.postcondition); - ret pp; + return pp; } let antec_pp = pp_clone(expr_pp(fcx.ccx, ex)); let e_pp = diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index 9c4285774f7..b134f3b71af 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -84,7 +84,7 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: ~[binding]) -> } } } - ret {changed: changed, post: post}; + return {changed: changed, post: post}; } fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr, @@ -100,7 +100,7 @@ fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr, } changed = set_poststate_ann(fcx.ccx, parent, post) || changed; - ret changed; + return changed; } fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, @@ -162,7 +162,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, _ { } } changed = set_poststate_ann(fcx.ccx, parent, post) || changed; - ret changed; + return changed; } fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr, @@ -178,7 +178,7 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr, %u exprs vs. %u ops", vec::len(bs), vec::len(ops)}); } - ret find_pre_post_state_exprs(fcx, pres, id, ops, + return find_pre_post_state_exprs(fcx, pres, id, ops, bs, cf) || changed; } @@ -195,7 +195,7 @@ fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id, } _ { changed |= set_poststate_ann(fcx.ccx, id, rs.post); } } - ret changed; + return changed; } fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, @@ -261,7 +261,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, changed |= set_poststate_ann(fcx.ccx, id, poststate_res); } } - ret changed; + return changed; } fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id, @@ -276,7 +276,7 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id, forget_in_poststate(fcx, post, cap_item.id); } } - ret set_poststate_ann(ccx, e_id, post) || pres_changed; + return set_poststate_ann(ccx, e_id, post) || pres_changed; } fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { @@ -284,41 +284,41 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { alt e.node { expr_new(p, _, v) { - ret find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure); + return find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure); } expr_vstore(ee, _) { let mut changed = find_pre_post_state_expr(fcx, pres, ee); set_prestate_ann(fcx.ccx, e.id, expr_prestate(fcx.ccx, ee)); set_poststate_ann(fcx.ccx, e.id, expr_poststate(fcx.ccx, ee)); - ret changed; + return changed; } expr_vec(elts, _) { - ret find_pre_post_state_exprs(fcx, pres, e.id, + return find_pre_post_state_exprs(fcx, pres, e.id, vec::from_elem(vec::len(elts), init_assign), elts, return_val); } expr_call(operator, operands, _) { debug!{"hey it's a call: %s", expr_to_str(e)}; - ret find_pre_post_state_call(fcx, pres, operator, e.id, + return find_pre_post_state_call(fcx, pres, operator, e.id, callee_arg_init_ops(fcx, operator.id), operands, controlflow_expr(fcx.ccx, operator)); } - expr_path(_) { ret pure_exp(fcx.ccx, e.id, pres); } + expr_path(_) { return pure_exp(fcx.ccx, e.id, pres); } expr_log(_, lvl, ex) { - ret find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure); + return find_pre_post_state_two(fcx, pres, lvl, ex, e.id, oper_pure); } expr_mac(_) { fcx.ccx.tcx.sess.bug(~"unexpanded macro"); } - expr_lit(l) { ret pure_exp(fcx.ccx, e.id, pres); } + expr_lit(l) { return pure_exp(fcx.ccx, e.id, pres); } expr_fn(_, _, _, cap_clause) { - ret find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause); + return find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause); } expr_fn_block(_, _, cap_clause) { - ret find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause); + return find_pre_post_state_cap_clause(fcx, e.id, pres, cap_clause); } expr_block(b) { - ret find_pre_post_state_block(fcx, pres, b) | + return find_pre_post_state_block(fcx, pres, b) | set_prestate_ann(fcx.ccx, e.id, pres) | set_poststate_ann(fcx.ccx, e.id, block_poststate(fcx.ccx, b)); } @@ -337,30 +337,31 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { set_poststate_ann(fcx.ccx, e.id, expr_poststate(fcx.ccx, base)) }); - ret changed; + return changed; } expr_tup(elts) { - ret find_pre_post_state_exprs(fcx, pres, e.id, + return find_pre_post_state_exprs(fcx, pres, e.id, vec::from_elem(vec::len(elts), init_assign), elts, return_val); } expr_move(lhs, rhs) { - ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_move); + return find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_move); } expr_assign(lhs, rhs) { - ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_assign); + return find_pre_post_state_two( + fcx, pres, lhs, rhs, e.id, oper_assign); } expr_swap(lhs, rhs) { - ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_swap); + return find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_swap); // Could be more precise and actually swap the role of // lhs and rhs in constraints } expr_ret(maybe_ret_val) { let mut changed = set_prestate_ann(fcx.ccx, e.id, pres); /* everything is true if execution continues after - a ret expression (since execution never continues locally - after a ret expression */ + a return expression (since execution never continues locally + after a return expression */ let post = false_postcond(num_constrs); set_poststate_ann(fcx.ccx, e.id, post); @@ -371,10 +372,10 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { changed |= find_pre_post_state_expr(fcx, pres, ret_val); } } - ret changed; + return changed; } expr_if(antec, conseq, maybe_alt) { - ret join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if, + return join_then_else(fcx, antec, conseq, maybe_alt, e.id, plain_if, pres); } expr_binary(bop, l, r) { @@ -382,15 +383,15 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { let mut changed = find_pre_post_state_expr(fcx, pres, l); changed |= find_pre_post_state_expr(fcx, expr_poststate(fcx.ccx, l), r); - ret changed | set_prestate_ann(fcx.ccx, e.id, pres) | + return changed | set_prestate_ann(fcx.ccx, e.id, pres) | set_poststate_ann(fcx.ccx, e.id, expr_poststate(fcx.ccx, l)); } else { - ret find_pre_post_state_two(fcx, pres, l, r, e.id, oper_pure); + return find_pre_post_state_two(fcx, pres, l, r, e.id, oper_pure); } } expr_assign_op(op, lhs, rhs) { - ret find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, + return find_pre_post_state_two(fcx, pres, lhs, rhs, e.id, oper_assign_op); } expr_while(test, body) { @@ -407,11 +408,11 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { or cont, we assume nothing about the poststate */ /* which is still unsound -- see ~[Break-unsound] */ if has_nonlocal_exits(body) { - ret changed | set_poststate_ann(fcx.ccx, e.id, pres); + return changed | set_poststate_ann(fcx.ccx, e.id, pres); } else { let e_post = expr_poststate(fcx.ccx, test); let b_post = block_poststate(fcx.ccx, body); - ret changed | + return changed | set_poststate_ann(fcx.ccx, e.id, intersect_states(e_post, b_post)); } @@ -433,14 +434,14 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { deinitialize everything before breaking */ let post = empty_poststate(num_constrs); post.kill(); - ret changed | set_poststate_ann(fcx.ccx, e.id, post); + return changed | set_poststate_ann(fcx.ccx, e.id, post); } else { - ret changed | set_poststate_ann(fcx.ccx, e.id, + return changed | set_poststate_ann(fcx.ccx, e.id, false_postcond(num_constrs)); } } expr_index(val, sub) { - ret find_pre_post_state_two(fcx, pres, val, sub, e.id, oper_pure); + return find_pre_post_state_two(fcx, pres, val, sub, e.id, oper_pure); } expr_alt(val, alts, _) { let mut changed = @@ -470,19 +471,19 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { a_post = e_post; } - ret changed | set_poststate_ann(fcx.ccx, e.id, a_post); + return changed | set_poststate_ann(fcx.ccx, e.id, a_post); } expr_field(x, _, _) | expr_loop_body(x) | expr_do_body(x) | expr_unary(_, x) | expr_addr_of(_, x) | expr_assert(x) | expr_cast(x, _) | expr_copy(x) { - ret find_pre_post_state_sub(fcx, pres, x, e.id, none); + return find_pre_post_state_sub(fcx, pres, x, e.id, none); } expr_fail(maybe_fail_val) { /* if execution continues after fail, then everything is true! woo! */ let post = false_postcond(num_constrs); - ret set_prestate_ann(fcx.ccx, e.id, pres) | + return set_prestate_ann(fcx.ccx, e.id, pres) | set_poststate_ann(fcx.ccx, e.id, post) | option::map_default( maybe_fail_val, false, @@ -492,13 +493,14 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { expr_check(_, p) { /* predicate p holds after this expression executes */ let c: sp_constr = expr_to_constr(fcx.ccx.tcx, p); - ret find_pre_post_state_sub(fcx, pres, p, e.id, some(c.node)); + return find_pre_post_state_sub(fcx, pres, p, e.id, some(c.node)); } expr_if_check(p, conseq, maybe_alt) { - ret join_then_else(fcx, p, conseq, maybe_alt, e.id, if_check, pres); + return join_then_else( + fcx, p, conseq, maybe_alt, e.id, if_check, pres); } - expr_break { ret pure_exp(fcx.ccx, e.id, pres); } - expr_again { ret pure_exp(fcx.ccx, e.id, pres); } + expr_break { return pure_exp(fcx.ccx, e.id, pres); } + expr_again { return pure_exp(fcx.ccx, e.id, pres); } } } @@ -529,10 +531,11 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { debug!{"poststate = %s", stmt_ann.states.poststate.to_str()}; debug!{"changed = %s", bool::to_str(changed)}; - ret changed; + return changed; } decl_item(an_item) { - ret set_prestate(stmt_ann, pres) | set_poststate(stmt_ann, pres); + return set_prestate(stmt_ann, pres) + | set_poststate(stmt_ann, pres); /* the outer visitor will recurse into the item */ } } @@ -549,7 +552,7 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { debug!{"poststate = %s", stmt_ann.states.poststate.to_str()}; debug!{"changed = %s", bool::to_str(changed)}; - ret changed; + return changed; } } } @@ -582,7 +585,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool { set_prestate_ann(fcx.ccx, b.node.id, pres0); set_poststate_ann(fcx.ccx, b.node.id, post); - ret changed; + return changed; } fn find_pre_post_state_fn(fcx: fn_ctxt, @@ -607,7 +610,7 @@ fn find_pre_post_state_fn(fcx: fn_ctxt, fcx.ccx.tcx.sess.span_note(f_body.span, fcx.name); */ - ret changed; + return changed; } // // Local Variables: diff --git a/src/rustc/middle/tstate/tritv.rs b/src/rustc/middle/tstate/tritv.rs index 1e78b82fba8..ee2cf2d7a14 100644 --- a/src/rustc/middle/tstate/tritv.rs +++ b/src/rustc/middle/tstate/tritv.rs @@ -94,7 +94,7 @@ class t { fn doesntcare() -> bool { for uint::range(0, self.nbits) |i| { - if self.get(i) != dont_care { ret false; } + if self.get(i) != dont_care { return false; } } true } @@ -134,7 +134,7 @@ class t { changed = change(changed, old, newv); self.set(i, newv); } - ret changed; + return changed; } fn become(source: t) -> bool { @@ -155,7 +155,7 @@ class t { changed = change(changed, old, newv); self.set(i, newv); } - ret changed; + return changed; } new(len: uint) { diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 6ece1a4740e..ff52e34fdad 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -542,12 +542,12 @@ type node_type_table = @smallintmap::smallintmap<t>; fn mk_rcache() -> creader_cache { type val = {cnum: int, pos: uint, len: uint}; fn hash_cache_entry(k: val) -> uint { - ret (k.cnum as uint) + k.pos + k.len; + return (k.cnum as uint) + k.pos + k.len; } fn eq_cache_entries(a: val, b: val) -> bool { - ret a.cnum == b.cnum && a.pos == b.pos && a.len == b.len; + return a.cnum == b.cnum && a.pos == b.pos && a.len == b.len; } - ret map::hashmap(hash_cache_entry, eq_cache_entries); + return map::hashmap(hash_cache_entry, eq_cache_entries); } fn new_ty_hash<V: copy>() -> map::hashmap<t, V> { @@ -608,7 +608,7 @@ fn mk_t(cx: ctxt, st: sty) -> t { mk_t_with_id(cx, st, none) } 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) { - some(t) { unsafe { ret unsafe::reinterpret_cast(t); } } + some(t) { unsafe { return unsafe::reinterpret_cast(t); } } _ {} } let mut flags = 0u; @@ -624,7 +624,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t { let mut f = 0u; for substs.tps.each |tt| { f |= get(tt).flags; } substs.self_r.iter(|r| f |= rflags(r)); - ret f; + return f; } alt st { ty_estr(vstore_slice(r)) { @@ -816,7 +816,7 @@ fn walk_ty(ty: t, f: fn(t)) { } fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { - if !f(ty) { ret; } + if !f(ty) { return; } alt get(ty).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_self | @@ -991,7 +991,7 @@ fn fold_regions( fn do_fold(cx: ctxt, ty: t, in_fn: bool, fldr: fn(region, bool) -> region) -> t { - if !type_has_regions(ty) { ret ty; } + if !type_has_regions(ty) { return ty; } fold_regions_and_ty( cx, ty, |r| fldr(r, in_fn), @@ -1005,7 +1005,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t { fn do_fold(cx: ctxt, t0: t, under_r: bool, fldop: fn(region, bool) -> region) -> t { let tb = get(t0); - if !tbox_has_flag(tb, has_regions) { ret t0; } + if !tbox_has_flag(tb, has_regions) { return t0; } alt tb.struct { ty_rptr(r, {ty: t1, mutbl: m}) { let m_r = fldop(r, under_r); @@ -1038,9 +1038,9 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t { // Substitute *only* type parameters. Used in trans where regions are erased. fn subst_tps(cx: ctxt, tps: ~[t], typ: t) -> t { - if tps.len() == 0u { ret typ; } + if tps.len() == 0u { return typ; } let tb = ty::get(typ); - if !tbox_has_flag(tb, has_params) { ret typ; } + if !tbox_has_flag(tb, has_params) { return typ; } alt tb.struct { ty_param(p) { tps[p.idx] } sty { fold_sty_to_ty(cx, sty, |t| subst_tps(cx, tps, t)) } @@ -1068,16 +1068,16 @@ fn subst(cx: ctxt, substs_to_str(cx, substs), ty_to_str(cx, typ)}; - if substs_is_noop(substs) { ret typ; } + if substs_is_noop(substs) { return typ; } let r = do_subst(cx, substs, typ); debug!{" r = %s", ty_to_str(cx, r)}; - ret r; + return r; fn do_subst(cx: ctxt, substs: substs, typ: t) -> t { let tb = get(typ); - if !tbox_has_flag(tb, needs_subst) { ret typ; } + if !tbox_has_flag(tb, needs_subst) { return typ; } alt tb.struct { ty_param(p) {substs.tps[p.idx]} ty_self {substs.self_ty.get()} @@ -1129,7 +1129,7 @@ fn type_is_structural(ty: t) -> bool { } fn type_is_copyable(cx: ctxt, ty: t) -> bool { - ret kind_can_be_copied(type_kind(cx, ty)); + return kind_can_be_copied(type_kind(cx, ty)); } fn type_is_sequence(ty: t) -> bool { @@ -1148,8 +1148,8 @@ fn type_is_str(ty: t) -> bool { fn sequence_element_type(cx: ctxt, ty: t) -> t { alt get(ty).struct { - ty_estr(_) { ret mk_mach_uint(cx, ast::ty_u8); } - ty_evec(mt, _) | ty_unboxed_vec(mt) { ret mt.ty; } + ty_estr(_) { return mk_mach_uint(cx, ast::ty_u8); } + ty_evec(mt, _) | ty_unboxed_vec(mt) { return mt.ty; } _ { cx.sess.bug( ~"sequence_element_type called on non-sequence value"); } @@ -1158,16 +1158,16 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t { fn get_element_type(ty: t, i: uint) -> t { alt get(ty).struct { - ty_rec(flds) { ret flds[i].mt.ty; } - ty_tup(ts) { ret ts[i]; } + ty_rec(flds) { return flds[i].mt.ty; } + ty_tup(ts) { return ts[i]; } _ { fail ~"get_element_type called on invalid type"; } } } pure fn type_is_box(ty: t) -> bool { alt get(ty).struct { - ty_box(_) { ret true; } - _ { ret false; } + ty_box(_) { return true; } + _ { return false; } } } @@ -1189,26 +1189,26 @@ pure fn type_is_region_ptr(ty: t) -> bool { pure fn type_is_slice(ty: t) -> bool { alt get(ty).struct { ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) { true } - _ { ret false; } + _ { return false; } } } pure fn type_is_unique_box(ty: t) -> bool { alt get(ty).struct { - ty_uniq(_) { ret true; } - _ { ret false; } + ty_uniq(_) { return true; } + _ { return false; } } } pure fn type_is_unsafe_ptr(ty: t) -> bool { alt get(ty).struct { - ty_ptr(_) { ret true; } - _ { ret false; } + ty_ptr(_) { return true; } + _ { return false; } } } pure fn type_is_vec(ty: t) -> bool { - ret alt get(ty).struct { + return alt get(ty).struct { ty_evec(_, _) | ty_unboxed_vec(_) { true } ty_estr(_) { true } _ { false } @@ -1217,10 +1217,10 @@ pure fn type_is_vec(ty: t) -> bool { pure fn type_is_unique(ty: t) -> bool { alt get(ty).struct { - ty_uniq(_) { ret true; } + ty_uniq(_) { return true; } ty_evec(_, vstore_uniq) { true } ty_estr(vstore_uniq) { true } - _ { ret false; } + _ { return false; } } } @@ -1233,13 +1233,13 @@ pure fn type_is_scalar(ty: t) -> bool { } fn type_is_immediate(ty: t) -> bool { - ret type_is_scalar(ty) || type_is_boxed(ty) || + return type_is_scalar(ty) || type_is_boxed(ty) || type_is_unique(ty) || type_is_region_ptr(ty); } fn type_needs_drop(cx: ctxt, ty: t) -> bool { alt cx.needs_drop_cache.find(ty) { - some(result) { ret result; } + some(result) { return result; } none {/* fall through */ } } @@ -1293,7 +1293,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { }; cx.needs_drop_cache.insert(ty, result); - ret result; + return result; } // Some things don't need cleanups during unwinding because the @@ -1302,7 +1302,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { // cleanups. fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool { alt cx.needs_unwind_cleanup_cache.find(ty) { - some(result) { ret result; } + some(result) { return result; } none { } } @@ -1310,7 +1310,7 @@ fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool { let needs_unwind_cleanup = type_needs_unwind_cleanup_(cx, ty, tycache, false); cx.needs_unwind_cleanup_cache.insert(ty, needs_unwind_cleanup); - ret needs_unwind_cleanup; + return needs_unwind_cleanup; } fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, @@ -1319,7 +1319,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, // Prevent infinite recursion alt tycache.find(ty) { - some(_) { ret false; } + some(_) { return false; } none { tycache.insert(ty, ()); } } @@ -1373,7 +1373,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, result } - ret needs_unwind_cleanup; + return needs_unwind_cleanup; } enum kind { kind_(u32) } @@ -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) { - some(result) { ret result; } + some(result) { return result; } none {/* fall through */ } } @@ -1735,7 +1735,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { } cx.kind_cache.insert(ty, result); - ret result; + return result; } /// gives a rough estimate of how much space it takes to represent @@ -1816,7 +1816,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_to_str(cx, r_ty), ty_to_str(cx, ty), r}; - ret r; + return r; } fn subtypes_require(cx: ctxt, seen: @mut ~[def_id], @@ -1848,7 +1848,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_box(mt) | ty_uniq(mt) | ty_rptr(_, mt) { - ret type_requires(cx, seen, r_ty, mt.ty); + return type_requires(cx, seen, r_ty, mt.ty); } ty_ptr(mt) { @@ -1904,7 +1904,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_to_str(cx, ty), r}; - ret r; + return r; } let seen = @mut ~[]; @@ -1915,46 +1915,48 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> bool { let sty = get(ty).struct; debug!{"type_structurally_contains: %s", ty_to_str(cx, ty)}; - if test(sty) { ret true; } + if test(sty) { return true; } alt sty { ty_enum(did, substs) { for vec::each(*enum_variants(cx, did)) |variant| { for variant.args.each |aty| { let sty = subst(cx, substs, aty); - if type_structurally_contains(cx, sty, test) { ret true; } + if type_structurally_contains(cx, sty, test) { return true; } } } - ret false; + return false; } ty_rec(fields) { for fields.each |field| { - if type_structurally_contains(cx, field.mt.ty, test) { ret true; } + if type_structurally_contains(cx, field.mt.ty, test) { + return true; + } } - ret false; + return false; } ty_class(did, substs) { for lookup_class_fields(cx, did).each |field| { let ft = lookup_field_type(cx, did, field.id, substs); - if type_structurally_contains(cx, ft, test) { ret true; } + if type_structurally_contains(cx, ft, test) { return true; } } - ret false; + return false; } ty_tup(ts) { for ts.each |tt| { - if type_structurally_contains(cx, tt, test) { ret true; } + if type_structurally_contains(cx, tt, test) { return true; } } - ret false; + return false; } ty_evec(mt, vstore_fixed(_)) { - ret type_structurally_contains(cx, mt.ty, test); + return type_structurally_contains(cx, mt.ty, test); } - _ { ret false; } + _ { return false; } } } fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool { - ret type_structurally_contains(cx, ty, |sty| { + return type_structurally_contains(cx, ty, |sty| { alt sty { ty_uniq(_) | ty_evec(_, vstore_uniq) | @@ -1979,7 +1981,7 @@ fn type_is_fp(ty: t) -> bool { } fn type_is_numeric(ty: t) -> bool { - ret type_is_integral(ty) || type_is_fp(ty); + return type_is_integral(ty) || type_is_fp(ty); } fn type_is_signed(ty: t) -> bool { @@ -2044,13 +2046,13 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { } } - ret result; + return result; } fn type_is_enum(ty: t) -> bool { alt get(ty).struct { - ty_enum(_, _) { ret true; } - _ { ret false;} + ty_enum(_, _) { return true; } + _ { return false;} } } @@ -2061,18 +2063,18 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool { ty_enum(did, substs) { let variants = enum_variants(cx, did); let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u); - ret !some_n_ary; + return !some_n_ary; } - _ { ret false;} + _ { return false;} } } fn type_param(ty: t) -> option<uint> { alt get(ty).struct { - ty_param(p) { ret some(p.idx); } + ty_param(p) { return some(p.idx); } _ {/* fall through */ } } - ret none; + return none; } // Returns the type and mutability of *t. @@ -2110,7 +2112,7 @@ fn type_autoderef(cx: ctxt, t: t) -> t { let mut t = t; loop { alt deref(cx, t, false) { - none { ret t; } + none { return t; } some(mt) { t = mt.ty; } } } @@ -2243,13 +2245,13 @@ 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) { - none { ret ~[]; } - some(ts) { ret ts; } + none { return ~[]; } + some(ts) { return ts; } } } fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { - ret cx.node_type_substs.contains_key(id); + return cx.node_type_substs.contains_key(id); } // Type accessors for substructures of types @@ -2283,8 +2285,8 @@ fn ty_fn_ret_style(fty: t) -> ast::ret_style { fn is_fn_ty(fty: t) -> bool { alt get(fty).struct { - ty_fn(_) { ret true; } - _ { ret false; } + ty_fn(_) { return true; } + _ { return false; } } } @@ -2301,14 +2303,14 @@ fn is_pred_ty(fty: t) -> bool { fn ty_var_id(typ: t) -> tv_vid { alt get(typ).struct { - ty_var(vid) { ret vid; } + 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 { - ty_var_integral(vid) { ret vid; } + ty_var_integral(vid) { return vid; } _ { error!{"ty_var_integral_id called on ty other than \ ty_var_integral"}; fail; } @@ -2317,14 +2319,14 @@ fn ty_var_integral_id(typ: t) -> tvi_vid { // Type accessors for AST nodes fn block_ty(cx: ctxt, b: ast::blk) -> t { - ret node_id_to_type(cx, b.node.id); + return node_id_to_type(cx, b.node.id); } // Returns the type of a pattern as a monotype. Like @expr_ty, this function // doesn't provide type parameter substitutions. fn pat_ty(cx: ctxt, pat: @ast::pat) -> t { - ret node_id_to_type(cx, pat.id); + return node_id_to_type(cx, pat.id); } @@ -2335,17 +2337,17 @@ fn pat_ty(cx: ctxt, pat: @ast::pat) -> t { // instead of "fn(t) -> T with T = int". If this isn't what you want, see // expr_ty_params_and_ty() below. fn expr_ty(cx: ctxt, expr: @ast::expr) -> t { - ret node_id_to_type(cx, expr.id); + return node_id_to_type(cx, expr.id); } fn expr_ty_params_and_ty(cx: ctxt, expr: @ast::expr) -> {params: ~[t], ty: t} { - ret {params: node_id_to_type_params(cx, expr.id), + return {params: node_id_to_type_params(cx, expr.id), ty: node_id_to_type(cx, expr.id)}; } fn expr_has_ty_params(cx: ctxt, expr: @ast::expr) -> bool { - ret node_id_has_type_params(cx, expr.id); + return node_id_has_type_params(cx, expr.id); } fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool { @@ -2361,15 +2363,15 @@ 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 { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { - ret id; + return id; } } } fn field_idx(id: ast::ident, fields: ~[field]) -> option<uint> { let mut i = 0u; - for fields.each |f| { if f.ident == id { ret some(i); } i += 1u; } - ret none; + for fields.each |f| { if f.ident == id { return some(i); } i += 1u; } + return none; } fn get_field(rec_ty: t, id: ast::ident) -> field { @@ -2386,8 +2388,8 @@ fn get_fields(rec_ty:t) -> ~[field] { fn method_idx(id: ast::ident, meths: ~[method]) -> option<uint> { let mut i = 0u; - for meths.each |m| { if m.ident == id { ret some(i); } i += 1u; } - ret none; + for meths.each |m| { if m.ident == id { return some(i); } i += 1u; } + return none; } /// Returns a vector containing the indices of all type parameters that appear @@ -2419,7 +2421,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { } // Fast path - if !type_needs_infer(rt) { ret; } + if !type_needs_infer(rt) { return; } // Occurs check! if vec::contains(vars_in_type(rt), vid) { @@ -2539,7 +2541,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { } alt err { - terr_mismatch { ret ~"types differ"; } + terr_mismatch { return ~"types differ"; } terr_ret_style_mismatch(expect, actual) { fn to_str(s: ast::ret_style) -> ~str { alt s { @@ -2547,69 +2549,71 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { ast::return_val { ~"return-by-value" } } } - ret to_str(actual) + ~" function found where " + to_str(expect) + + return to_str(actual) + ~" function found where " + to_str(expect) + ~" function was expected"; } terr_purity_mismatch(f1, f2) { - ret fmt!{"expected %s fn but found %s fn", + return fmt!{"expected %s fn but found %s fn", purity_to_str(f1), purity_to_str(f2)}; } terr_proto_mismatch(e, a) { - ret fmt!{"closure protocol mismatch (%s vs %s)", + return fmt!{"closure protocol mismatch (%s vs %s)", proto_to_str(e), proto_to_str(a)}; } - terr_mutability { ret ~"values differ in mutability"; } - terr_box_mutability { ret ~"boxed values differ in mutability"; } - terr_vec_mutability { ret ~"vectors differ in mutability"; } - terr_ptr_mutability { ret ~"pointers differ in mutability"; } - terr_ref_mutability { ret ~"references differ in mutability"; } + terr_mutability { return ~"values differ in mutability"; } + terr_box_mutability { return ~"boxed values differ in mutability"; } + terr_vec_mutability { return ~"vectors differ in mutability"; } + terr_ptr_mutability { return ~"pointers differ in mutability"; } + terr_ref_mutability { return ~"references differ in mutability"; } terr_ty_param_size(e_sz, a_sz) { - ret ~"expected a type with " + uint::to_str(e_sz, 10u) + + return ~"expected a type with " + uint::to_str(e_sz, 10u) + ~" type params but found one with " + uint::to_str(a_sz, 10u) + ~" type params"; } terr_tuple_size(e_sz, a_sz) { - ret ~"expected a tuple with " + uint::to_str(e_sz, 10u) + + return ~"expected a tuple with " + uint::to_str(e_sz, 10u) + ~" elements but found one with " + uint::to_str(a_sz, 10u) + ~" elements"; } terr_record_size(e_sz, a_sz) { - ret ~"expected a record with " + uint::to_str(e_sz, 10u) + + return ~"expected a record with " + uint::to_str(e_sz, 10u) + ~" fields but found one with " + uint::to_str(a_sz, 10u) + ~" fields"; } - terr_record_mutability { ret ~"record elements differ in mutability"; } + terr_record_mutability { + return ~"record elements differ in mutability"; + } terr_record_fields(e_fld, a_fld) { - ret ~"expected a record with field `" + *e_fld + + return ~"expected a record with field `" + *e_fld + ~"` but found one with field `" + *a_fld + ~"`"; } - terr_arg_count { ret ~"incorrect number of function parameters"; } + terr_arg_count { return ~"incorrect number of function parameters"; } terr_mode_mismatch(e_mode, a_mode) { - ret ~"expected argument mode " + mode_to_str(e_mode) + + return ~"expected argument mode " + mode_to_str(e_mode) + ~" but found " + mode_to_str(a_mode); } terr_regions_differ(subregion, superregion) { - ret fmt!{"%s does not necessarily outlive %s", + return fmt!{"%s does not necessarily outlive %s", explain_region(cx, subregion), explain_region(cx, superregion)}; } terr_vstores_differ(k, e_vs, a_vs) { - ret fmt!{"%s storage differs: expected %s but found %s", + return fmt!{"%s storage differs: expected %s but found %s", terr_vstore_kind_to_str(k), vstore_to_str(cx, e_vs), vstore_to_str(cx, a_vs)}; } terr_in_field(err, fname) { - ret fmt!{"in field `%s`, %s", *fname, type_err_to_str(cx, *err)}; + return fmt!{"in field `%s`, %s", *fname, type_err_to_str(cx, *err)}; } terr_sorts(exp, act) { - ret fmt!{"%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)}; + return fmt!{"%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act)}; } terr_self_substs { - ret ~"inconsistent self substitution"; // XXX this is more of a bug + return ~"inconsistent self substitution"; // XXX this is more of a bug } terr_no_integral_type { - ret ~"couldn't determine an appropriate integral type for integer \ + return ~"couldn't determine an appropriate integral type for integer \ literal"; } } @@ -2629,7 +2633,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) { - some(ms) { ret ms; } + some(ms) { return ms; } _ {} } // Local traits are supposed to have been added explicitly. @@ -2789,7 +2793,7 @@ fn type_is_empty(cx: ctxt, t: t) -> bool { fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { alt cx.enum_var_cache.find(id) { - some(variants) { ret variants; } + some(variants) { return variants; } _ { /* fallthrough */ } } @@ -2844,7 +2848,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id, let mut i = 0u; while i < vec::len::<variant_info>(*variants) { let variant = variants[i]; - if ast_util::def_eq(variant.id, variant_id) { ret variant; } + if ast_util::def_eq(variant.id, variant_id) { return variant; } i += 1u; } cx.sess.bug(~"enum_variant_with_id(): no variant exists with that ID"); @@ -2855,14 +2859,14 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id, // 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) { - some(tpt) { ret tpt; } + some(tpt) { return tpt; } none { // The item is in this crate. The caller should have added it to the // type cache already assert did.crate != ast::local_crate; let tyt = csearch::get_type(cx, did); cx.tcache.insert(did, tyt); - ret tyt; + return tyt; } } } @@ -2908,7 +2912,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { } } else { - ret csearch::get_class_fields(cx, did); + return csearch::get_class_fields(cx, did); } } @@ -2962,7 +2966,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, let ms = lookup_class_method_ids(cx, did); for ms.each |m| { if m.name == name { - ret ast_util::local_def(m.id); + return ast_util::local_def(m.id); } } cx.sess.span_fatal(sp, fmt!{"Class doesn't have a method \ @@ -3087,7 +3091,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { /*bot*/ ~[f, f, f, f, t, t, f, f], /*struct*/ ~[t, t, t, t, t, t, t, t]]; - ret tbl[tycat(ty)][opcat(op)]; + return tbl[tycat(ty)][opcat(op)]; } fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] { @@ -3099,7 +3103,7 @@ fn ty_params_to_tys(tcx: ty::ctxt, tps: ~[ast::ty_param]) -> ~[t] { /// Returns an equivalent type with all the typedefs and self regions removed. fn normalize_ty(cx: ctxt, t: t) -> t { alt cx.normalized_cache.find(t) { - some(t) { ret t; } + some(t) { return t; } none { } } @@ -3136,7 +3140,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t { let sty = fold_sty(get(t).struct, |t| { normalize_ty(cx, t) }); let t_norm = mk_t(cx, sty); cx.normalized_cache.insert(t, t_norm); - ret t_norm; + return t_norm; } // Local Variables: diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index bf7069f87e2..adc47d5fad4 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -228,13 +228,13 @@ fn require_same_types( fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool { alt ty::get(a.ty).struct { ty::ty_evec(mt, vstore_uniq) { - if mt.mutbl != ast::m_imm { ret false; } + if mt.mutbl != ast::m_imm { return false; } alt ty::get(mt.ty).struct { - ty::ty_estr(vstore_uniq) { ret true; } - _ { ret false; } + ty::ty_estr(vstore_uniq) { return true; } + _ { return false; } } } - _ { ret false; } + _ { return false; } } } @@ -253,7 +253,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt, 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"); - ret; + return; } _ {} } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index 1dd8cde5084..632a29ba8e8 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -142,7 +142,7 @@ fn ast_path_to_ty<AC: ast_conv, RS: region_scope copy owned>( ast_path_to_substs_and_ty(self, rscope, did, path); write_ty_to_tcx(tcx, path_id, ty); write_substs_to_tcx(tcx, path_id, substs.tps); - ret {substs: substs, ty: ty}; + return {substs: substs, ty: ty}; } const NO_REGIONS: uint = 1u; @@ -157,7 +157,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( fn ast_mt_to_mt<AC: ast_conv, RS: region_scope copy owned>( self: AC, rscope: RS, mt: ast::mt) -> ty::mt { - ret {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl}; + return {ty: ast_ty_to_ty(self, rscope, mt.ty), mutbl: mt.mutbl}; } // Handle @, ~, and & being able to mean estrs and evecs. @@ -172,13 +172,13 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( // 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) { - ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst); + return ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst); } ast::ty_path(path, id) { alt tcx.def_map.find(id) { some(ast::def_prim_ty(ast::ty_str)) { check_path_args(tcx, path, NO_TPS | NO_REGIONS); - ret ty::mk_estr(tcx, vst); + return ty::mk_estr(tcx, vst); } _ {} } @@ -187,7 +187,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( } let seq_ty = ast_mt_to_mt(self, rscope, a_seq_ty); - ret constr(seq_ty); + return constr(seq_ty); } fn check_path_args(tcx: ty::ctxt, @@ -213,7 +213,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) { - some(ty::atttce_resolved(ty)) { ret ty; } + some(ty::atttce_resolved(ty)) { return ty; } some(ty::atttce_unresolved) { tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ insert an enum in the cycle, \ @@ -348,7 +348,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_resolved(typ)); - ret typ; + return typ; } fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>( diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 440ec24092e..862bf2cfaa4 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -157,9 +157,9 @@ impl methods of get_and_find_region for isr_alist { fn find(br: ty::bound_region) -> option<ty::region> { for list::each(self) |isr| { let (isr_br, isr_r) = isr; - if isr_br == br { ret some(isr_r); } + if isr_br == br { return some(isr_r); } } - ret none; + return none; } } @@ -653,7 +653,7 @@ impl methods for @fn_ctxt { self.region_lb = lb; let v <- f(); self.region_lb = old_region_lb; - ret v; + return v; } } @@ -681,7 +681,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { // reported on the enum definition as well because the enum is not // instantiable. if vec::contains(enum_dids, did) { - ret t1; + return t1; } vec::push(enum_dids, did); } @@ -690,7 +690,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) { - none { ret t1; } + none { return t1; } some(mt) { t1 = mt.ty; } } }; @@ -726,7 +726,7 @@ fn check_expr_with(fcx: @fn_ctxt, expr: @ast::expr, expected: ty::t) -> bool { fn check_expr(fcx: @fn_ctxt, expr: @ast::expr, expected: option<ty::t>) -> bool { - ret do check_expr_with_unifier(fcx, expr, expected) { + return do check_expr_with_unifier(fcx, expr, expected) { for expected.each |t| { demand::suptype(fcx, expr.span, t, fcx.expr_ty(expr)); } @@ -898,7 +898,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let mut bot = check_expr(fcx, lhs, none); bot |= check_expr_with(fcx, rhs, fcx.expr_ty(lhs)); fcx.write_ty(id, ty::mk_nil(fcx.ccx.tcx)); - ret bot; + return bot; } // A generic function for doing all of the checking for call expressions @@ -928,7 +928,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ty::ty_fn(f) { bot |= (f.ret_style == ast::noreturn); fcx.write_ty(call_expr_id, f.output); - ret bot; + return bot; } _ { fcx.ccx.tcx.sess.span_fatal(sp, ~"calling non-function"); } } @@ -945,7 +945,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let bot = check_decl_local(fcx, local); check_block_no_value(fcx, body); fcx.write_nil(node_id); - ret bot; + return bot; } // A generic function for checking the then and else in an if @@ -969,7 +969,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } }; fcx.write_ty(id, if_t); - ret if_bot; + return if_bot; } fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr, @@ -1000,7 +1000,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); - ret alt (op, ty::get(lhs_t).struct) { + return alt (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 @@ -1049,7 +1049,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, alt lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t, name, ~[rhs]) { - some(pair) { ret pair; } + some(pair) { return pair; } _ {} } } @@ -1242,7 +1242,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } } } - ret bot; + return bot; } @@ -1421,8 +1421,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, alt fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) { result::ok(_) { /* fall through */ } result::err(_) { - tcx.sess.span_err(expr.span, - ~"`ret;` in function returning non-nil"); } + tcx.sess.span_err( + expr.span, + ~"`return;` in function returning non-nil"); } } } some(e) { check_expr_with(fcx, e, ret_ty); } @@ -1902,7 +1903,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, unifier(); debug!{"<< bot=%b", bot}; - ret bot; + return bot; } fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) { @@ -1916,7 +1917,7 @@ fn require_integral(fcx: @fn_ctxt, sp: span, t: ty::t) { fn check_decl_initializer(fcx: @fn_ctxt, nid: ast::node_id, init: ast::initializer) -> bool { let lty = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, init.expr.span, nid)); - ret check_expr_with(fcx, init.expr, lty); + return check_expr_with(fcx, init.expr, lty); } fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { @@ -1941,7 +1942,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { pat_region: region }; alt::check_pat(pcx, local.node.pat, t); - ret bot; + return bot; } fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool { @@ -1967,7 +1968,7 @@ fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool { } } fcx.write_nil(node_id); - ret bot; + return bot; } fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool { @@ -1977,7 +1978,7 @@ fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool { let nilty = ty::mk_nil(fcx.ccx.tcx); demand::suptype(fcx, blk.span, nilty, blkty); } - ret bot; + return bot; } fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { @@ -2160,17 +2161,17 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ast::def_arg(nid, _) { assert (fcx.locals.contains_key(nid)); let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid)); - ret no_params(typ); + return no_params(typ); } ast::def_local(nid, _) { assert (fcx.locals.contains_key(nid)); let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid)); - ret no_params(typ); + return no_params(typ); } ast::def_self(_) { alt fcx.self_info { some(self_info) { - ret no_params(self_info.self_ty); + return no_params(self_info.self_ty); } none { fcx.ccx.tcx.sess.span_bug(sp, ~"def_self with no self_info"); @@ -2179,7 +2180,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> } ast::def_fn(id, ast::extern_fn) { // extern functions are just u8 pointers - ret { + return { bounds: @~[], rp: false, ty: ty::mk_ptr( @@ -2194,26 +2195,26 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ast::def_fn(id, ast::unsafe_fn) { // Unsafe functions can only be touched in an unsafe context fcx.require_unsafe(sp, ~"access to unsafe function"); - ret ty::lookup_item_type(fcx.ccx.tcx, id); + return ty::lookup_item_type(fcx.ccx.tcx, id); } ast::def_fn(id, _) | ast::def_const(id) | ast::def_variant(_, id) | ast::def_class(id, _) { - ret ty::lookup_item_type(fcx.ccx.tcx, id); + return ty::lookup_item_type(fcx.ccx.tcx, id); } ast::def_binding(nid) { assert (fcx.locals.contains_key(nid)); let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid)); - ret no_params(typ); + return no_params(typ); } ast::def_ty(_) | ast::def_prim_ty(_) { fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found type"); } ast::def_upvar(_, inner, _) { - ret ty_param_bounds_and_ty_for_def(fcx, sp, *inner); + return ty_param_bounds_and_ty_for_def(fcx, sp, *inner); } ast::def_ty_param(did, n) { - ret no_params(ty::mk_param(fcx.ccx.tcx, n, did)); + return no_params(ty::mk_param(fcx.ccx.tcx, n, did)); } ast::def_mod(*) | ast::def_foreign_mod(*) { fcx.ccx.tcx.sess.span_fatal(sp, ~"expected value but found module"); @@ -2288,7 +2289,7 @@ fn instantiate_path(fcx: @fn_ctxt, // 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) { - result::ok(t_s) if !ty::type_is_var(t_s) { ret t_s; } + result::ok(t_s) if !ty::type_is_var(t_s) { return t_s; } _ { fcx.ccx.tcx.sess.span_fatal (sp, ~"the type of this value must be known in this context"); @@ -2303,17 +2304,17 @@ fn structure_of(fcx: @fn_ctxt, sp: span, typ: ty::t) -> ty::sty { fn type_is_integral(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool { let typ_s = structurally_resolved_type(fcx, sp, typ); - ret ty::type_is_integral(typ_s); + return ty::type_is_integral(typ_s); } fn type_is_scalar(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool { let typ_s = structurally_resolved_type(fcx, sp, typ); - ret ty::type_is_scalar(typ_s); + return ty::type_is_scalar(typ_s); } fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool { let typ_s = structurally_resolved_type(fcx, sp, typ); - ret ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s); + return ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s); } fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, @@ -2350,7 +2351,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt, tps: ~[ast::ty_param], ty: ty::t) { // make a vector of booleans initially false, set to true when used - if tps.len() == 0u { ret; } + if tps.len() == 0u { return; } let tps_used = vec::to_mut(vec::from_elem(tps.len(), false)); ty::walk_regions_and_ty( @@ -2437,7 +2438,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { other { tcx.sess.span_err(it.span, ~"unrecognized intrinsic function: `" + other + ~"`"); - ret; + return; } }; let fty = ty::mk_fn(tcx, {purity: ast::impure_fn, diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index 5cc8a953722..b0106f44cfc 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -40,7 +40,7 @@ fn check_alt(fcx: @fn_ctxt, bot |= !arm_non_bot; if !arm_non_bot { result_ty = ty::mk_bot(tcx); } fcx.write_ty(expr.id, result_ty); - ret bot; + return bot; } type pat_ctxt = { @@ -197,7 +197,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { ex_f_count, f_count}); } fn matches(name: ast::ident, f: ty::field) -> bool { - ret str::eq(*name, *f.ident); + return str::eq(*name, *f.ident); } for fields.each |f| { alt vec::find(ex_fields, |a| matches(f.ident, a)) { diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 08f36bdb256..efd2756a607 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -160,7 +160,7 @@ class lookup { } } - if self.candidates.len() == 0u { ret none; } + if self.candidates.len() == 0u { return none; } if self.candidates.len() > 1u { self.tcx().sess.span_err( @@ -359,7 +359,7 @@ class lookup { // multiple-methods-in-scope errors. if self.fcx.ccx.trait_map.contains_key(self.expr.id) { - ret; + return; } let impls_vecs = self.fcx.ccx.impl_map.get(self.expr.id); @@ -376,7 +376,7 @@ class lookup { // we want to find the innermost scope that has any // matches and then ignore outer scopes - if added_any {ret;} + if added_any {return;} } } @@ -428,7 +428,7 @@ class lookup { } } - ret added_any; + return added_any; } fn add_candidates_from_m(self_substs: ty::substs, @@ -563,7 +563,7 @@ class lookup { self.fcx.write_ty_substs(self.node_id, cand.fty, all_substs); - ret cand.entry; + return cand.entry; } } diff --git a/src/rustc/middle/typeck/check/regionck.rs b/src/rustc/middle/typeck/check/regionck.rs index 50e2d5db973..6e9293dd8e9 100644 --- a/src/rustc/middle/typeck/check/regionck.rs +++ b/src/rustc/middle/typeck/check/regionck.rs @@ -93,7 +93,7 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) { let e = rcx.errors_reported; v.visit_pat(l.node.pat, rcx, v); if e != rcx.errors_reported { - ret; // if decl has errors, skip initializer expr + return; // if decl has errors, skip initializer expr } v.visit_ty(l.node.ty, rcx, v); @@ -131,7 +131,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { // 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) { - ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) { ret; } + ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) { return; } _ { } } } @@ -151,7 +151,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { // check_cast_for_escaping_regions() in kind.rs explaining how // it goes about doing that. alt rcx.resolve_node_type(e.id) { - result::err(_) => { ret; /* typeck will fail anyhow */ } + result::err(_) => { return; /* typeck will fail anyhow */ } result::ok(target_ty) => { alt ty::get(target_ty).struct { ty::ty_trait(_, substs) { @@ -173,7 +173,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { _ { } } - if !visit_node(e.id, e.span, rcx) { ret; } + if !visit_node(e.id, e.span, rcx) { return; } visit::visit_expr(e, rcx, v); } @@ -192,7 +192,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool { // 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) { - result::err(_) { ret true; } + result::err(_) { return true; } result::ok(ty) { ty } }; @@ -206,7 +206,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool { ppaux::region_to_str(tcx, encl_region)}; // Otherwise, look at the type and see if it is a region pointer. - ret constrain_regions_in_type(rcx, encl_region, span, ty); + return constrain_regions_in_type(rcx, encl_region, span, ty); } fn constrain_regions_in_type( @@ -220,7 +220,7 @@ fn constrain_regions_in_type( rcx.fcx.ccx.tcx, ty, |r| constrain_region(rcx, encl_region, span, r), |t| ty::type_has_regions(t)); - ret (e == rcx.errors_reported); + return (e == rcx.errors_reported); fn constrain_region(rcx: @rcx, encl_region: ty::region, @@ -238,7 +238,7 @@ fn constrain_regions_in_type( // (e.g., the `&` in `fn(&T)`). Such regions need not be // constrained by `encl_region` as they are placeholders // for regions that are as-yet-unknown. - ret; + return; } _ {} } diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index 5bbe9bb1867..a2bfc9c3ffa 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -56,7 +56,7 @@ fn replace_bound_regions_in_fn_ty( none { none } }; - ret {isr: isr, + return {isr: isr, self_info: new_self_info, fn_ty: alt check ty::get(t_fn).struct { ty::ty_fn(o) {o} }}; @@ -169,7 +169,7 @@ fn replace_bound_regions_in_fn_ty( */ fn region_of(fcx: @fn_ctxt, expr: @ast::expr) -> ty::region { debug!{"region_of(expr=%s)", expr_to_str(expr)}; - ret alt expr.node { + return alt expr.node { ast::expr_path(path) { def(fcx, expr, lookup_def(fcx, path.span, expr.id))} ast::expr_field(base, _, _) { diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index 6baa89e0638..a4b8bf021e1 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -81,7 +81,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, debug!{"(checking vtable) @0 relating ty to trait ty with did %?", idid}; relate_trait_tys(fcx, sp, trait_ty, ity); - ret vtable_param(n, n_bound); + return vtable_param(n, n_bound); } } } @@ -110,7 +110,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, } } } - ret vtable_trait(did, substs.tps); + return vtable_trait(did, substs.tps); } _ { @@ -178,11 +178,11 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, alt found.len() { 0u { /* fallthrough */ } - 1u { ret found[0]; } + 1u { return found[0]; } _ { fcx.ccx.tcx.sess.span_err( sp, ~"multiple applicable methods in scope"); - ret found[0]; + return found[0]; } } } diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index d9615c88583..726cc2a7c70 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -9,9 +9,9 @@ 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) { ret some(typ); } + if !ty::type_needs_infer(typ) { return some(typ); } alt resolve_type(fcx.infcx, typ, resolve_all | force_all) { - result::ok(new_type) { ret some(new_type); } + result::ok(new_type) { return some(new_type); } result::err(e) { if !fcx.ccx.tcx.sess.has_errors() { fcx.ccx.tcx.sess.span_err( @@ -20,7 +20,7 @@ fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) -> for this expression: %s", infer::fixup_err_to_str(e)}) } - ret none; + return none; } } } @@ -31,7 +31,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) alt resolve_type_vars_in_type(fcx, sp, n_ty) { none { wbcx.success = false; - ret none; + return none; } some(t) { @@ -44,14 +44,14 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) for substs.tps.each |subst| { alt resolve_type_vars_in_type(fcx, sp, subst) { some(t) { vec::push(new_tps, t); } - none { wbcx.success = false; ret none; } + none { wbcx.success = false; return none; } } } write_substs_to_tcx(tcx, id, new_tps); } none {} } - ret some(t); + return some(t); } } } @@ -73,12 +73,12 @@ type wb_ctxt = type wb_vt = visit::vt<wb_ctxt>; fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) { - if !wbcx.success { ret; } + if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, s.span, ty::stmt_node_id(s)); visit::visit_stmt(s, wbcx, v); } fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { - if !wbcx.success { ret; } + if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, e.span, e.id); alt e.node { ast::expr_fn(_, decl, _, _) | @@ -113,12 +113,12 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { visit::visit_expr(e, wbcx, v); } fn visit_block(b: ast::blk, wbcx: wb_ctxt, v: wb_vt) { - if !wbcx.success { ret; } + if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, b.span, b.node.id); visit::visit_block(b, wbcx, v); } fn visit_pat(p: @ast::pat, wbcx: wb_ctxt, v: wb_vt) { - if !wbcx.success { ret; } + if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, p.span, p.id); debug!{"Type for pattern binding %s (id %d) resolved to %s", pat_to_str(p), p.id, @@ -128,7 +128,7 @@ fn visit_pat(p: @ast::pat, wbcx: wb_ctxt, v: wb_vt) { visit::visit_pat(p, wbcx, v); } fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) { - if !wbcx.success { ret; } + 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) { @@ -170,7 +170,7 @@ fn resolve_type_vars_in_expr(fcx: @fn_ctxt, e: @ast::expr) -> bool { if wbcx.success { infer::resolve_borrowings(fcx.infcx); } - ret wbcx.success; + return wbcx.success; } fn resolve_type_vars_in_fn(fcx: @fn_ctxt, @@ -185,5 +185,5 @@ fn resolve_type_vars_in_fn(fcx: @fn_ctxt, if wbcx.success { infer::resolve_borrowings(fcx.infcx); } - ret wbcx.success; + return wbcx.success; } diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index af074ddb7ab..4de713030d9 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -90,14 +90,14 @@ fn get_base_type_def_id(inference_context: infer_ctxt, alt get_base_type(inference_context, span, original_type) { none { - ret none; + return none; } some(base_type) { alt get(base_type).struct { ty_enum(def_id, _) | ty_class(def_id, _) | ty_trait(def_id, _) { - ret some(def_id); + return some(def_id); } _ { fail ~"get_base_type() returned a type that wasn't an \ @@ -319,7 +319,8 @@ class CoherenceChecker { let monotype_a = self.universally_quantify_polytype(polytype_a); let monotype_b = self.universally_quantify_polytype(polytype_b); - ret mk_subty(self.inference_context, monotype_a, monotype_b).is_ok() + return + mk_subty(self.inference_context, monotype_a, monotype_b).is_ok() || mk_subty(self.inference_context, monotype_b, monotype_a).is_ok(); } @@ -341,13 +342,13 @@ class CoherenceChecker { tps: type_parameters }; - ret subst(self.crate_context.tcx, substitutions, polytype.ty); + return subst(self.crate_context.tcx, substitutions, polytype.ty); } fn get_self_type_for_implementation(implementation: @Impl) -> ty_param_bounds_and_ty { - ret self.crate_context.tcx.tcache.get(implementation.did); + return self.crate_context.tcx.tcache.get(implementation.did); } // Privileged scope checking @@ -480,7 +481,7 @@ class CoherenceChecker { } } - ret results; + return results; } // Converts an implementation in the AST to an Impl structure. @@ -497,7 +498,7 @@ class CoherenceChecker { }); } - ret @{ + return @{ did: local_def(item.id), ident: item.ident, methods: methods @@ -521,7 +522,7 @@ class CoherenceChecker { } } - ret @{ + return @{ did: local_def(item.id), ident: item.ident, methods: methods @@ -539,7 +540,7 @@ class CoherenceChecker { assert implementation.did.crate == local_crate; alt self.crate_context.tcx.items.find(implementation.did.node) { some(node_item(item, _)) { - ret item.span; + return item.span; } _ { self.crate_context.tcx.sess.bug(~"span_of_impl() called on \ diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 3cbd82cc683..aab71d1b72b 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -190,7 +190,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, if impl_m.tps != if_m.tps { tcx.sess.span_err(sp, ~"method `" + *if_m.ident + ~"` has an incompatible set of type parameters"); - ret; + return; } if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) { @@ -199,7 +199,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, *if_m.ident, vec::len(impl_m.fty.inputs), vec::len(if_m.fty.inputs)}); - ret; + return; } // Perform substitutions so that the trait/impl methods are expressed @@ -230,7 +230,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, require_same_types( tcx, none, sp, impl_fty, if_fty, || ~"method `" + *if_m.ident + ~"` has an incompatible type"); - ret; + return; // Replaces bound references to the self region with `with_r`. fn replace_bound_self(tcx: ty::ctxt, ty: ty::t, @@ -485,7 +485,7 @@ 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) { - some(tpt) { ret tpt; } + some(tpt) { return tpt; } _ {} } let rp = tcx.region_paramd_items.contains_key(it.id); @@ -494,7 +494,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) let typ = ccx.to_ty(empty_rscope, t); let tpt = no_params(typ); tcx.tcache.insert(local_def(it.id), tpt); - ret tpt; + return tpt; } ast::item_fn(decl, tps, _) { let bounds = ty_param_bounds(ccx, tps); @@ -506,11 +506,11 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) debug!{"type of %s (id %d) is %s", *it.ident, it.id, ty_to_str(tcx, tpt.ty)}; ccx.tcx.tcache.insert(local_def(it.id), tpt); - ret tpt; + return tpt; } ast::item_ty(t, tps) { alt tcx.tcache.find(local_def(it.id)) { - some(tpt) { ret tpt; } + some(tpt) { return tpt; } none { } } @@ -530,7 +530,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) }; tcx.tcache.insert(local_def(it.id), tpt); - ret tpt; + return tpt; } ast::item_enum(_, tps) { // Create a new generic polytype. @@ -538,21 +538,21 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) let t = ty::mk_enum(tcx, local_def(it.id), substs); let tpt = {bounds: bounds, rp: rp, ty: t}; tcx.tcache.insert(local_def(it.id), tpt); - ret tpt; + return tpt; } ast::item_trait(tps, ms) { let {bounds, substs} = mk_substs(ccx, tps, rp); let t = ty::mk_trait(tcx, local_def(it.id), substs); let tpt = {bounds: bounds, rp: rp, ty: t}; tcx.tcache.insert(local_def(it.id), tpt); - ret tpt; + return tpt; } ast::item_class(tps, _, _, _, _) { let {bounds,substs} = mk_substs(ccx, tps, rp); let t = ty::mk_class(tcx, local_def(it.id), substs); let tpt = {bounds: bounds, rp: rp, ty: t}; tcx.tcache.insert(local_def(it.id), tpt); - ret tpt; + return tpt; } ast::item_impl(*) | ast::item_mod(_) | ast::item_foreign_mod(_) { fail; } @@ -564,7 +564,7 @@ fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item) -> ty::ty_param_bounds_and_ty { alt it.node { ast::foreign_item_fn(fn_decl, params) { - ret ty_of_foreign_fn_decl(ccx, fn_decl, params, + return ty_of_foreign_fn_decl(ccx, fn_decl, params, local_def(it.id)); } } @@ -627,7 +627,7 @@ fn ty_of_foreign_fn_decl(ccx: @crate_ctxt, ret_style: ast::return_val}); let tpt = {bounds: bounds, rp: false, ty: t_fn}; ccx.tcx.tcache.insert(def_id, tpt); - ret tpt; + return tpt; } fn mk_ty_params(ccx: @crate_ctxt, atps: ~[ast::ty_param]) diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index 68420c32de4..b1ad11327a7 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -233,17 +233,17 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) -> option<ty::t> { debug!{"single_type_contained_in(a=%s)", uint::to_str(*a, 10u)}; - if *a == INT_TY_SET_i8 { ret some(ty::mk_i8(tcx)); } - if *a == INT_TY_SET_u8 { ret some(ty::mk_u8(tcx)); } - if *a == INT_TY_SET_i16 { ret some(ty::mk_i16(tcx)); } - if *a == INT_TY_SET_u16 { ret some(ty::mk_u16(tcx)); } - if *a == INT_TY_SET_i32 { ret some(ty::mk_i32(tcx)); } - if *a == INT_TY_SET_u32 { ret some(ty::mk_u32(tcx)); } - if *a == INT_TY_SET_i64 { ret some(ty::mk_i64(tcx)); } - if *a == INT_TY_SET_u64 { ret some(ty::mk_u64(tcx)); } - if *a == INT_TY_SET_i { ret some(ty::mk_int(tcx)); } - if *a == INT_TY_SET_u { ret some(ty::mk_uint(tcx)); } - ret none; + if *a == INT_TY_SET_i8 { return some(ty::mk_i8(tcx)); } + if *a == INT_TY_SET_u8 { return some(ty::mk_u8(tcx)); } + if *a == INT_TY_SET_i16 { return some(ty::mk_i16(tcx)); } + if *a == INT_TY_SET_u16 { return some(ty::mk_u16(tcx)); } + if *a == INT_TY_SET_i32 { return some(ty::mk_i32(tcx)); } + if *a == INT_TY_SET_u32 { return some(ty::mk_u32(tcx)); } + if *a == INT_TY_SET_i64 { return some(ty::mk_i64(tcx)); } + if *a == INT_TY_SET_u64 { return some(ty::mk_u64(tcx)); } + if *a == INT_TY_SET_i { return some(ty::mk_int(tcx)); } + if *a == INT_TY_SET_u { return some(ty::mk_uint(tcx)); } + return none; } fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) @@ -594,7 +594,7 @@ impl transaction_methods for infer_ctxt { self.tvb.bindings = ~[]; self.rb.bindings = ~[]; - ret r; + return r; } /// Execute `f`, unroll bindings on failure @@ -615,7 +615,7 @@ impl transaction_methods for infer_ctxt { while self.borrowings.len() != bl { self.borrowings.pop(); } } } - ret r; + return r; } /// Execute `f` then unroll any bindings it creates @@ -625,7 +625,7 @@ impl transaction_methods for infer_ctxt { let r <- f(); rollback_to(self.tvb, 0u); rollback_to(self.rb, 0u); - ret r; + return r; } } @@ -635,7 +635,7 @@ impl methods for infer_ctxt { *self.ty_var_counter += 1u; self.tvb.vals.insert(id, root({lb: none, ub: none}, 0u)); - ret tv_vid(id); + return tv_vid(id); } fn next_ty_var() -> ty::t { @@ -652,7 +652,7 @@ impl methods for infer_ctxt { self.tvib.vals.insert(id, root(int_ty_set_all(), 0u)); - ret tvi_vid(id); + return tvi_vid(id); } fn next_ty_var_integral() -> ty::t { @@ -663,7 +663,7 @@ impl methods for infer_ctxt { let id = *self.region_var_counter; *self.region_var_counter += 1u; self.rb.vals.insert(id, root(bnds, 0)); - ret region_vid(id); + return region_vid(id); } fn next_region_var_with_scope_lb(scope_id: ast::node_id) -> ty::region { @@ -686,15 +686,15 @@ impl methods for infer_ctxt { fn resolve_type_vars_if_possible(typ: ty::t) -> ty::t { alt resolve_type(self, typ, resolve_all) { - result::ok(new_type) { ret new_type; } - result::err(_) { ret typ; } + 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) { - result::ok(newr) { ret newr; } - result::err(_) { ret oldr; } + result::ok(newr) { return newr; } + result::err(_) { return oldr; } } } } @@ -859,7 +859,7 @@ impl unify_methods for infer_ctxt { a_id.to_str(), a_bounds.to_str(self), b_id.to_str(), b_bounds.to_str(self)}; - if a_id == b_id { ret uok(); } + if a_id == b_id { return uok(); } // If both A's UB and B's LB have already been bound to types, // see if we can make those types subtypes. @@ -867,7 +867,7 @@ impl unify_methods for infer_ctxt { (some(a_ub), some(b_lb)) { let r = self.try(|| a_ub.sub(self, b_lb)); alt r { - ok(()) { ret result::ok(()); } + ok(()) { return result::ok(()); } err(_) { /*fallthrough */ } } } @@ -921,13 +921,13 @@ impl unify_methods for infer_ctxt { // If we're already dealing with the same two variables, // there's nothing to do. - if a_id == b_id { ret uok(); } + if a_id == b_id { return uok(); } // Otherwise, take the intersection of the two sets of // possible types. let intersection = intersection(a_pt, b_pt); if *intersection == INT_TY_SET_EMPTY { - ret err(ty::terr_no_integral_type); + return err(ty::terr_no_integral_type); } // Rank optimization @@ -985,7 +985,7 @@ impl unify_methods for infer_ctxt { intersection(a_pt, convert_integral_ty_to_int_ty_set( self.tcx, b)); if *intersection == INT_TY_SET_EMPTY { - ret err(ty::terr_no_integral_type); + return err(ty::terr_no_integral_type); } self.set(vb, a_id, root(intersection, nde_a.rank)); uok() @@ -1021,7 +1021,7 @@ impl unify_methods for infer_ctxt { intersection(b_pt, convert_integral_ty_to_int_ty_set( self.tcx, a)); if *intersection == INT_TY_SET_EMPTY { - ret err(ty::terr_no_integral_type); + return err(ty::terr_no_integral_type); } self.set(vb, b_id, root(intersection, nde_b.rank)); uok() @@ -1156,9 +1156,9 @@ impl methods for resolve_state { debug!{"Resolved to %s (modes=%x)", ty_to_str(self.infcx.tcx, rty), self.modes}; - ret ok(rty); + return ok(rty); } - some(e) { ret err(e); } + some(e) { return err(e); } } } @@ -1174,7 +1174,7 @@ impl methods for resolve_state { fn resolve_type(typ: ty::t) -> ty::t { debug!{"resolve_type(%s)", typ.to_str(self.infcx)}; indent(fn&() -> ty::t { - if !ty::type_needs_infer(typ) { ret typ; } + if !ty::type_needs_infer(typ) { return typ; } alt ty::get(typ).struct { ty::ty_var(vid) { @@ -1219,7 +1219,7 @@ impl methods for resolve_state { fn resolve_region_var(rid: region_vid) -> ty::region { if !self.should(resolve_rvar) { - ret ty::re_var(rid) + return ty::re_var(rid) } let nde = self.infcx.get(self.infcx.rb, rid); let bounds = nde.possible_types; @@ -1247,7 +1247,7 @@ impl methods for resolve_state { fn resolve_ty_var(vid: tv_vid) -> ty::t { if vec::contains(self.v_seen, vid) { self.err = some(cyclic_ty(vid)); - ret ty::mk_var(self.infcx.tcx, vid); + return ty::mk_var(self.infcx.tcx, vid); } else { vec::push(self.v_seen, vid); let tcx = self.infcx.tcx; @@ -1273,13 +1273,13 @@ impl methods for resolve_state { } }; vec::pop(self.v_seen); - ret t1; + return t1; } } fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t { if !self.should(resolve_ivar) { - ret ty::mk_var_integral(self.infcx.tcx, vid); + return ty::mk_var_integral(self.infcx.tcx, vid); } let nde = self.infcx.get(self.infcx.tvib, vid); @@ -1938,7 +1938,7 @@ impl of combine for sub { debug!{"mts(%s <: %s)", a.to_str(*self), b.to_str(*self)}; if a.mutbl != b.mutbl && b.mutbl != m_const { - ret err(ty::terr_mutability); + return err(ty::terr_mutability); } alt b.mutbl { @@ -1975,7 +1975,7 @@ impl of combine for sub { fn tys(a: ty::t, b: ty::t) -> cres<ty::t> { debug!{"%s.tys(%s, %s)", self.tag(), a.to_str(*self), b.to_str(*self)}; - if a == b { ret ok(a); } + if a == b { return ok(a); } do indent { alt (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) { @@ -2146,7 +2146,7 @@ impl of combine for lub { } fn contraregions(a: ty::region, b: ty::region) -> cres<ty::region> { - ret glb(self.infcx()).regions(a, b); + return glb(self.infcx()).regions(a, b); } fn regions(a: ty::region, b: ty::region) -> cres<ty::region> { @@ -2489,7 +2489,7 @@ fn lattice_tys<L:lattice_ops combine>( debug!{"%s.lattice_tys(%s, %s)", self.tag(), a.to_str(self.infcx()), b.to_str(self.infcx())}; - if a == b { ret ok(a); } + if a == b { return ok(a); } do indent { alt (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) { self.ty_bot(b) } @@ -2568,7 +2568,7 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>( b_vid.to_str(), b_bounds.to_str(self.infcx())}; if a_vid == b_vid { - ret ok(a_t); + return ok(a_t); } // If both A and B have an UB type, then we can just compute the @@ -2577,7 +2577,7 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>( alt (a_bnd, b_bnd) { (some(a_ty), some(b_ty)) { alt self.infcx().try(|| c_ts(a_ty, b_ty) ) { - ok(t) { ret ok(t); } + ok(t) { return ok(t); } err(_) { /*fallthrough */ } } } @@ -2610,7 +2610,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>( 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())}; - ret c_ts(a_bnd, b); + return c_ts(a_bnd, b); } none { // If a does not have an upper bound, make b the upper bound of a diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index b9f4d3d76ae..ff4baccc42e 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -11,7 +11,7 @@ fn indent<R>(op: fn() -> R) -> R { debug!{">>"}; let r <- op(); debug!{"<< (Result = %?)", r}; - ret r; + return r; } class _indenter { @@ -27,12 +27,12 @@ fn indenter() -> _indenter { type flag = hashmap<~str, ()>; -fn field_expr(f: ast::field) -> @ast::expr { ret f.node.expr; } +fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; } fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] { let mut es = ~[]; for fields.each |f| { vec::push(es, f.node.expr); } - ret es; + return es; } // Takes a predicate p, returns true iff p is true for any subexpressions @@ -52,7 +52,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool { let v = visit::mk_vt(@{visit_expr: visit_expr with *visit::default_visitor()}); visit::visit_block(b, rs, v); - ret *rs; + return *rs; } fn has_nonlocal_exits(b: ast::blk) -> bool { @@ -68,7 +68,7 @@ fn may_break(b: ast::blk) -> bool { } fn local_rhs_span(l: @ast::local, def: span) -> span { - alt l.node.init { some(i) { ret i.expr.span; } _ { ret def; } } + alt l.node.init { some(i) { return i.expr.span; } _ { return def; } } } fn is_main_name(path: syntax::ast_map::path) -> bool { diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index f6f0cf8b363..7fb7d4c83cb 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -25,7 +25,7 @@ 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 { - ret alt region { + return alt region { re_scope(node_id) => { let scope_str = alt cx.items.find(node_id) { some(ast_map::node_block(blk)) => { @@ -167,7 +167,7 @@ fn mt_to_str(cx: ctxt, m: mt) -> ~str { ast::m_imm { ~"" } ast::m_const { ~"const " } }; - ret mstr + ty_to_str(cx, m.ty); + return mstr + ty_to_str(cx, m.ty); } fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { @@ -234,25 +234,25 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { ast::return_val { s += ty_to_str(cx, output); } } } - ret s; + return s; } fn method_to_str(cx: ctxt, m: method) -> ~str { - ret fn_to_str( + return fn_to_str( cx, m.fty.purity, m.fty.proto, some(m.ident), m.fty.inputs, m.fty.output, m.fty.ret_style) + ~";"; } fn field_to_str(cx: ctxt, f: field) -> ~str { - ret *f.ident + ~": " + mt_to_str(cx, f.mt); + return *f.ident + ~": " + mt_to_str(cx, f.mt); } // if there is an id, print that instead of the structural type: for ty::type_def_id(typ).each |def_id| { // note that this typedef cannot have type parameters - ret ast_map::path_to_str(ty::item_path(cx, def_id)); + return ast_map::path_to_str(ty::item_path(cx, def_id)); } // pretty print the structural type representation: - ret alt ty::get(typ).struct { + return alt ty::get(typ).struct { ty_nil { ~"()" } ty_bot { ~"_|_" } ty_bool { ~"bool" } @@ -340,7 +340,7 @@ fn parameterized(cx: ctxt, fn ty_to_short_str(cx: ctxt, typ: t) -> ~str { let mut s = encoder::encoded_ty(cx, typ); if str::len(s) >= 32u { s = str::slice(s, 0u, 32u); } - ret s; + return s; } // Local Variables: diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index 5b7cc1df001..cd931578c32 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -64,7 +64,7 @@ fn run<T>(owner: srv_owner<T>, source: ~str, +parse: parser) -> T { let res = owner(srv_); comm::send(srv_.ch, exit); - ret res; + return res; } fn act(po: comm::port<msg>, source: ~str, parse: parser) { diff --git a/src/rustdoc/config.rs b/src/rustdoc/config.rs index c663806bf99..5300ebe1a3b 100644 --- a/src/rustdoc/config.rs +++ b/src/rustdoc/config.rs @@ -172,7 +172,7 @@ fn config_from_opts( }) } }; - ret result; + return result; } fn parse_output_format(output_format: ~str) -> result<output_format, ~str> { @@ -197,7 +197,7 @@ fn maybe_find_pandoc( program_output: program_output ) -> result<option<~str>, ~str> { if config.output_format != pandoc_html { - ret result::ok(maybe_pandoc_cmd); + return result::ok(maybe_pandoc_cmd); } let possible_pandocs = alt maybe_pandoc_cmd { diff --git a/src/rustdoc/desc_to_brief_pass.rs b/src/rustdoc/desc_to_brief_pass.rs index c047530fec2..37a76f936d2 100644 --- a/src/rustdoc/desc_to_brief_pass.rs +++ b/src/rustdoc/desc_to_brief_pass.rs @@ -94,7 +94,7 @@ mod test { fn extract(desc: option<~str>) -> option<~str> { if option::is_none(desc) { - ret none + return none } parse_desc(option::get(desc)) diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 2aa9afe03ad..7280786db7e 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -106,7 +106,7 @@ fn pandoc_header_id(header: ~str) -> ~str { let header = convert_to_lowercase(header); let header = remove_up_to_first_letter(header); let header = maybe_use_section_id(header); - ret header; + return header; fn remove_formatting(s: ~str) -> ~str { str::replace(s, ~"`", ~"") @@ -124,7 +124,7 @@ fn pandoc_header_id(header: ~str) -> ~str { let s = str::replace(s, ~":", ~""); let s = str::replace(s, ~"&", ~""); let s = str::replace(s, ~"^", ~""); - ret s; + return s; } fn replace_with_hyphens(s: ~str) -> ~str { str::replace(s, ~" ", ~"-") diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index a880c510b89..9337f531a31 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -47,7 +47,7 @@ fn run( write_markdown(sorted_doc, writer_factory); - ret doc; + return doc; } #[test] @@ -138,7 +138,7 @@ fn make_title(page: doc::page) -> ~str { }; let title = markdown_pass::header_text(item); let title = str::replace(title, ~"`", ~""); - ret title; + return title; } #[test] @@ -378,7 +378,7 @@ fn should_write_crate_description() { fn write_index(ctxt: ctxt, index: doc::index) { if vec::is_empty(index.entries) { - ret; + return; } for index.entries.each |entry| { @@ -589,7 +589,7 @@ fn write_variants( docs: ~[doc::variantdoc] ) { if vec::is_empty(docs) { - ret; + return; } write_header_(ctxt, h4, ~"Variants"); @@ -805,7 +805,7 @@ mod test { ) -> ~str { let (writer_factory, po) = markdown_writer::future_writer_factory(); write_markdown(doc, writer_factory); - ret comm::recv(po).second(); + return comm::recv(po).second(); } fn write_markdown_str_srv( @@ -815,7 +815,7 @@ mod test { let (writer_factory, po) = markdown_writer::future_writer_factory(); let pass = mk_pass(writer_factory); pass.f(srv, doc); - ret comm::recv(po).second(); + return comm::recv(po).second(); } #[test] diff --git a/src/rustdoc/markdown_writer.rs b/src/rustdoc/markdown_writer.rs index ffc8092846c..08e39ba53da 100644 --- a/src/rustdoc/markdown_writer.rs +++ b/src/rustdoc/markdown_writer.rs @@ -142,7 +142,7 @@ fn readclose(fd: libc::c_int) -> ~str { buf += str::from_bytes(bytes); } os::fclose(file); - ret buf; + return buf; } fn generic_writer(+process: fn~(markdown: ~str)) -> writer { diff --git a/src/rustdoc/page_pass.rs b/src/rustdoc/page_pass.rs index e5e3866242d..eed559367d3 100644 --- a/src/rustdoc/page_pass.rs +++ b/src/rustdoc/page_pass.rs @@ -26,7 +26,7 @@ fn run( ) -> doc::doc { if output_style == config::doc_per_crate { - ret doc; + return doc; } let result_port = comm::port(); @@ -123,7 +123,7 @@ fn fold_nmod( let doc = fold::default_seq_fold_nmod(fold, doc); let page = doc::itempage(doc::nmodtag(doc)); comm::send(fold.ctxt, some(page)); - ret doc; + return doc; } #[test] diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index 13a5b03c5a6..b6d225df98e 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -104,14 +104,14 @@ fn main(args: ~[~str]) { if vec::contains(args, ~"-h") { config::usage(); - ret; + return; } let config = alt config::parse_config(args) { result::ok(config) { config } result::err(err) { io::println(fmt!{"error: %s", err}); - ret; + return; } }; @@ -123,7 +123,7 @@ fn time<T>(what: ~str, f: fn() -> T) -> T { let rv = f(); let end = std::time::precise_time_s(); info!{"time: %3.3f s %s", end - start, what}; - ret rv; + return rv; } /// Runs rustdoc over the given file diff --git a/src/rustdoc/sectionalize_pass.rs b/src/rustdoc/sectionalize_pass.rs index 1ca660a3488..41771966881 100644 --- a/src/rustdoc/sectionalize_pass.rs +++ b/src/rustdoc/sectionalize_pass.rs @@ -85,7 +85,7 @@ fn sectionalize(desc: option<~str>) -> (option<~str>, ~[doc::section]) { */ if option::is_none(desc) { - ret (none, ~[]); + return (none, ~[]); } let lines = str::lines(option::get(desc)); diff --git a/src/test/auxiliary/cci_class_4.rs b/src/test/auxiliary/cci_class_4.rs index 43f57c41f88..be2c982799b 100644 --- a/src/test/auxiliary/cci_class_4.rs +++ b/src/test/auxiliary/cci_class_4.rs @@ -24,11 +24,11 @@ class cat { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 95870b73c4d..36642db378f 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -27,11 +27,11 @@ class cat : to_str { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index cb3d9de652f..31ee535fcab 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -10,7 +10,7 @@ fn alist_add<A: copy, B: copy>(lst: alist<A,B>, k: A, v: B) { fn alist_get<A: copy, B: copy>(lst: alist<A,B>, k: A) -> B { let eq_fn = lst.eq_fn; for lst.data.each |entry| { - if eq_fn(entry.key, k) { ret entry.value; } + if eq_fn(entry.key, k) { return entry.value; } } fail; } @@ -18,12 +18,12 @@ fn alist_get<A: copy, B: copy>(lst: alist<A,B>, k: A) -> B { #[inline] fn new_int_alist<B: copy>() -> alist<int, B> { fn eq_int(&&a: int, &&b: int) -> bool { a == b } - ret {eq_fn: eq_int, data: dvec()}; + return {eq_fn: eq_int, data: dvec()}; } #[inline] fn new_int_alist_2<B: copy>() -> alist<int, B> { #[inline] fn eq_int(&&a: int, &&b: int) -> bool { a == b } - ret {eq_fn: eq_int, data: dvec()}; + return {eq_fn: eq_int, data: dvec()}; } \ No newline at end of file diff --git a/src/test/auxiliary/test_comm.rs b/src/test/auxiliary/test_comm.rs index 4542a23b854..007ef3bcc43 100644 --- a/src/test/auxiliary/test_comm.rs +++ b/src/test/auxiliary/test_comm.rs @@ -75,7 +75,7 @@ fn recv_<T: send>(p: *rust_port) -> T { // this is a good place to yield task::yield(); } - ret res; + return res; } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 0683624d5ff..b32047755ee 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -33,7 +33,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: fn()) { run_test = argv.contains(~"all") || argv.contains(name) } - if !run_test { ret } + if !run_test { return } let start = precise_time_s(); test(); diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs index 3a35e0c89ca..d950abb99be 100644 --- a/src/test/bench/core-vec-append.rs +++ b/src/test/bench/core-vec-append.rs @@ -9,7 +9,7 @@ fn collect_raw(num: uint) -> ~[uint] { for uint::range(0u, num) |i| { vec::push(result, i); } - ret result; + return result; } fn collect_dvec(num: uint) -> ~[mut uint] { @@ -17,7 +17,7 @@ fn collect_dvec(num: uint) -> ~[mut uint] { for uint::range(0u, num) |i| { result.push(i); } - ret dvec::unwrap(result); + return dvec::unwrap(result); } fn main(args: ~[~str]) { diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 3e3f69372b4..497f964b18a 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -320,7 +320,7 @@ fn validate(edges: ~[(node_id, node_id)], } }; - if !status { ret status } + if !status { return status } // 2. Each tree edge connects vertices whose BFS levels differ by // exactly one. @@ -336,7 +336,7 @@ fn validate(edges: ~[(node_id, node_id)], } }; - if !status { ret status } + if !status { return status } // 3. Every edge in the input list has vertices with levels that // differ by at most one or that both are not in the BFS tree. @@ -349,7 +349,7 @@ fn validate(edges: ~[(node_id, node_id)], abs(level[u] - level[v]) <= 1 }; - if !status { ret status } + if !status { return status } // 4. The BFS tree spans an entire connected component's vertices. @@ -370,7 +370,7 @@ fn validate(edges: ~[(node_id, node_id)], } }; - if !status { ret status } + if !status { return status } // If we get through here, all the tests passed! true diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index f9b698a2195..291e7c2dba5 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -2,12 +2,12 @@ use std; fn ack(m: int, n: int) -> int { if m == 0 { - ret n + 1 + return n + 1 } else { if n == 0 { - ret ack(m - 1, 1); + return ack(m - 1, 1); } else { - ret ack(m - 1, ack(m, n - 1)); + return ack(m - 1, ack(m, n - 1)); } } } diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 55e566296fc..aadf8929015 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -6,20 +6,20 @@ enum tree/& { nil, node(&tree, &tree, int), } fn item_check(t: &tree) -> int { alt *t { - nil { ret 0; } + nil { return 0; } node(left, right, item) { - ret item + item_check(left) - item_check(right); + return item + item_check(left) - item_check(right); } } } fn bottom_up_tree(arena: &arena::arena, item: int, depth: int) -> &tree { if depth > 0 { - ret new(*arena) node(bottom_up_tree(arena, 2 * item - 1, depth - 1), + return new(*arena) node(bottom_up_tree(arena, 2 * item - 1, depth - 1), bottom_up_tree(arena, 2 * item, depth - 1), item); } - ret new(*arena) nil; + return new(*arena) nil; } fn main(args: ~[~str]) { diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 0400e8b127e..8882b5ae7c7 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -35,7 +35,7 @@ fn show_color_list(set: ~[color]) -> ~str { out += ~" "; out += show_color(col); } - ret out; + return out; } fn show_digit(nn: uint) -> ~str { @@ -67,7 +67,7 @@ fn show_number(nn: uint) -> ~str { out = show_digit(dig) + ~" " + out; } - ret out; + return out; } fn transform(aa: color, bb: color) -> color { @@ -137,7 +137,7 @@ fn rendezvous(nn: uint, set: ~[color]) { fn@(ii: uint, col: color) -> comm::chan<option<creature_info>> { // create each creature as a listener with a port, and // give us a channel to talk to each - ret do task::spawn_listener |from_rendezvous| { + return do task::spawn_listener |from_rendezvous| { creature(ii, col, from_rendezvous, to_rendezvous, to_rendezvous_log); }; diff --git a/src/test/bench/shootout-fannkuchredux.rs b/src/test/bench/shootout-fannkuchredux.rs index 4f48c8799b7..e5eab3b78f4 100644 --- a/src/test/bench/shootout-fannkuchredux.rs +++ b/src/test/bench/shootout-fannkuchredux.rs @@ -4,7 +4,7 @@ import int; import vec; fn fannkuch(n: int) -> int { - fn perm1init(i: uint) -> int { ret i as int; } + fn perm1init(i: uint) -> int { return i as int; } let perm = vec::to_mut(vec::from_elem(n as uint, 0)); let perm1 = vec::to_mut(vec::from_fn(n as uint, perm1init)); @@ -44,7 +44,7 @@ fn fannkuch(n: int) -> int { while go { if r == n { io::println(fmt!{"%d", checksum}); - ret flips; + return flips; } let p0 = perm1[0]; i = 0; @@ -55,7 +55,7 @@ fn fannkuch(n: int) -> int { } nperm += 1; } - ret flips; + return flips; } fn main(args: ~[~str]) { diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index ca528764b1d..a1cb8933893 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -12,7 +12,7 @@ import int; import str; import io::writer_util; -fn LINE_LENGTH() -> uint { ret 60u; } +fn LINE_LENGTH() -> uint { return 60u; } type myrandom = @{mut last: u32}; @@ -27,20 +27,20 @@ fn make_cumulative(aa: ~[aminoacids]) -> ~[aminoacids] { let mut cp: u32 = 0u32; let mut ans: ~[aminoacids] = ~[]; for aa.each |a| { cp += a.prob; ans += ~[{ch: a.ch, prob: cp}]; } - ret ans; + return ans; } fn select_random(r: u32, genelist: ~[aminoacids]) -> char { - if r < genelist[0].prob { ret genelist[0].ch; } + if r < genelist[0].prob { return genelist[0].ch; } fn bisect(v: ~[aminoacids], lo: uint, hi: uint, target: u32) -> char { if hi > lo + 1u { let mid: uint = lo + (hi - lo) / 2u; if target < v[mid].prob { - ret bisect(v, lo, mid, target); - } else { ret bisect(v, mid, hi, target); } - } else { ret v[hi].ch; } + return bisect(v, lo, mid, target); + } else { return bisect(v, mid, hi, target); } + } else { return v[hi].ch; } } - ret bisect(genelist, 0u, vec::len::<aminoacids>(genelist) - 1u, r); + return bisect(genelist, 0u, vec::len::<aminoacids>(genelist) - 1u, r); } fn make_random_fasta(wr: io::writer, id: ~str, desc: ~str, genelist: ~[aminoacids], n: int) { @@ -72,7 +72,7 @@ fn make_repeat_fasta(wr: io::writer, id: ~str, desc: ~str, s: ~str, n: int) unsa if str::len(op) > 0u { wr.write_line(op); } } -fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; } +fn acid(ch: char, prob: u32) -> aminoacids { return {ch: ch, prob: prob}; } fn main(args: ~[~str]) { let args = if os::getenv(~"RUST_BENCH").is_some() { diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index 2851b59956e..4e8cfff4ad2 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -2,9 +2,9 @@ use std; fn fib(n: int) -> int { if n < 2 { - ret 1; + return 1; } else { - ret fib(n - 1) + fib(n - 2); + return fib(n - 1) + fib(n - 2); } } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index d8a82019f33..d02fe7770c5 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -14,24 +14,24 @@ import pipes::{stream, port, chan}; // given a map, print a sorted version of it fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { fn pct(xx: uint, yy: uint) -> float { - ret (xx as float) * 100f / (yy as float); + return (xx as float) * 100f / (yy as float); } fn le_by_val<TT: copy, UU: copy>(kv0: (TT,UU), kv1: (TT,UU)) -> bool { let (_, v0) = kv0; let (_, v1) = kv1; - ret v0 >= v1; + return v0 >= v1; } fn le_by_key<TT: copy, UU: copy>(kv0: (TT,UU), kv1: (TT,UU)) -> bool { let (k0, _) = kv0; let (k1, _) = kv1; - ret k0 <= k1; + return k0 <= k1; } // sort by key, then by value fn sortKV<TT: copy, UU: copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { - ret sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig)); + return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig)); } let mut pairs = ~[]; @@ -39,7 +39,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { // map -> [(k,%)] mm.each(fn&(key: ~[u8], val: uint) -> bool { vec::push(pairs, (key, pct(val, total))); - ret true; + return true; }); let pairs_sorted = sortKV(pairs); @@ -49,17 +49,17 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { pairs_sorted.each(fn&(kv: (~[u8], float)) -> bool unsafe { let (k,v) = kv; buffer += (fmt!{"%s %0.3f\n", str::to_upper(str::unsafe::from_bytes(k)), v}); - ret true; + return true; }); - ret buffer; + return buffer; } // 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))) { - option::none { ret 0u; } - option::some(num) { ret num; } + option::none { return 0u; } + option::some(num) { return num; } } } @@ -85,7 +85,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, ii += 1u; } - ret vec::slice(bb, len - (nn - 1u), len); + return vec::slice(bb, len - (nn - 1u), len); } fn make_sequence_processor(sz: uint, from_parent: pipes::port<~[u8]>, diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 2eee8572a77..d5beee9ff08 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -12,24 +12,24 @@ import std::sort; // given a map, print a sorted version of it fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { fn pct(xx: uint, yy: uint) -> float { - ret (xx as float) * 100f / (yy as float); + return (xx as float) * 100f / (yy as float); } fn le_by_val<TT: copy, UU: copy>(kv0: (TT,UU), kv1: (TT,UU)) -> bool { let (_, v0) = kv0; let (_, v1) = kv1; - ret v0 >= v1; + return v0 >= v1; } fn le_by_key<TT: copy, UU: copy>(kv0: (TT,UU), kv1: (TT,UU)) -> bool { let (k0, _) = kv0; let (k1, _) = kv1; - ret k0 <= k1; + return k0 <= k1; } // sort by key, then by value fn sortKV<TT: copy, UU: copy>(orig: ~[(TT,UU)]) -> ~[(TT,UU)] { - ret sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig)); + return sort::merge_sort(le_by_val, sort::merge_sort(le_by_key, orig)); } let mut pairs = ~[]; @@ -37,7 +37,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { // map -> [(k,%)] mm.each(fn&(key: ~[u8], val: uint) -> bool { vec::push(pairs, (key, pct(val, total))); - ret true; + return true; }); let pairs_sorted = sortKV(pairs); @@ -47,17 +47,17 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str { pairs_sorted.each(fn&(kv: (~[u8], float)) -> bool unsafe { let (k,v) = kv; buffer += (fmt!{"%s %0.3f\n", str::to_upper(str::unsafe::from_bytes(k)), v}); - ret true; + return true; }); - ret buffer; + return buffer; } // 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))) { - option::none { ret 0u; } - option::some(num) { ret num; } + option::none { return 0u; } + option::some(num) { return num; } } } @@ -83,7 +83,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, ii += 1u; } - ret vec::slice(bb, len - (nn - 1u), len); + return vec::slice(bb, len - (nn - 1u), len); } fn make_sequence_processor(sz: uint, from_parent: comm::port<~[u8]>, @@ -142,7 +142,7 @@ fn main(args: ~[~str]) { let from_child = vec::map (sizes, |_sz| comm::port() ); let to_parent = vec::mapi(sizes, |ii, _sz| comm::chan(from_child[ii]) ); let to_child = vec::mapi(sizes, fn@(ii: uint, sz: uint) -> comm::chan<~[u8]> { - ret do task::spawn_listener |from_parent| { + return do task::spawn_listener |from_parent| { make_sequence_processor(sz, from_parent, to_parent[ii]); }; }); diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 3e1288b3b0a..0082bc6ad03 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -52,7 +52,7 @@ mod NBodySystem { // side-effecting Body::offset_momentum(bodies[0], px, py, pz); - ret bodies; + return bodies; } fn advance(bodies: ~[Body::props], dt: float) { @@ -122,7 +122,7 @@ mod NBodySystem { i += 1; } - ret e; + return e; } } @@ -144,7 +144,7 @@ mod Body { mass: float}; fn jupiter() -> Body::props { - ret {mut x: 4.84143144246472090e+00, + return {mut x: 4.84143144246472090e+00, mut y: -1.16032004402742839e+00, mut z: -1.03622044471123109e-01, mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR, @@ -154,7 +154,7 @@ mod Body { } fn saturn() -> Body::props { - ret {mut x: 8.34336671824457987e+00, + return {mut x: 8.34336671824457987e+00, mut y: 4.12479856412430479e+00, mut z: -4.03523417114321381e-01, mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR, @@ -164,7 +164,7 @@ mod Body { } fn uranus() -> Body::props { - ret {mut x: 1.28943695621391310e+01, + return {mut x: 1.28943695621391310e+01, mut y: -1.51111514016986312e+01, mut z: -2.23307578892655734e-01, mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR, @@ -174,7 +174,7 @@ mod Body { } fn neptune() -> Body::props { - ret {mut x: 1.53796971148509165e+01, + return {mut x: 1.53796971148509165e+01, mut y: -2.59193146099879641e+01, mut z: 1.79258772950371181e-01, mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR, @@ -184,7 +184,7 @@ mod Body { } fn sun() -> Body::props { - ret {mut x: 0.0, + return {mut x: 0.0, mut y: 0.0, mut z: 0.0, mut vx: 0.0, diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index be7a8c6c3c7..2d2f9377820 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -41,7 +41,7 @@ fn fib(n: int) -> int { let p = port(); let ch = chan(p); let t = task::spawn(|| pfib(ch, n) ); - ret recv(p); + return recv(p); } type config = {stress: bool}; @@ -53,7 +53,7 @@ fn parse_opts(argv: ~[~str]) -> config { alt getopts::getopts(opt_args, opts) { - ok(m) { ret {stress: getopts::opt_present(m, ~"stress")} } + 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 890f36b833c..36df950a2b7 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -24,13 +24,13 @@ fn roundtrip(id: int, p: comm::port<int>, ch: comm::chan<int>) { alt comm::recv(p) { 1 { io::println(fmt!{"%d\n", id}); - ret; + return; } token { debug!{"%d %d", id, token}; comm::send(ch, token - 1); if token <= n_threads { - ret; + return; } } } diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index e062e5c9dcb..fc22b99f59c 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -42,7 +42,7 @@ fn read_grid(f: io::reader) -> grid_t { g[row][col] = option::get(uint::from_str(comps[2])) as u8; } } - ret grid_ctor(g); + return grid_ctor(g); } // solve sudoku grid @@ -62,12 +62,12 @@ fn solve_grid(g: grid_t) { for uint::range(1u, 10u) |i| { if avail.get(i) { g[row][col] = i as u8; - ret true; + return true; } }; } g[row][col] = 0u8; - ret false; + return false; } // find colors available in neighbourhood of (row, col) diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 59c9be9d58f..8192143faa2 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -167,7 +167,7 @@ mod map_reduce { vec::push(tasks, spawn_joinable(|| map_task(map, ctrl, i) )); vec::push(ctrls, ctrl_server); } - ret tasks; + return tasks; } fn map_task<K1: copy send, K2: const copy send hash_key, V: copy send>( @@ -226,7 +226,7 @@ mod map_reduce { alt recv(p) { emit_val(v) { // error!{"received %d", v}; - ret some(v); + return some(v); } done { // error!{"all done"}; @@ -236,7 +236,7 @@ mod map_reduce { release { ref_count -= 1; } } } - ret none; + return none; } reduce(key, || get(p, ref_count, is_done) ); @@ -303,7 +303,7 @@ fn main(argv: ~[~str]) { out.write_line(fmt!{"Usage: %s <filename> ...", argv[0]}); - ret; + return; } let readers: ~[fn~() -> word_reader] = if argv.len() >= 2 { @@ -339,9 +339,9 @@ fn read_word(r: io::reader) -> option<~str> { if is_word_char(c) { w += str::from_char(c); - } else { if w != ~"" { ret some(w); } } + } else { if w != ~"" { return some(w); } } } - ret none; + return none; } fn is_word_char(c: char) -> bool { diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index d83045ae417..01b949e312c 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -68,7 +68,7 @@ mod map_reduce { map_task(ctrl, i); // Task body } } - ret results; + return results; } fn map_task(ctrl: chan<ctrl_proto>, input: ~str) { @@ -114,7 +114,7 @@ mod map_reduce { alt recv(p) { emit_val(v) { // error!{"received %d", v}; - ret some(v); + return some(v); } done { // error!{"all done"}; @@ -124,7 +124,7 @@ mod map_reduce { release { state.ref_count -= 1; } } } - ret none; + return none; } reduce(key, || get(p, state) ); @@ -210,9 +210,9 @@ fn read_word(r: io::reader) -> option<~str> { if is_word_char(c) { w += str::from_char(c); - } else { if w != ~"" { ret some(w); } } + } else { if w != ~"" { return some(w); } } } - ret none; + return none; } fn is_digit(c: char) -> bool { diff --git a/src/test/compile-fail/bad-bang-ann-3.rs b/src/test/compile-fail/bad-bang-ann-3.rs index 3a88afd5346..fab48c0d559 100644 --- a/src/test/compile-fail/bad-bang-ann-3.rs +++ b/src/test/compile-fail/bad-bang-ann-3.rs @@ -2,7 +2,7 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: uint) -> ! { - ret 7u; + return 7u; //~^ ERROR expected `_|_` but found `uint` } diff --git a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs index 2e1d7778a9e..73152fba0ed 100644 --- a/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs +++ b/src/test/compile-fail/block-arg-used-as-lambda-with-illegal-cap.rs @@ -1,9 +1,9 @@ fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint { - ret f; + return f; } fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint { - ret to_lambda1({|x| b(x)}); //~ ERROR value may contain borrowed pointers + return to_lambda1({|x| b(x)}); //~ ERROR value may contain borrowed pointers } fn main() { diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index dd8f77ce20e..f407d362603 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -3,9 +3,9 @@ fn coerce(b: fn()) -> extern fn() { fn lol(f: extern fn(fn()) -> extern fn(), - g: fn()) -> extern fn() { ret f(g); } - fn fn_id(f: extern fn()) -> extern fn() { ret f } - ret lol(fn_id, b); + g: fn()) -> extern fn() { return f(g); } + fn fn_id(f: extern fn()) -> extern fn() { return f } + return lol(fn_id, b); //~^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()` } diff --git a/src/test/compile-fail/block-copy.rs b/src/test/compile-fail/block-copy.rs index cb5550cded9..964ea5c7750 100644 --- a/src/test/compile-fail/block-copy.rs +++ b/src/test/compile-fail/block-copy.rs @@ -1,6 +1,6 @@ // error-pattern: stack closure type can only appear -fn lol(f: fn()) -> fn() { ret f; } +fn lol(f: fn()) -> fn() { return f; } fn main() { let i = 8; let f = lol(fn&() { log(error, i); }); diff --git a/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs b/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs index fc8ff1ffe07..71bba89fb77 100644 --- a/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs +++ b/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs @@ -1,6 +1,6 @@ fn foo(x: *~int) -> ~int { let y <- *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block - ret y; + return y; } fn main() { diff --git a/src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs b/src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs index ad9877c2674..da394fbf372 100644 --- a/src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs +++ b/src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs @@ -1,7 +1,7 @@ fn want_slice(v: &[int]) -> int { let mut sum = 0; for vec::each(v) |i| { sum += i; } - ret sum; + return sum; } fn has_mut_vec(+v: @~[mut int]) -> int { diff --git a/src/test/compile-fail/cap-clause-illegal-cap.rs b/src/test/compile-fail/cap-clause-illegal-cap.rs index c13cc37f4b7..f7863013898 100644 --- a/src/test/compile-fail/cap-clause-illegal-cap.rs +++ b/src/test/compile-fail/cap-clause-illegal-cap.rs @@ -5,7 +5,7 @@ class foo { let x: int; new(x: int) { self.x = x; } drop { } } fn to_lambda2(b: foo) -> fn@(uint) -> uint { // test case where copy clause specifies a value that is not used // in fn@ body, but value is illegal to copy: - ret fn@(u: uint, copy b) -> uint { 22u }; + return fn@(u: uint, copy b) -> uint { 22u }; } fn main() { diff --git a/src/test/compile-fail/capture1.rs b/src/test/compile-fail/capture1.rs index 877884bf7f9..053e2f5ca7f 100644 --- a/src/test/compile-fail/capture1.rs +++ b/src/test/compile-fail/capture1.rs @@ -4,5 +4,5 @@ fn main() { let bar: int = 5; - fn foo() -> int { ret bar; } + fn foo() -> int { return bar; } } diff --git a/src/test/compile-fail/class-cast-to-iface.rs b/src/test/compile-fail/class-cast-to-iface.rs index fb35b788779..159e881ee8a 100644 --- a/src/test/compile-fail/class-cast-to-iface.rs +++ b/src/test/compile-fail/class-cast-to-iface.rs @@ -27,11 +27,11 @@ class cat : noisy { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/compile-fail/constrained-type-missing-check.rs b/src/test/compile-fail/constrained-type-missing-check.rs index bed10a12de5..4ad79f570ae 100644 --- a/src/test/compile-fail/constrained-type-missing-check.rs +++ b/src/test/compile-fail/constrained-type-missing-check.rs @@ -2,7 +2,7 @@ // xfail-test // error-pattern:Unsatisfied precondition -pure fn less_than(x: int, y: int) -> bool { ret x < y; } +pure fn less_than(x: int, y: int) -> bool { return x < y; } type ordered_range = {low: int, high: int} : less_than(*.low, *.high); diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs index fe7b7aec104..2f46bd2d473 100644 --- a/src/test/compile-fail/dead-code-ret.rs +++ b/src/test/compile-fail/dead-code-ret.rs @@ -5,5 +5,5 @@ fn f(caller: str) { log(debug, caller); } -fn main() { ret f("main"); debug!{"Paul is dead"}; } +fn main() { return f("main"); debug!{"Paul is dead"}; } diff --git a/src/test/compile-fail/for-loop-decl.rs b/src/test/compile-fail/for-loop-decl.rs index eb327ff3ea1..697a135d0cc 100644 --- a/src/test/compile-fail/for-loop-decl.rs +++ b/src/test/compile-fail/for-loop-decl.rs @@ -13,7 +13,7 @@ fn bitv_to_str(enclosing: fn_info, v: ~bitv::bitv) -> str { for enclosing.vars.each_value |val| { if v.get(val) { s += "foo"; } } - ret s; + return s; } fn main() { debug!{"OK"}; } diff --git a/src/test/compile-fail/fully-qualified-type-name2.rs b/src/test/compile-fail/fully-qualified-type-name2.rs index db6521cbd78..12125422a94 100644 --- a/src/test/compile-fail/fully-qualified-type-name2.rs +++ b/src/test/compile-fail/fully-qualified-type-name2.rs @@ -9,7 +9,7 @@ mod y { } fn bar(x: x::foo) -> y::foo { - ret x; + return x; //~^ ERROR mismatched types: expected `y::foo` but found `x::foo` } diff --git a/src/test/compile-fail/fully-qualified-type-name3.rs b/src/test/compile-fail/fully-qualified-type-name3.rs index 6bd764af179..8c4f976f1b3 100644 --- a/src/test/compile-fail/fully-qualified-type-name3.rs +++ b/src/test/compile-fail/fully-qualified-type-name3.rs @@ -4,7 +4,7 @@ type T1 = uint; type T2 = int; fn bar(x: T1) -> T2 { - ret x; + return x; //~^ ERROR mismatched types: expected `T2` but found `T1` } diff --git a/src/test/compile-fail/fully-qualified-type-name4.rs b/src/test/compile-fail/fully-qualified-type-name4.rs index 73560432032..00eb7434224 100644 --- a/src/test/compile-fail/fully-qualified-type-name4.rs +++ b/src/test/compile-fail/fully-qualified-type-name4.rs @@ -3,7 +3,7 @@ import core::task::task; fn bar(x: uint) -> task { - ret x; + return x; //~^ ERROR mismatched types: expected `core::task::task` } diff --git a/src/test/compile-fail/iface-cast.rs b/src/test/compile-fail/iface-cast.rs index f6642ec1b62..736634c13e8 100644 --- a/src/test/compile-fail/iface-cast.rs +++ b/src/test/compile-fail/iface-cast.rs @@ -1,7 +1,7 @@ trait foo<T> { } fn bar(x: foo<uint>) -> foo<int> { - ret (x as foo::<int>); + return (x as foo::<int>); //~^ ERROR mismatched types: expected `foo<int>` but found `foo<uint>` } diff --git a/src/test/compile-fail/import-glob-circular.rs b/src/test/compile-fail/import-glob-circular.rs index e0f2d3a3c09..a3be8b17604 100644 --- a/src/test/compile-fail/import-glob-circular.rs +++ b/src/test/compile-fail/import-glob-circular.rs @@ -6,7 +6,7 @@ mod circ1 { export f2; export common; fn f1() { debug!{"f1"}; } - fn common() -> uint { ret 0u; } + fn common() -> uint { return 0u; } } mod circ2 { @@ -15,7 +15,7 @@ mod circ2 { export f2; export common; fn f2() { debug!{"f2"}; } - fn common() -> uint { ret 1u; } + fn common() -> uint { return 1u; } } mod test { diff --git a/src/test/compile-fail/issue-1193.rs b/src/test/compile-fail/issue-1193.rs index b20d734ec59..d6ab1e44211 100644 --- a/src/test/compile-fail/issue-1193.rs +++ b/src/test/compile-fail/issue-1193.rs @@ -7,8 +7,8 @@ mod foo { fn bar(v: t) -> bool { alt v { - a { ret true; } - b { ret false; } + a { return true; } + b { return false; } } } } diff --git a/src/test/compile-fail/issue-1448-1.rs b/src/test/compile-fail/issue-1448-1.rs index 191dda5b4c1..1da1289f18e 100644 --- a/src/test/compile-fail/issue-1448-1.rs +++ b/src/test/compile-fail/issue-1448-1.rs @@ -2,6 +2,6 @@ fn main() { #macro[[#apply[f, [x, ...]], f(x, ...)]]; - fn add(a: int, b: int) -> int { ret a + b; } + fn add(a: int, b: int) -> int { return a + b; } assert (apply!{add, [y, 15]} == 16); //~ ERROR unresolved name: y } diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index 79f0598baac..7234ca9e9e1 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -3,6 +3,6 @@ fn fail_len(v: ~[const int]) -> uint { for v.each |x| { i += 1u; } //~^ WARNING unreachable statement //~^^ ERROR the type of this value must be known - ret i; + return i; } fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/issue-3021-d.rs b/src/test/compile-fail/issue-3021-d.rs index 145cce00839..82aeb1c8da2 100644 --- a/src/test/compile-fail/issue-3021-d.rs +++ b/src/test/compile-fail/issue-3021-d.rs @@ -15,7 +15,7 @@ fn siphash(k0 : u64, k1 : u64) -> siphash { let v0 = st.v0, v1 = st.v1; - ret v0 ^ v1; + return v0 ^ v1; } impl of siphash for sipstate { @@ -25,7 +25,7 @@ fn siphash(k0 : u64, k1 : u64) -> siphash { self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR attempted dynamic environment-capture //~^ ERROR unresolved name: k1 } - fn result() -> u64 { ret mk_result(self); } + fn result() -> u64 { return mk_result(self); } } } diff --git a/src/test/compile-fail/issue-897-2.rs b/src/test/compile-fail/issue-897-2.rs index ce6737cc962..ebf3b5e986e 100644 --- a/src/test/compile-fail/issue-897-2.rs +++ b/src/test/compile-fail/issue-897-2.rs @@ -1,6 +1,6 @@ fn g() -> ! { fail; } fn f() -> ! { - ret 42i; //~ ERROR expected `_|_` but found `int` + return 42i; //~ ERROR expected `_|_` but found `int` g(); //~ WARNING unreachable statement } fn main() { } diff --git a/src/test/compile-fail/issue-897.rs b/src/test/compile-fail/issue-897.rs index 1adf8534cca..f53d880d10b 100644 --- a/src/test/compile-fail/issue-897.rs +++ b/src/test/compile-fail/issue-897.rs @@ -1,5 +1,5 @@ fn f() -> ! { - ret 42i; //~ ERROR expected `_|_` but found `int` + return 42i; //~ ERROR expected `_|_` but found `int` fail; //~ WARNING unreachable statement } fn main() { } diff --git a/src/test/compile-fail/lambda-mutate-nested.rs b/src/test/compile-fail/lambda-mutate-nested.rs index 8b673e2b307..7eff11daea1 100644 --- a/src/test/compile-fail/lambda-mutate-nested.rs +++ b/src/test/compile-fail/lambda-mutate-nested.rs @@ -5,7 +5,7 @@ fn f2(x: fn()) { x(); } fn main() { let i = 0; - let ctr = fn@ () -> int { f2(|| i = i + 1 ); ret i; }; + let ctr = fn@ () -> int { f2(|| i = i + 1 ); return i; }; log(error, ctr()); log(error, ctr()); log(error, ctr()); diff --git a/src/test/compile-fail/lambda-mutate.rs b/src/test/compile-fail/lambda-mutate.rs index 8886f930e20..15b9bcd8469 100644 --- a/src/test/compile-fail/lambda-mutate.rs +++ b/src/test/compile-fail/lambda-mutate.rs @@ -2,7 +2,7 @@ // Make sure we can't write to upvars from fn@s fn main() { let i = 0; - let ctr = fn@ () -> int { i = i + 1; ret i; }; + let ctr = fn@ () -> int { i = i + 1; return i; }; log(error, ctr()); log(error, ctr()); log(error, ctr()); diff --git a/src/test/compile-fail/liveness-break-uninit-2.rs b/src/test/compile-fail/liveness-break-uninit-2.rs index fc1c941836e..029d0aef9da 100644 --- a/src/test/compile-fail/liveness-break-uninit-2.rs +++ b/src/test/compile-fail/liveness-break-uninit-2.rs @@ -8,7 +8,7 @@ fn foo() -> int { log(debug, x); //~ ERROR use of possibly uninitialized variable: `x` - ret 17; + return 17; } fn main() { log(debug, foo()); } diff --git a/src/test/compile-fail/liveness-break-uninit.rs b/src/test/compile-fail/liveness-break-uninit.rs index 56753a3a95c..3729d2e8b22 100644 --- a/src/test/compile-fail/liveness-break-uninit.rs +++ b/src/test/compile-fail/liveness-break-uninit.rs @@ -8,7 +8,7 @@ fn foo() -> int { log(debug, x); //~ ERROR use of possibly uninitialized variable: `x` - ret 17; + return 17; } fn main() { log(debug, foo()); } diff --git a/src/test/compile-fail/liveness-forgot-ret.rs b/src/test/compile-fail/liveness-forgot-ret.rs index 4d78b7a7aff..84d0ccd641e 100644 --- a/src/test/compile-fail/liveness-forgot-ret.rs +++ b/src/test/compile-fail/liveness-forgot-ret.rs @@ -1,8 +1,8 @@ // -*- rust -*- // error-pattern: not all control paths return a value -fn god_exists(a: int) -> bool { ret god_exists(a); } +fn god_exists(a: int) -> bool { return god_exists(a); } -fn f(a: int) -> int { if god_exists(a) { ret 5; }; } +fn f(a: int) -> int { if god_exists(a) { return 5; }; } fn main() { f(12); } diff --git a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs index 5716a380936..59bbe0e14c8 100644 --- a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs +++ b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs @@ -1,7 +1,7 @@ fn main() { let j = fn@() -> int { let i: int; - ret i; //~ ERROR use of possibly uninitialized variable: `i` + return i; //~ ERROR use of possibly uninitialized variable: `i` }; j(); } diff --git a/src/test/compile-fail/liveness-init-in-fn-expr.rs b/src/test/compile-fail/liveness-init-in-fn-expr.rs index cffba2132c2..ebd128905d8 100644 --- a/src/test/compile-fail/liveness-init-in-fn-expr.rs +++ b/src/test/compile-fail/liveness-init-in-fn-expr.rs @@ -1,7 +1,7 @@ fn main() { let f = fn@() -> int { let i: int; - ret i; //~ ERROR use of possibly uninitialized variable: `i` + return i; //~ ERROR use of possibly uninitialized variable: `i` }; log(error, f()); } diff --git a/src/test/compile-fail/liveness-missing-ret2.rs b/src/test/compile-fail/liveness-missing-ret2.rs index 54d8de63014..8cb365afbf6 100644 --- a/src/test/compile-fail/liveness-missing-ret2.rs +++ b/src/test/compile-fail/liveness-missing-ret2.rs @@ -1,7 +1,7 @@ // error-pattern: not all control paths return a value fn f() -> int { - // Make sure typestate doesn't interpret this alt expression + // Make sure typestate doesn't interpreturn this alt expression // as the function result alt check true { true { } }; } diff --git a/src/test/compile-fail/liveness-return.rs b/src/test/compile-fail/liveness-return.rs index 830eb9f8e89..c993ddd24b7 100644 --- a/src/test/compile-fail/liveness-return.rs +++ b/src/test/compile-fail/liveness-return.rs @@ -1,6 +1,6 @@ fn f() -> int { let x: int; - ret x; //~ ERROR use of possibly uninitialized variable: `x` + return x; //~ ERROR use of possibly uninitialized variable: `x` } fn main() { f(); } diff --git a/src/test/compile-fail/liveness-while.rs b/src/test/compile-fail/liveness-while.rs index 9cd61330bae..cfa555b1e35 100644 --- a/src/test/compile-fail/liveness-while.rs +++ b/src/test/compile-fail/liveness-while.rs @@ -1,7 +1,7 @@ fn f() -> int { let mut x: int; while 1 == 1 { x = 10; } - ret x; //~ ERROR use of possibly uninitialized variable: `x` + return x; //~ ERROR use of possibly uninitialized variable: `x` } fn main() { f(); } diff --git a/src/test/compile-fail/loop-does-not-diverge.rs b/src/test/compile-fail/loop-does-not-diverge.rs index 06a227cffd2..6f9b74a4ad7 100644 --- a/src/test/compile-fail/loop-does-not-diverge.rs +++ b/src/test/compile-fail/loop-does-not-diverge.rs @@ -4,7 +4,7 @@ fn forever() -> ! { loop { break; } - ret 42i; //~ ERROR expected `_|_` but found `int` + return 42i; //~ ERROR expected `_|_` but found `int` } fn main() { diff --git a/src/test/compile-fail/macro-2.rs b/src/test/compile-fail/macro-2.rs index 71ae833a139..c2c3d0127c5 100644 --- a/src/test/compile-fail/macro-2.rs +++ b/src/test/compile-fail/macro-2.rs @@ -2,7 +2,7 @@ fn main() { #macro[[#mylambda[x, body], { - fn f(x: int) -> int { ret body } + fn f(x: int) -> int { return body } f }]]; diff --git a/src/test/compile-fail/nested-ty-params.rs b/src/test/compile-fail/nested-ty-params.rs index de696f21b25..54d4d8e4817 100644 --- a/src/test/compile-fail/nested-ty-params.rs +++ b/src/test/compile-fail/nested-ty-params.rs @@ -1,6 +1,6 @@ // error-pattern:attempt to use a type argument out of scope fn hd<U>(v: ~[U]) -> U { - fn hd1(w: [U]) -> U { ret w[0]; } + fn hd1(w: [U]) -> U { return w[0]; } - ret hd1(v); + return hd1(v); } diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 4d60457d87f..3e9648e19c9 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)) { ret x * 3; } _ { fail; } } } +fn foo(t: bar) -> int { alt t { t1(_, some(x)) { return x * 3; } _ { fail; } } } fn main() { } diff --git a/src/test/compile-fail/pure-loop-body.rs b/src/test/compile-fail/pure-loop-body.rs index e418a2f201f..bcc23d3c0d9 100644 --- a/src/test/compile-fail/pure-loop-body.rs +++ b/src/test/compile-fail/pure-loop-body.rs @@ -1,7 +1,7 @@ pure fn range(from: uint, to: uint, f: fn(uint) -> bool) { let mut i = from; while i < to { - if !f(i) {ret;} // Note: legal to call argument, even if it is not pure. + if !f(i) {return;} // Note: legal to call argument, even if it is not pure. i += 1u; } } diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index e62b702e53f..e795c5b8686 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -7,21 +7,21 @@ trait a_trait { fn foo() -> &self/int; } class a_class { let x:&self/int; new(x:&self/int) { self.x = x; } } fn a_fn1(e: an_enum/&a) -> an_enum/&b { - ret e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a` + return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a` } fn a_fn2(e: a_trait/&a) -> a_trait/&b { - ret e; //~ ERROR mismatched types: expected `a_trait/&b` but found `a_trait/&a` + return e; //~ ERROR mismatched types: expected `a_trait/&b` but found `a_trait/&a` } fn a_fn3(e: a_class/&a) -> a_class/&b { - ret e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a` + return e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a` } fn a_fn4(e: int/&a) -> int/&b { //~^ ERROR region parameters are not allowed on this type //~^^ ERROR region parameters are not allowed on this type - ret e; + return e; } fn main() { } \ No newline at end of file diff --git a/src/test/compile-fail/regions-creating-enums.rs b/src/test/compile-fail/regions-creating-enums.rs index 5924164ef26..02780c70ed8 100644 --- a/src/test/compile-fail/regions-creating-enums.rs +++ b/src/test/compile-fail/regions-creating-enums.rs @@ -20,12 +20,12 @@ fn compute(x: &ast) -> uint { fn map_nums(x: &ast, f: fn(uint) -> uint) -> &ast { alt *x { num(x) { - ret &num(f(x)); //~ ERROR illegal borrow + return &num(f(x)); //~ ERROR illegal borrow } add(x, y) { let m_x = map_nums(x, f); let m_y = map_nums(y, f); - ret &add(m_x, m_y); //~ ERROR illegal borrow + return &add(m_x, m_y); //~ ERROR illegal borrow } } } diff --git a/src/test/compile-fail/regions-iface-2.rs b/src/test/compile-fail/regions-iface-2.rs index c034f8a753a..98b9797df62 100644 --- a/src/test/compile-fail/regions-iface-2.rs +++ b/src/test/compile-fail/regions-iface-2.rs @@ -13,7 +13,7 @@ impl of get_ctxt for has_ctxt { fn make_gc() -> get_ctxt { let ctxt = { v: 22u }; let hc = { c: &ctxt }; - ret hc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&` + return hc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&` } fn main() { diff --git a/src/test/compile-fail/regions-iface-3.rs b/src/test/compile-fail/regions-iface-3.rs index 78e77d66def..a0be6c90177 100644 --- a/src/test/compile-fail/regions-iface-3.rs +++ b/src/test/compile-fail/regions-iface-3.rs @@ -3,11 +3,11 @@ trait get_ctxt { } fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b { - ret gc; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a` + return gc; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a` } fn make_gc2(gc: get_ctxt/&a) -> get_ctxt/&b { - ret gc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a` + return gc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a` } fn main() { diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index 2f4003f0f3a..dd2968504ee 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -1,13 +1,13 @@ type point = {x: int, y: int}; fn x_coord(p: &point) -> &int { - ret &p.x; + return &p.x; } fn foo(p: @point) -> &int { let xc = x_coord(p); //~ ERROR illegal borrow assert *xc == 3; - ret xc; + return xc; } fn main() {} diff --git a/src/test/compile-fail/regions-nested-fns-2.rs b/src/test/compile-fail/regions-nested-fns-2.rs index ad22140b3b5..04c5145cbf2 100644 --- a/src/test/compile-fail/regions-nested-fns-2.rs +++ b/src/test/compile-fail/regions-nested-fns-2.rs @@ -3,8 +3,8 @@ fn ignore<T>(_t: T) {} fn nested() { let y = 3; ignore(fn&(z: &z/int) -> &z/int { - if false { ret &y; } //~ ERROR illegal borrow - ret z; + if false { return &y; } //~ ERROR illegal borrow + return z; }); } diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index bd6e3644556..9d9116d10b2 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -11,9 +11,9 @@ fn nested(x: &x/int) { }); ignore(fn&(z: &z/int) -> &z/int { - if false { ret x; } //~ ERROR mismatched types - if false { ret ay; } //~ ERROR mismatched types - ret z; + if false { return x; } //~ ERROR mismatched types + if false { return ay; } //~ ERROR mismatched types + return z; }); } diff --git a/src/test/compile-fail/regions-ret.rs b/src/test/compile-fail/regions-ret.rs index 9c1bf26b400..b764fdbff9d 100644 --- a/src/test/compile-fail/regions-ret.rs +++ b/src/test/compile-fail/regions-ret.rs @@ -1,5 +1,5 @@ fn f(_x : &a/int) -> &a/int { - ret &3; //~ ERROR illegal borrow + return &3; //~ ERROR illegal borrow } fn main() { diff --git a/src/test/compile-fail/regions-scoping.rs b/src/test/compile-fail/regions-scoping.rs index c17319ca7bb..7b996cf4735 100644 --- a/src/test/compile-fail/regions-scoping.rs +++ b/src/test/compile-fail/regions-scoping.rs @@ -9,18 +9,18 @@ fn nested(x: &x/int) { // (1) z: &z/int) -> &z/int) // A fresh region `z` (3) -> &x/int { - if false { ret z(x, x, x); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int` - if false { ret z(x, x, y); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int` + if false { return z(x, x, x); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int` + if false { return z(x, x, y); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int` //~^ ERROR mismatched types: expected `&x/int` but found `&y/int` - if false { ret z(x, y, x); } - if false { ret z(x, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` - if false { ret z(y, x, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { return z(x, y, x); } + if false { return z(x, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { return z(y, x, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` //~^ ERROR mismatched types: expected `&y/int` but found `&x/int` - if false { ret z(y, x, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { return z(y, x, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` //~^ ERROR mismatched types: expected `&y/int` but found `&x/int` //~^^ ERROR mismatched types: expected `&x/int` but found `&y/int` - if false { ret z(y, y, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` - if false { ret z(y, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { return z(y, y, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` + if false { return z(y, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int` //~^ ERROR mismatched types: expected `&x/int` but found `&y/int` fail; } diff --git a/src/test/compile-fail/ret-non-nil.rs b/src/test/compile-fail/ret-non-nil.rs index 4153f413dc0..ad9fcef4f52 100644 --- a/src/test/compile-fail/ret-non-nil.rs +++ b/src/test/compile-fail/ret-non-nil.rs @@ -1,7 +1,7 @@ -// error-pattern: `ret;` in function returning non-nil +// error-pattern: `return;` in function returning non-nil -fn f() { ret; } +fn f() { return; } -fn g() -> int { ret; } +fn g() -> int { return; } fn main() { f(); g(); } diff --git a/src/test/compile-fail/sendfn-is-not-a-lambda.rs b/src/test/compile-fail/sendfn-is-not-a-lambda.rs index 5aee9cd6fa7..081c400d71d 100644 --- a/src/test/compile-fail/sendfn-is-not-a-lambda.rs +++ b/src/test/compile-fail/sendfn-is-not-a-lambda.rs @@ -1,8 +1,8 @@ fn test(f: fn@(uint) -> uint) -> uint { - ret f(22u); + return f(22u); } fn main() { - let f = fn~(x: uint) -> uint { ret 4u; }; + let f = fn~(x: uint) -> uint { return 4u; }; log(debug, test(f)); //~ ERROR expected `fn@(uint) -> uint` } diff --git a/src/test/compile-fail/tail-typeck.rs b/src/test/compile-fail/tail-typeck.rs index 0c64e9d9556..844fa8b285e 100644 --- a/src/test/compile-fail/tail-typeck.rs +++ b/src/test/compile-fail/tail-typeck.rs @@ -1,7 +1,7 @@ // error-pattern: mismatched types -fn f() -> int { ret g(); } +fn f() -> int { return g(); } -fn g() -> uint { ret 0u; } +fn g() -> uint { return 0u; } fn main() { let y = f(); } diff --git a/src/test/compile-fail/tps-invariant-iface.rs b/src/test/compile-fail/tps-invariant-iface.rs index 82fbd5f1163..93ad8a72ac3 100644 --- a/src/test/compile-fail/tps-invariant-iface.rs +++ b/src/test/compile-fail/tps-invariant-iface.rs @@ -8,7 +8,7 @@ enum box_impl<T> = { }; impl<T:copy> of box_trait<T> for box_impl<T> { - fn get() -> T { ret self.f; } + fn get() -> T { return self.f; } fn set(t: T) { self.f = t; } } diff --git a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs index 03af39ab7fc..98670900da5 100644 --- a/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs +++ b/src/test/compile-fail/unsafe-fn-assign-deref-ptr.rs @@ -2,7 +2,7 @@ fn f(p: *u8) { *p = 0u8; //~ ERROR dereference of unsafe pointer requires unsafe function or block - ret; + return; } fn main() { diff --git a/src/test/compile-fail/unsafe-fn-autoderef.rs b/src/test/compile-fail/unsafe-fn-autoderef.rs index b4ab76dc0c9..a6ce6e2033a 100644 --- a/src/test/compile-fail/unsafe-fn-autoderef.rs +++ b/src/test/compile-fail/unsafe-fn-autoderef.rs @@ -15,7 +15,7 @@ fn f(p: *rec) -> int { // are prohibited by various checks, such as that the enum is // instantiable and so forth). - ret p.f; //~ ERROR attempted access of field `f` on type `*rec` + return p.f; //~ ERROR attempted access of field `f` on type `*rec` } fn main() { diff --git a/src/test/compile-fail/unsafe-fn-called-from-safe.rs b/src/test/compile-fail/unsafe-fn-called-from-safe.rs index d7681a2ec60..08df19de658 100644 --- a/src/test/compile-fail/unsafe-fn-called-from-safe.rs +++ b/src/test/compile-fail/unsafe-fn-called-from-safe.rs @@ -1,6 +1,6 @@ // -*- rust -*- -unsafe fn f() { ret; } +unsafe fn f() { return; } fn main() { f(); //~ ERROR access to unsafe function requires unsafe function or block diff --git a/src/test/compile-fail/unsafe-fn-deref-ptr.rs b/src/test/compile-fail/unsafe-fn-deref-ptr.rs index e66bf5eb687..affa1dc7ac4 100644 --- a/src/test/compile-fail/unsafe-fn-deref-ptr.rs +++ b/src/test/compile-fail/unsafe-fn-deref-ptr.rs @@ -1,7 +1,7 @@ // -*- rust -*- fn f(p: *u8) -> u8 { - ret *p; //~ ERROR dereference of unsafe pointer requires unsafe function or block + return *p; //~ ERROR dereference of unsafe pointer requires unsafe function or block } fn main() { diff --git a/src/test/compile-fail/unsafe-fn-used-as-value.rs b/src/test/compile-fail/unsafe-fn-used-as-value.rs index 7dc0ce4a12b..f71f36f3f60 100644 --- a/src/test/compile-fail/unsafe-fn-used-as-value.rs +++ b/src/test/compile-fail/unsafe-fn-used-as-value.rs @@ -1,6 +1,6 @@ // -*- rust -*- -unsafe fn f() { ret; } +unsafe fn f() { return; } fn main() { let x = f; //~ ERROR access to unsafe function requires unsafe function or block diff --git a/src/test/compile-fail/unused-imports-warn.rs b/src/test/compile-fail/unused-imports-warn.rs index a81b8301a9f..be716bf8804 100644 --- a/src/test/compile-fail/unused-imports-warn.rs +++ b/src/test/compile-fail/unused-imports-warn.rs @@ -11,7 +11,7 @@ mod bar { mod c { import foo::point; import foo::square; - fn cc(p: point) -> str { ret 2 * (p.x + p.y); } + fn cc(p: point) -> str { return 2 * (p.x + p.y); } } } diff --git a/src/test/compile-fail/vec-concat-bug.rs b/src/test/compile-fail/vec-concat-bug.rs index 33873c087a5..afbb57f5878 100644 --- a/src/test/compile-fail/vec-concat-bug.rs +++ b/src/test/compile-fail/vec-concat-bug.rs @@ -7,7 +7,7 @@ fn concat<T: copy>(v: ~[const ~[const T]]) -> ~[T] { r += inner; }); - ret r; + return r; } fn main() {} \ No newline at end of file diff --git a/src/test/compile-fail/wrong-ret-type.rs b/src/test/compile-fail/wrong-ret-type.rs index 82293a8f706..9db0a582c34 100644 --- a/src/test/compile-fail/wrong-ret-type.rs +++ b/src/test/compile-fail/wrong-ret-type.rs @@ -1,3 +1,3 @@ // error-pattern: mismatched types -fn mk_int() -> uint { let i: int = 3; ret i; } +fn mk_int() -> uint { let i: int = 3; return i; } fn main() { } diff --git a/src/test/pretty/blank-lines.rs b/src/test/pretty/blank-lines.rs index 2c22432401b..3ef46a721ae 100644 --- a/src/test/pretty/blank-lines.rs +++ b/src/test/pretty/blank-lines.rs @@ -11,5 +11,5 @@ fn f() -> [int]/3 { - ret enterprise; + return enterprise; } diff --git a/src/test/pretty/block-arg-disambig.rs b/src/test/pretty/block-arg-disambig.rs index 8a4297d95b2..ea4563a579c 100644 --- a/src/test/pretty/block-arg-disambig.rs +++ b/src/test/pretty/block-arg-disambig.rs @@ -1,5 +1,5 @@ // FIXME: The disambiguation the pretty printer does here // is probably not necessary anymore (#2882) -fn blk1(b: fn()) -> fn@() { ret fn@() { }; } +fn blk1(b: fn()) -> fn@() { return fn@() { }; } fn test1() { (do blk1 { debug!{"hi"}; })(); } diff --git a/src/test/pretty/disamb-stmt-expr.rs b/src/test/pretty/disamb-stmt-expr.rs index 546020b6cd8..61323152af1 100644 --- a/src/test/pretty/disamb-stmt-expr.rs +++ b/src/test/pretty/disamb-stmt-expr.rs @@ -1,8 +1,8 @@ // pp-exact // Here we check that the parentheses around the body of `wsucc()` are -// preserved. They are needed to disambiguate `{ret n+1}; - 0` from -// `({ret n+1}-0)`. +// preserved. They are needed to disambiguate `{return n+1}; - 0` from +// `({return n+1}-0)`. fn id(f: fn() -> int) -> int { f() } diff --git a/src/test/run-fail/expr-alt-fail-fn.rs b/src/test/run-fail/expr-alt-fail-fn.rs index bf6898ed297..5a1d410bec1 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 } }; ret x; } +fn g() -> int { let x = alt true { true { f() } false { 10 } }; return x; } fn main() { g(); } diff --git a/src/test/run-fail/expr-if-fail-fn.rs b/src/test/run-fail/expr-if-fail-fn.rs index 406302532fa..31989707f4f 100644 --- a/src/test/run-fail/expr-if-fail-fn.rs +++ b/src/test/run-fail/expr-if-fail-fn.rs @@ -4,6 +4,6 @@ // error-pattern:explicit failure fn f() -> ! { fail } -fn g() -> int { let x = if true { f() } else { 10 }; ret x; } +fn g() -> int { let x = if true { f() } else { 10 }; return x; } fn main() { g(); } diff --git a/src/test/run-fail/if-check-fail.rs b/src/test/run-fail/if-check-fail.rs index 0ca92ab18c4..e6f109745ae 100644 --- a/src/test/run-fail/if-check-fail.rs +++ b/src/test/run-fail/if-check-fail.rs @@ -1,8 +1,8 @@ // error-pattern:Number is odd pure fn even(x: uint) -> bool { if x < 2u { - ret false; - } else if x == 2u { ret true; } else { ret even(x - 2u); } + return false; + } else if x == 2u { return true; } else { return even(x - 2u); } } fn foo(x: uint) { diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs index 7a0324a0f16..ea25bb76545 100644 --- a/src/test/run-fail/unwind-misc-1.rs +++ b/src/test/run-fail/unwind-misc-1.rs @@ -9,10 +9,10 @@ fn main() { let count = @mut 0u; fn hash(&&s: ~[@~str]) -> uint { if (vec::len(s) > 0u && str::eq(*s[0], ~"boom")) { fail; } - ret 10u; + return 10u; } fn eq(&&s: ~[@~str], &&t: ~[@~str]) -> bool { - ret s == t; + return s == t; } let map = map::hashmap(hash, eq); diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 5f29e83f8f8..85bceea0ca2 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -11,7 +11,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] { let mut i = start; let mut r = ~[]; while i <= end { vec::push(r, i as char); i += 1u as u8; } - ret r; + return r; } fn enum_uints(start: uint, end: uint) -> ~[uint] { @@ -19,7 +19,7 @@ fn enum_uints(start: uint, end: uint) -> ~[uint] { let mut i = start; let mut r = ~[]; while i <= end { vec::push(r, i); i += 1u; } - ret r; + return r; } fn main() { diff --git a/src/test/run-pass-fulldeps/issue-1926.rs b/src/test/run-pass-fulldeps/issue-1926.rs index 5a19fb96464..5d7a11ca0d8 100644 --- a/src/test/run-pass-fulldeps/issue-1926.rs +++ b/src/test/run-pass-fulldeps/issue-1926.rs @@ -18,7 +18,7 @@ fn new_parse_sess() -> parser::parse_sess { mut chpos: 0u, mut byte_pos: 0u }; - ret sess; + return sess; } trait fake_ext_ctxt { diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs index 866ed58f842..699ee7ada70 100644 --- a/src/test/run-pass/alias-uninit-value.rs +++ b/src/test/run-pass/alias-uninit-value.rs @@ -10,7 +10,7 @@ enum sty { ty_nil, } type raw_t = {struct: sty, cname: option<~str>, hash: uint}; fn mk_raw_ty(st: sty, cname: option<~str>) -> raw_t { - ret {struct: st, cname: cname, hash: 0u}; + return {struct: st, cname: cname, hash: 0u}; } fn main() { mk_raw_ty(ty_nil, none::<~str>); } diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs index 4f6f215226e..2a1599cd074 100644 --- a/src/test/run-pass/alloca-from-derived-tydesc.rs +++ b/src/test/run-pass/alloca-from-derived-tydesc.rs @@ -2,6 +2,6 @@ enum option<T> { some(T), none, } type r<T> = {mut v: ~[option<T>]}; -fn f<T>() -> ~[T] { ret ~[]; } +fn f<T>() -> ~[T] { return ~[]; } fn main() { let r: r<int> = {mut v: ~[]}; r.v = f(); } diff --git a/src/test/run-pass/alt-bot-2.rs b/src/test/run-pass/alt-bot-2.rs index e3fd606c2d8..341fcdc38d5 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 ret 1 { 2 { 3 } } } +fn a() -> int { alt check return 1 { 2 { 3 } } } fn main() { a(); } diff --git a/src/test/run-pass/alt-join.rs b/src/test/run-pass/alt-join.rs index 637c2c8dabf..2ba2fedb386 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 { none::<T> { x = 17; } _ { x = 42; } } rs += ~[x]; } - ret; + return; } fn main() { debug!{"hello"}; foo::<int>(some::<int>(5)); } diff --git a/src/test/run-pass/alt-pattern-lit.rs b/src/test/run-pass/alt-pattern-lit.rs index e904818d688..aba7336a23b 100644 --- a/src/test/run-pass/alt-pattern-lit.rs +++ b/src/test/run-pass/alt-pattern-lit.rs @@ -2,8 +2,8 @@ fn altlit(f: int) -> int { alt check f { - 10 { debug!{"case 10"}; ret 20; } - 11 { debug!{"case 11"}; ret 22; } + 10 { debug!{"case 10"}; return 20; } + 11 { debug!{"case 11"}; return 22; } } } diff --git a/src/test/run-pass/alt-tag.rs b/src/test/run-pass/alt-tag.rs index 98fdb9ee2b8..f58eb29edb2 100644 --- a/src/test/run-pass/alt-tag.rs +++ b/src/test/run-pass/alt-tag.rs @@ -15,7 +15,7 @@ fn process(c: color) -> int { rgba(_, _, _, a) { debug!{"rgba"}; log(debug, a); x = a; } hsl(_, s, _) { debug!{"hsl"}; log(debug, s); x = s; } } - ret x; + return x; } fn main() { diff --git a/src/test/run-pass/alt-with-ret-arm.rs b/src/test/run-pass/alt-with-ret-arm.rs index b12841dd229..74a7e36a6e6 100644 --- a/src/test/run-pass/alt-with-ret-arm.rs +++ b/src/test/run-pass/alt-with-ret-arm.rs @@ -3,7 +3,7 @@ fn main() { // the right type for f, as we unified // bot and u32 here let f = alt uint::from_str(~"1234") { - none { ret () } + none { return () } some(num) { num as u32 } }; assert f == 1234u32; diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 4a349a827a4..1d1ae9c785f 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -2,10 +2,10 @@ fn f1(a: {mut x: int}, &b: int, -c: int) -> int { let r = a.x + b + c; a.x = 0; b = 10; - ret r; + return r; } -fn f2(a: int, f: fn(int)) -> int { f(1); ret a; } +fn f2(a: int, f: fn(int)) -> int { f(1); return a; } fn main() { let mut a = {mut x: 1}, b = 2, c = 3; diff --git a/src/test/run-pass/artificial-block.rs b/src/test/run-pass/artificial-block.rs index 87c7cc149f6..e8d8a3821d1 100644 --- a/src/test/run-pass/artificial-block.rs +++ b/src/test/run-pass/artificial-block.rs @@ -1,3 +1,3 @@ -fn f() -> int { { ret 3; } } +fn f() -> int { { return 3; } } fn main() { assert (f() == 3); } diff --git a/src/test/run-pass/assignability-iface.rs b/src/test/run-pass/assignability-iface.rs index f555f61f5b8..b5a3fd8af61 100644 --- a/src/test/run-pass/assignability-iface.rs +++ b/src/test/run-pass/assignability-iface.rs @@ -21,7 +21,7 @@ impl vec<A> of iterable<A> for ~[A] { fn length<A, T: iterable<A>>(x: T) -> uint { let mut len = 0; for x.iterate() |_y| { len += 1 } - ret len; + return len; } fn main() { diff --git a/src/test/run-pass/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index 0d5429e1980..522ead87c73 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn f<T: copy, U: copy>(x: T, y: U) -> {a: T, b: U} { ret {a: x, b: y}; } +fn f<T: copy, U: copy>(x: T, y: U) -> {a: T, b: U} { return {a: x, b: y}; } fn main() { log(debug, f({x: 3, y: 4, z: 5}, 4).a.x); diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 4b8f33e45bb..ad3b1366fca 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -1,6 +1,6 @@ -fn f<T: copy>(x: ~[T]) -> T { ret x[0]; } +fn f<T: copy>(x: ~[T]) -> T { return x[0]; } -fn g(act: fn(~[int]) -> int) -> int { ret act(~[1, 2, 3]); } +fn g(act: fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } fn main() { assert (g(f) == 1); diff --git a/src/test/run-pass/basic.rs b/src/test/run-pass/basic.rs index 786b34cb984..311b1f2a1f0 100644 --- a/src/test/run-pass/basic.rs +++ b/src/test/run-pass/basic.rs @@ -18,13 +18,13 @@ fn a(c: chan<int>) { send(c, 10); } -fn k(x: int) -> int { ret 15; } +fn k(x: int) -> int { return 15; } fn g(x: int, y: ~str) -> int { log(debug, x); log(debug, y); let z: int = k(1); - ret z; + return z; } fn main() { diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index 94c55ba33a1..348e2ef9cae 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -1,19 +1,19 @@ use std; fn asSendfn( f : fn~()->uint ) -> uint { - ret f(); + return f(); } fn asLambda( f : fn@()->uint ) -> uint { - ret f(); + return f(); } fn asBlock( f : fn&()->uint ) -> uint { - ret f(); + return f(); } fn asAny( f : fn()->uint ) -> uint { - ret f(); + return f(); } fn main() { diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs index 4d479418877..14b05b29dc3 100644 --- a/src/test/run-pass/block-arg-in-parentheses.rs +++ b/src/test/run-pass/block-arg-in-parentheses.rs @@ -14,7 +14,7 @@ fn w_paren2(v: ~[int]) -> int { } fn w_ret(v: ~[int]) -> int { - ret do vec::foldl(0, v) |x,y| { x+y } - 10; + return do vec::foldl(0, v) |x,y| { x+y } - 10; } fn main() { diff --git a/src/test/run-pass/block-arg-used-as-any.rs b/src/test/run-pass/block-arg-used-as-any.rs index 257d7c25831..426bffe2f95 100644 --- a/src/test/run-pass/block-arg-used-as-any.rs +++ b/src/test/run-pass/block-arg-used-as-any.rs @@ -1,5 +1,5 @@ fn call_any(f: fn() -> uint) -> uint { - ret f(); + return f(); } fn main() { diff --git a/src/test/run-pass/block-arg-used-as-lambda.rs b/src/test/run-pass/block-arg-used-as-lambda.rs index 46f3276a4e5..1eb1c4f7907 100644 --- a/src/test/run-pass/block-arg-used-as-lambda.rs +++ b/src/test/run-pass/block-arg-used-as-lambda.rs @@ -1,5 +1,5 @@ fn to_lambda(f: fn@(uint) -> uint) -> fn@(uint) -> uint { - ret f; + return f; } fn main() { diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index 70e6c432c91..cac00bd9a60 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -1,6 +1,6 @@ -fn force(f: fn() -> int) -> int { ret f(); } +fn force(f: fn() -> int) -> int { return f(); } fn main() { - fn f() -> int { ret 7; } + fn f() -> int { return 7; } assert (force(f) == 7); let g = {||force(f)}; assert (g() == 7); diff --git a/src/test/run-pass/borrowck-borrow-from-at-vec.rs b/src/test/run-pass/borrowck-borrow-from-at-vec.rs index 5d3b21783e5..a79b581c562 100644 --- a/src/test/run-pass/borrowck-borrow-from-at-vec.rs +++ b/src/test/run-pass/borrowck-borrow-from-at-vec.rs @@ -1,7 +1,7 @@ fn sum_slice(x: &[int]) -> int { let mut sum = 0; for x.each |i| { sum += i; } - ret sum; + return sum; } fn main() { diff --git a/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs b/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs index ef0803c00d0..7ef868dbac2 100644 --- a/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs +++ b/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs @@ -3,7 +3,7 @@ fn bar(x: *~int) -> ~int { unsafe { let y <- *x; - ret y; + return y; } } diff --git a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs index e5ea87b9996..b96a40dc088 100644 --- a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs +++ b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs @@ -1,7 +1,7 @@ fn want_slice(v: &[int]) -> int { let mut sum = 0; for vec::each(v) |i| { sum += i; } - ret sum; + return sum; } fn has_mut_vec(+v: ~[mut int]) -> int { diff --git a/src/test/run-pass/box-inside-if.rs b/src/test/run-pass/box-inside-if.rs index 3366906ec94..e9f9da8d16f 100644 --- a/src/test/run-pass/box-inside-if.rs +++ b/src/test/run-pass/box-inside-if.rs @@ -2,11 +2,11 @@ // -*- rust -*- -fn some_box(x: int) -> @int { ret @x; } +fn some_box(x: int) -> @int { return @x; } -fn is_odd(n: int) -> bool { ret true; } +fn is_odd(n: int) -> bool { return true; } -fn length_is_even(vs: @int) -> bool { ret true; } +fn length_is_even(vs: @int) -> bool { return true; } fn foo(acc: int, n: int) { if is_odd(n) && length_is_even(some_box(1)) { error!{"bloop"}; } diff --git a/src/test/run-pass/box-inside-if2.rs b/src/test/run-pass/box-inside-if2.rs index 97a7a919712..98ca1bc6370 100644 --- a/src/test/run-pass/box-inside-if2.rs +++ b/src/test/run-pass/box-inside-if2.rs @@ -2,11 +2,11 @@ // -*- rust -*- -fn some_box(x: int) -> @int { ret @x; } +fn some_box(x: int) -> @int { return @x; } -fn is_odd(n: int) -> bool { ret true; } +fn is_odd(n: int) -> bool { return true; } -fn length_is_even(vs: @int) -> bool { ret true; } +fn length_is_even(vs: @int) -> bool { return true; } fn foo(acc: int, n: int) { if is_odd(n) || length_is_even(some_box(1)) { error!{"bloop"}; } diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs index 48c7c046d37..e243867b268 100644 --- a/src/test/run-pass/box-unbox.rs +++ b/src/test/run-pass/box-unbox.rs @@ -2,7 +2,7 @@ type box<T: copy> = {c: @T}; -fn unbox<T: copy>(b: box<T>) -> T { ret *b.c; } +fn unbox<T: copy>(b: box<T>) -> T { return *b.c; } fn main() { let foo: int = 17; diff --git a/src/test/run-pass/break-value.rs b/src/test/run-pass/break-value.rs index 3aaadb759f7..6179226abbb 100644 --- a/src/test/run-pass/break-value.rs +++ b/src/test/run-pass/break-value.rs @@ -1,3 +1,3 @@ -fn int_id(x: int) -> int { ret x; } +fn int_id(x: int) -> int { return x; } fn main() { loop { int_id(break); } } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 7b62553a4e5..dc640d9dda8 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -9,11 +9,11 @@ extern mod libc { } fn atol(s: ~str) -> int { - ret str::as_buf(s, { |x, _len| libc::atol(x) }); + return str::as_buf(s, { |x, _len| libc::atol(x) }); } fn atoll(s: ~str) -> i64 { - ret str::as_buf(s, { |x, _len| libc::atoll(x) }); + return str::as_buf(s, { |x, _len| libc::atoll(x) }); } fn main() { diff --git a/src/test/run-pass/chan-leak.rs b/src/test/run-pass/chan-leak.rs index ffd115c5b4e..ca3f93a4df6 100644 --- a/src/test/run-pass/chan-leak.rs +++ b/src/test/run-pass/chan-leak.rs @@ -27,7 +27,7 @@ fn new_cx() -> ctx { let t = task::spawn(|| request_task(ch) ); let mut cx: ctx; cx = recv(p); - ret cx; + return cx; } fn main() { diff --git a/src/test/run-pass/class-cast-to-iface-cross-crate.rs b/src/test/run-pass/class-cast-to-iface-cross-crate.rs index 765aba74cc2..deb0462da84 100644 --- a/src/test/run-pass/class-cast-to-iface-cross-crate.rs +++ b/src/test/run-pass/class-cast-to-iface-cross-crate.rs @@ -27,11 +27,11 @@ class cat : to_str { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } diff --git a/src/test/run-pass/class-cast-to-iface.rs b/src/test/run-pass/class-cast-to-iface.rs index 0fba6a7b74b..42e0c9b337b 100644 --- a/src/test/run-pass/class-cast-to-iface.rs +++ b/src/test/run-pass/class-cast-to-iface.rs @@ -26,11 +26,11 @@ class cat : noisy { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/run-pass/class-impl-parameterized-iface.rs b/src/test/run-pass/class-impl-parameterized-iface.rs index fe31eb7a380..5c109481a91 100644 --- a/src/test/run-pass/class-impl-parameterized-iface.rs +++ b/src/test/run-pass/class-impl-parameterized-iface.rs @@ -29,11 +29,11 @@ class cat : map<int, bool> { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } diff --git a/src/test/run-pass/class-impl-very-parameterized-iface.rs b/src/test/run-pass/class-impl-very-parameterized-iface.rs index 2a5bcc98f06..ccdd94a934a 100644 --- a/src/test/run-pass/class-impl-very-parameterized-iface.rs +++ b/src/test/run-pass/class-impl-very-parameterized-iface.rs @@ -32,11 +32,11 @@ class cat<T: copy> : map<int, T> { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } diff --git a/src/test/run-pass/class-implement-iface-cross-crate.rs b/src/test/run-pass/class-implement-iface-cross-crate.rs index a66289a7ece..7aa2d9b684c 100644 --- a/src/test/run-pass/class-implement-iface-cross-crate.rs +++ b/src/test/run-pass/class-implement-iface-cross-crate.rs @@ -27,11 +27,11 @@ class cat : noisy { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/run-pass/class-implement-ifaces.rs b/src/test/run-pass/class-implement-ifaces.rs index 73a2e685af1..17e0a9902ab 100644 --- a/src/test/run-pass/class-implement-ifaces.rs +++ b/src/test/run-pass/class-implement-ifaces.rs @@ -26,11 +26,11 @@ class cat : noisy { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/run-pass/class-implements-multiple-ifaces.rs b/src/test/run-pass/class-implements-multiple-ifaces.rs index 968dfb07bf9..7f57aac1370 100644 --- a/src/test/run-pass/class-implements-multiple-ifaces.rs +++ b/src/test/run-pass/class-implements-multiple-ifaces.rs @@ -21,8 +21,8 @@ trait bitey { } fn vec_includes<T>(xs: ~[T], x: T) -> bool { - for each(xs) |y| { if y == x { ret true; }} - ret false; + for each(xs) |y| { if y == x { return true; }} + return false; } // vtables other than the 1st one don't seem to work @@ -68,7 +68,7 @@ class cat : noisy, scratchy, bitey { let mut rslt = none; for each(all) |thing| { if !self.scratched.contains(thing) { self.scratched.push(thing); - ret some(thing); }} + return some(thing); }} rslt } fn bite() -> body_part { @@ -102,7 +102,7 @@ fn bite_everything<T: bitey>(critter: T) -> bool { left = vec::filter(left, |p| p != part ); } else { - ret false; + return false; } } true diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 35c462e9dc2..95f12651b66 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -26,11 +26,11 @@ class cat { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/run-pass/classes.rs b/src/test/run-pass/classes.rs index 175d2c35c77..dbd590fb08f 100644 --- a/src/test/run-pass/classes.rs +++ b/src/test/run-pass/classes.rs @@ -22,11 +22,11 @@ class cat { if self.how_hungry > 0 { error!{"OM NOM NOM"}; self.how_hungry -= 2; - ret true; + return true; } else { error!{"Not hungry!"}; - ret false; + return false; } } } diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index 479a0e3d78d..2cf1276887e 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -1,5 +1,5 @@ // xfail-win32 -fn adder(+x: @int, +y: @int) -> int { ret *x + *y; } +fn adder(+x: @int, +y: @int) -> int { return *x + *y; } fn failer() -> @int { fail; } fn main() { assert(result::is_err(task::try(|| { diff --git a/src/test/run-pass/complex.rs b/src/test/run-pass/complex.rs index 104c312d673..748423429cc 100644 --- a/src/test/run-pass/complex.rs +++ b/src/test/run-pass/complex.rs @@ -13,7 +13,7 @@ fn putint(i: int) { while i < 36 { putstr(~"hi"); i = i + 1; } } -fn zerg(i: int) -> int { ret i; } +fn zerg(i: int) -> int { return i; } fn foo(x: int) -> int { let mut y: t = x + 2; @@ -22,7 +22,7 @@ fn foo(x: int) -> int { let mut z: t; z = 0x55; foo(z); - ret 0; + return 0; } fn main() { diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 8e99ca0da12..da18e9fabfb 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -39,7 +39,7 @@ class r { mod m { // This needs to parse but would fail in typeck. Since it's not in // the current config it should not be typechecked. - fn bogus() { ret 0; } + fn bogus() { return 0; } } mod m { diff --git a/src/test/run-pass/dead-code-one-arm-if.rs b/src/test/run-pass/dead-code-one-arm-if.rs index 0785005fac9..921a1ac8cc6 100644 --- a/src/test/run-pass/dead-code-one-arm-if.rs +++ b/src/test/run-pass/dead-code-one-arm-if.rs @@ -2,4 +2,4 @@ // -*- rust -*- -fn main() { if 1 == 1 { ret; } debug!{"Paul is dead"}; } +fn main() { if 1 == 1 { return; } debug!{"Paul is dead"}; } diff --git a/src/test/run-pass/deep.rs b/src/test/run-pass/deep.rs index 461d3c9ddfd..ca84abc5f60 100644 --- a/src/test/run-pass/deep.rs +++ b/src/test/run-pass/deep.rs @@ -3,7 +3,7 @@ // -*- rust -*- fn f(x: int) -> int { - if x == 1 { ret 1; } else { let y: int = 1 + f(x - 1); ret y; } + if x == 1 { return 1; } else { let y: int = 1 + f(x - 1); return y; } } fn main() { assert (f(5000) == 5000); } diff --git a/src/test/run-pass/drop-on-ret.rs b/src/test/run-pass/drop-on-ret.rs index 16722714bc3..d0e7b572f8c 100644 --- a/src/test/run-pass/drop-on-ret.rs +++ b/src/test/run-pass/drop-on-ret.rs @@ -2,6 +2,6 @@ // -*- rust -*- -fn f() -> int { if true { let s: ~str = ~"should not leak"; ret 1; } ret 0; } +fn f() -> int { if true { let s: ~str = ~"should not leak"; return 1; } return 0; } fn main() { f(); } diff --git a/src/test/run-pass/early-ret-binop-add.rs b/src/test/run-pass/early-ret-binop-add.rs index 977536cd57c..efe2ffae100 100644 --- a/src/test/run-pass/early-ret-binop-add.rs +++ b/src/test/run-pass/early-ret-binop-add.rs @@ -1,2 +1,2 @@ -fn wsucc(n: int) -> int { 0 + { ret n + 1 } } +fn wsucc(n: int) -> int { 0 + { return n + 1 } } fn main() { } diff --git a/src/test/run-pass/early-ret-binop.rs b/src/test/run-pass/early-ret-binop.rs index 118bec708b8..cd60f9b7856 100644 --- a/src/test/run-pass/early-ret-binop.rs +++ b/src/test/run-pass/early-ret-binop.rs @@ -1,2 +1,2 @@ -fn wsucc(n: int) -> int { ({ ret n + 1 } == 0); } +fn wsucc(n: int) -> int { ({ return n + 1 } == 0); } fn main() { } diff --git a/src/test/run-pass/export-abstract-tag.rs b/src/test/run-pass/export-abstract-tag.rs index 6a840037641..eb76676ece6 100644 --- a/src/test/run-pass/export-abstract-tag.rs +++ b/src/test/run-pass/export-abstract-tag.rs @@ -7,7 +7,7 @@ mod foo { enum t { t1, } - fn f() -> t { ret t1; } + fn f() -> t { return t1; } } fn main() { let v: foo::t = foo::f(); } diff --git a/src/test/run-pass/export-unexported-dep.rs b/src/test/run-pass/export-unexported-dep.rs index 856f568e788..3392f109015 100644 --- a/src/test/run-pass/export-unexported-dep.rs +++ b/src/test/run-pass/export-unexported-dep.rs @@ -8,7 +8,7 @@ mod foo { // not exported enum t { t1, t2, } - fn f() -> t { ret t1; } + fn f() -> t { return t1; } fn g(v: t) { assert (v == t1); } } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index aa90fb785ec..3254996d141 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -10,7 +10,7 @@ fn test_generic<T>(expected: @T, eq: compare<T>) { } fn test_box() { - fn compare_box(b1: @bool, b2: @bool) -> bool { ret *b1 == *b2; } + fn compare_box(b1: @bool, b2: @bool) -> bool { return *b1 == *b2; } test_generic::<bool>(@true, compare_box); } diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index 78383513cd4..d5fad94a464 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -10,7 +10,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_box(&&v1: @int, &&v2: @int) -> bool { ret v1 == v2; } + fn compare_box(&&v1: @int, &&v2: @int) -> bool { return v1 == v2; } test_generic::<@int>(@1, compare_box); } diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index d7d639bcbcb..35a631062a8 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -9,7 +9,7 @@ fn test_generic<T: copy>(expected: ~T, eq: compare<T>) { } fn test_box() { - fn compare_box(b1: ~bool, b2: ~bool) -> bool { ret *b1 == *b2; } + fn compare_box(b1: ~bool, b2: ~bool) -> bool { return *b1 == *b2; } test_generic::<bool>(~true, compare_box); } diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index a1923e2dd8c..95b79e9b3b9 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -10,7 +10,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_box(&&v1: ~int, &&v2: ~int) -> bool { ret v1 == v2; } + fn compare_box(&&v1: ~int, &&v2: ~int) -> bool { return v1 == v2; } test_generic::<~int>(~1, compare_box); } diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index 57d519b62cb..b4078a7d907 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -10,14 +10,14 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { } fn test_bool() { - fn compare_bool(&&b1: bool, &&b2: bool) -> bool { ret b1 == b2; } + fn compare_bool(&&b1: bool, &&b2: bool) -> bool { return b1 == b2; } test_generic::<bool>(true, compare_bool); } fn test_rec() { type t = {a: int, b: int}; - fn compare_rec(t1: t, t2: t) -> bool { ret t1 == t2; } + fn compare_rec(t1: t, t2: t) -> bool { return t1 == t2; } test_generic::<t>({a: 1, b: 2}, compare_rec); } diff --git a/src/test/run-pass/expr-block-fn.rs b/src/test/run-pass/expr-block-fn.rs index 9fbe930b7f7..7ec1b0eb022 100644 --- a/src/test/run-pass/expr-block-fn.rs +++ b/src/test/run-pass/expr-block-fn.rs @@ -2,7 +2,7 @@ fn test_fn() { type t = extern fn() -> int; - fn ten() -> int { ret 10; } + fn ten() -> int { return 10; } let rs: t = { ten }; assert (rs() == 10); } diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index f4be90bfe34..a453ae2fa6e 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -13,7 +13,7 @@ fn test_box() { fn compare_box(b1: @bool, b2: @bool) -> bool { log(debug, *b1); log(debug, *b2); - ret *b1 == *b2; + return *b1 == *b2; } test_generic::<bool>(@true, compare_box); } diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 8d8fc5020d5..7935cec7f5d 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -10,7 +10,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_vec(&&v1: @int, &&v2: @int) -> bool { ret v1 == v2; } + fn compare_vec(&&v1: @int, &&v2: @int) -> bool { return v1 == v2; } test_generic::<@int>(@1, compare_vec); } diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index c7953536546..df94544acd1 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -12,7 +12,7 @@ fn test_box() { fn compare_box(b1: ~bool, b2: ~bool) -> bool { log(debug, *b1); log(debug, *b2); - ret *b1 == *b2; + return *b1 == *b2; } test_generic::<bool>(~true, compare_box); } diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 7b210b66f1f..51bb0274e7f 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -10,7 +10,7 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_vec(&&v1: ~int, &&v2: ~int) -> bool { ret v1 == v2; } + fn compare_vec(&&v1: ~int, &&v2: ~int) -> bool { return v1 == v2; } test_generic::<~int>(~1, compare_vec); } diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index d5a329189b5..3aff514d2ca 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -12,14 +12,14 @@ fn test_generic<T: copy>(expected: T, eq: compare<T>) { } fn test_bool() { - fn compare_bool(&&b1: bool, &&b2: bool) -> bool { ret b1 == b2; } + fn compare_bool(&&b1: bool, &&b2: bool) -> bool { return b1 == b2; } test_generic::<bool>(true, compare_bool); } fn test_rec() { type t = {a: int, b: int}; - fn compare_rec(t1: t, t2: t) -> bool { ret t1 == t2; } + fn compare_rec(t1: t, t2: t) -> bool { return t1 == t2; } test_generic::<t>({a: 1, b: 2}, compare_rec); } diff --git a/src/test/run-pass/expr-empty-ret.rs b/src/test/run-pass/expr-empty-ret.rs index 6044c6e8ff7..0a50faf4401 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 { ret } }; } +fn f() { let x = alt 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 b197d3c7e28..3b32df0ec79 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -30,7 +30,7 @@ fn test_block() { fn test_ret() { fn f() -> int { - ret 10 // no semi + return 10 // no semi } assert (f() == 10); diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index 0eea4a8ee34..13d224d73ec 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -10,7 +10,7 @@ fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) { } fn test_box() { - fn compare_box(b1: @bool, b2: @bool) -> bool { ret *b1 == *b2; } + fn compare_box(b1: @bool, b2: @bool) -> bool { return *b1 == *b2; } test_generic::<bool>(@true, @false, compare_box); } diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index e4379e22e80..ef56bcd41dc 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -10,7 +10,7 @@ fn test_generic<T: copy>(expected: T, not_expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_box(&&v1: @int, &&v2: @int) -> bool { ret v1 == v2; } + fn compare_box(&&v1: @int, &&v2: @int) -> bool { return v1 == v2; } test_generic::<@int>(@1, @2, compare_box); } diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index cb44a03af2d..e664d4e242f 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -12,14 +12,14 @@ fn test_generic<T: copy>(expected: T, not_expected: T, eq: compare<T>) { } fn test_bool() { - fn compare_bool(&&b1: bool, &&b2: bool) -> bool { ret b1 == b2; } + fn compare_bool(&&b1: bool, &&b2: bool) -> bool { return b1 == b2; } test_generic::<bool>(true, false, compare_bool); } fn test_rec() { type t = {a: int, b: int}; - fn compare_rec(t1: t, t2: t) -> bool { ret t1 == t2; } + fn compare_rec(t1: t, t2: t) -> bool { return t1 == t2; } test_generic::<t>({a: 1, b: 2}, {a: 2, b: 3}, compare_rec); } diff --git a/src/test/run-pass/expr-scope.rs b/src/test/run-pass/expr-scope.rs index 53c8223c778..d974b1ec5a9 100644 --- a/src/test/run-pass/expr-scope.rs +++ b/src/test/run-pass/expr-scope.rs @@ -2,4 +2,4 @@ // xfail-fast fn f() { } -fn main() { ret ::f(); } +fn main() { return ::f(); } diff --git a/src/test/run-pass/fact.rs b/src/test/run-pass/fact.rs index bf2329a94ff..e682fde8776 100644 --- a/src/test/run-pass/fact.rs +++ b/src/test/run-pass/fact.rs @@ -9,7 +9,7 @@ fn f(x: int) -> int { if x == 1 { // debug!{"bottoming out"}; - ret 1; + return 1; } else { // debug!{"recurring"}; @@ -17,7 +17,7 @@ fn f(x: int) -> int { // debug!{"returned"}; log(debug, y); - ret y; + return y; } } diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs index 7f1a983ce7b..7bf1b813e93 100644 --- a/src/test/run-pass/fixed-point-bind-box.rs +++ b/src/test/run-pass/fixed-point-bind-box.rs @@ -1,14 +1,14 @@ fn fix_help<A, B>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B { - ret f({|a|fix_help(f, a)}, x); + return f({|a|fix_help(f, a)}, x); } fn fix<A, B>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { - ret {|a|fix_help(f, a)}; + return {|a|fix_help(f, a)}; } fn fact_(f: fn@(&&int) -> int, &&n: int) -> int { // fun fact 0 = 1 - ret if n == 0 { 1 } else { n * f(n - 1) }; + return if n == 0 { 1 } else { n * f(n - 1) }; } fn main() { diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 029af017f65..95ebd437b88 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -1,14 +1,14 @@ fn fix_help<A: owned, B: send>(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B { - ret f({|a|fix_help(f, a)}, x); + return f({|a|fix_help(f, a)}, x); } fn fix<A: owned, B: send>(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { - ret {|a|fix_help(f, a)}; + return {|a|fix_help(f, a)}; } fn fact_(f: fn@(&&int) -> int, &&n: int) -> int { // fun fact 0 = 1 - ret if n == 0 { 1 } else { n * f(n - 1) }; + return if n == 0 { 1 } else { n * f(n - 1) }; } fn main() { diff --git a/src/test/run-pass/float-signature.rs b/src/test/run-pass/float-signature.rs index c9cfbe40e0e..df156bccdc5 100644 --- a/src/test/run-pass/float-signature.rs +++ b/src/test/run-pass/float-signature.rs @@ -1,7 +1,7 @@ fn main() { - fn foo(n: float) -> float { ret n + 0.12345; } + fn foo(n: float) -> float { return n + 0.12345; } let n: float = 0.1; let m: float = foo(n); log(debug, m); diff --git a/src/test/run-pass/fn-lval.rs b/src/test/run-pass/fn-lval.rs index bc3eae6e707..69ba49702e4 100644 --- a/src/test/run-pass/fn-lval.rs +++ b/src/test/run-pass/fn-lval.rs @@ -4,6 +4,6 @@ // -*- rust -*- fn foo(f: extern fn(int) -> int) { } -fn id(x: int) -> int { ret x; } +fn id(x: int) -> int { return x; } fn main() { foo(id); } diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 010df0158ed..85623dd21e4 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -13,7 +13,7 @@ extern mod libc { fn strlen(str: ~str) -> uint unsafe { // C string is terminated with a zero let bytes = str::bytes(str) + ~[0u8]; - ret libc::my_strlen(vec::unsafe::to_ptr(bytes)); + return libc::my_strlen(vec::unsafe::to_ptr(bytes)); } fn main() { diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index 408bd665534..88f817e0339 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -1,7 +1,7 @@ // -*- rust -*- -fn ho(f: fn@(int) -> int) -> int { let n: int = f(3); ret n; } +fn ho(f: fn@(int) -> int) -> int { let n: int = f(3); return n; } -fn direct(x: int) -> int { ret x + 1; } +fn direct(x: int) -> int { return x + 1; } fn main() { let a: int = direct(3); // direct diff --git a/src/test/run-pass/fun-indirect-call.rs b/src/test/run-pass/fun-indirect-call.rs index e89378fe1b5..b7337da92c8 100644 --- a/src/test/run-pass/fun-indirect-call.rs +++ b/src/test/run-pass/fun-indirect-call.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn f() -> int { ret 42; } +fn f() -> int { return 42; } fn main() { let g: extern fn() -> int = f; diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index b9bc823a8b9..c273672f781 100644 --- a/src/test/run-pass/generic-alias-box.rs +++ b/src/test/run-pass/generic-alias-box.rs @@ -1,6 +1,6 @@ -fn id<T: copy>(t: T) -> T { ret t; } +fn id<T: copy>(t: T) -> T { return t; } fn main() { let expected = @100; diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 4d2811da7b1..79285589766 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -1,6 +1,6 @@ -fn id<T: copy send>(t: T) -> T { ret t; } +fn id<T: copy send>(t: T) -> T { return t; } fn main() { let expected = ~100; diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs index 14fb924492a..3d871c896a8 100644 --- a/src/test/run-pass/generic-box.rs +++ b/src/test/run-pass/generic-box.rs @@ -1,6 +1,6 @@ -fn box<T: copy>(x: {x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { ret @x; } +fn box<T: copy>(x: {x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { return @x; } fn main() { let x: @{x: int, y: int, z: int} = box::<int>({x: 1, y: 2, z: 3}); diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 39f4c0d1472..cb406e85980 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -1,12 +1,12 @@ -fn g<X: copy>(x: X) -> X { ret x; } +fn g<X: copy>(x: X) -> X { return x; } fn f<T: copy>(t: T) -> {a: T, b: T} { type pair = {a: T, b: T}; let x: pair = {a: t, b: t}; - ret g::<pair>(x); + return g::<pair>(x); } fn main() { diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index 8c042a9e76d..c683da09bdf 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -2,7 +2,7 @@ type recbox<T: copy> = {x: @T}; -fn reclift<T: copy>(t: T) -> recbox<T> { ret {x: @t}; } +fn reclift<T: copy>(t: T) -> recbox<T> { return {x: @t}; } fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index 6f985120d42..227bb7066c4 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -1,6 +1,6 @@ type recbox<T: copy> = {x: ~T}; -fn reclift<T: copy>(t: T) -> recbox<T> { ret {x: ~t}; } +fn reclift<T: copy>(t: T) -> recbox<T> { return {x: ~t}; } fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs index 4f0bd22944e..97d827e994d 100644 --- a/src/test/run-pass/generic-fn-box.rs +++ b/src/test/run-pass/generic-fn-box.rs @@ -1,5 +1,5 @@ -fn f<T>(x: @T) -> @T { ret x; } +fn f<T>(x: @T) -> @T { return x; } fn main() { let x = f(@3); log(debug, *x); } diff --git a/src/test/run-pass/generic-fn-infer.rs b/src/test/run-pass/generic-fn-infer.rs index 31f0008fc0b..b375752d1a1 100644 --- a/src/test/run-pass/generic-fn-infer.rs +++ b/src/test/run-pass/generic-fn-infer.rs @@ -4,6 +4,6 @@ // -*- rust -*- // Issue #45: infer type parameters in function applications -fn id<T: copy>(x: T) -> T { ret x; } +fn id<T: copy>(x: T) -> T { return x; } fn main() { let x: int = 42; let y: int = id(x); assert (x == y); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index 749341c1a19..7d54afd59eb 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -1,4 +1,4 @@ -fn f<T: copy>(x: ~T) -> ~T { ret x; } +fn f<T: copy>(x: ~T) -> ~T { return x; } fn main() { let x = f(~3); log(debug, *x); } diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index 4aac6559fe3..fae711ae3ad 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn id<T: copy>(x: T) -> T { ret x; } +fn id<T: copy>(x: T) -> T { return x; } type triple = {x: int, y: int, z: int}; diff --git a/src/test/run-pass/generic-temporary.rs b/src/test/run-pass/generic-temporary.rs index 29a1a4482f7..f0a16e79fb0 100644 --- a/src/test/run-pass/generic-temporary.rs +++ b/src/test/run-pass/generic-temporary.rs @@ -1,6 +1,6 @@ -fn mk() -> int { ret 1; } +fn mk() -> int { return 1; } fn chk(&&a: int) { log(debug, a); assert (a == 1); } diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index 58a33b80946..b660592720c 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -1,4 +1,4 @@ -fn get_third<T: copy>(t: (T, T, T)) -> T { let (_, _, x) = t; ret x; } +fn get_third<T: copy>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } fn main() { log(debug, get_third((1, 2, 3))); diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index 686bd36888e..0572257a877 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -1,5 +1,5 @@ -fn box<T: copy>(x: {x: T, y: T, z: T}) -> ~{x: T, y: T, z: T} { ret ~x; } +fn box<T: copy>(x: {x: T, y: T, z: T}) -> ~{x: T, y: T, z: T} { return ~x; } fn main() { let x: ~{x: int, y: int, z: int} = box::<int>({x: 1, y: 2, z: 3}); diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs index d7c1ab785ff..89181c15691 100644 --- a/src/test/run-pass/global-scope.rs +++ b/src/test/run-pass/global-scope.rs @@ -1,11 +1,11 @@ // xfail-fast -fn f() -> int { ret 1; } +fn f() -> int { return 1; } mod foo { - fn f() -> int { ret 2; } + fn f() -> int { return 2; } fn g() { assert (f() == 2); assert (::f() == 1); } } -fn main() { ret foo::g(); } +fn main() { return foo::g(); } diff --git a/src/test/run-pass/if-check.rs b/src/test/run-pass/if-check.rs index 78208ec6149..38c44945f21 100644 --- a/src/test/run-pass/if-check.rs +++ b/src/test/run-pass/if-check.rs @@ -1,7 +1,7 @@ pure fn even(x: uint) -> bool { if x < 2u { - ret false; - } else if x == 2u { ret true; } else { ret even(x - 2u); } + return false; + } else if x == 2u { return true; } else { return even(x - 2u); } } fn foo(x: uint) { diff --git a/src/test/run-pass/if-ret.rs b/src/test/run-pass/if-ret.rs index 87cd9647243..71be22dda06 100644 --- a/src/test/run-pass/if-ret.rs +++ b/src/test/run-pass/if-ret.rs @@ -1,3 +1,3 @@ -fn foo() { if (ret) { } } +fn foo() { if (return) { } } fn main() { foo(); } diff --git a/src/test/run-pass/issue-1974.rs b/src/test/run-pass/issue-1974.rs index e8d27aa5e5c..ffa6108cd52 100644 --- a/src/test/run-pass/issue-1974.rs +++ b/src/test/run-pass/issue-1974.rs @@ -3,6 +3,6 @@ fn main() { let s = ~"hej"; while s != ~"" { - ret; + return; } } \ No newline at end of file diff --git a/src/test/run-pass/issue-1989.rs b/src/test/run-pass/issue-1989.rs index 2ee30d48571..a389730f042 100644 --- a/src/test/run-pass/issue-1989.rs +++ b/src/test/run-pass/issue-1989.rs @@ -11,7 +11,7 @@ type pointy = { }; fn empty_pointy() -> @pointy { - ret @{ + return @{ mut a : none, mut f : fn@()->(){}, } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 67f90d6e3d6..a5e2d8ba613 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -25,7 +25,7 @@ fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { do self.iter |a| { b <- blk(b, a); } - ret b; + return b; } fn range(lo: uint, hi: uint, it: fn(uint)) { diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs index 7847ef3c8e0..1a986fa757a 100644 --- a/src/test/run-pass/issue-2214.rs +++ b/src/test/run-pass/issue-2214.rs @@ -2,7 +2,7 @@ import libc::{c_double, c_int}; import f64::*; fn lgamma(n: c_double, value: &mut int) -> c_double { - ret m::lgamma(n, value as &mut c_int); + return m::lgamma(n, value as &mut c_int); } #[link_name = "m"] diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 412bcb5b66a..5ffcab99a7b 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -89,11 +89,11 @@ mod pipes { full { let mut payload = none; payload <-> (*p).payload; - ret some(option::unwrap(payload)) + return some(option::unwrap(payload)) } terminated { assert old_state == terminated; - ret none; + return none; } } } diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index 06202bc1c0b..3452beaf7f4 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -1,5 +1,5 @@ -fn quux<T: copy>(x: T) -> T { let f = id::<T>; ret f(x); } +fn quux<T: copy>(x: T) -> T { let f = id::<T>; return f(x); } -fn id<T: copy>(x: T) -> T { ret x; } +fn id<T: copy>(x: T) -> T { return x; } fn main() { assert (quux(10) == 10); } diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 216344942e7..652336145f6 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -1,6 +1,6 @@ -fn double<T: copy>(a: T) -> ~[T] { ret ~[a] + ~[a]; } +fn double<T: copy>(a: T) -> ~[T] { return ~[a] + ~[a]; } -fn double_int(a: int) -> ~[int] { ret ~[a] + ~[a]; } +fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } fn main() { let mut d = double(1); 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 459648452e4..1473c433e53 100644 --- a/src/test/run-pass/keyword-changes-2012-07-31.rs +++ b/src/test/run-pass/keyword-changes-2012-07-31.rs @@ -1,4 +1,4 @@ -// ret -> return +// return -> return // mod -> module // alt -> match diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index 745fc345dc0..c1dc0b76a10 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -3,7 +3,7 @@ fn lp<T>(s: ~str, f: fn(~str) -> T) -> T { while false { let r = f(s); - ret r; + return r; } fail; } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index fc5425f24e9..baa03abeeb9 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -3,7 +3,7 @@ fn foo() -> fn@() -> int { let k = ~22; let _u = {a: k}; - ret fn@(move k) -> int { 22 }; + return fn@(move k) -> int { 22 }; } fn main() { diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index e5d1f814047..7ad71854dc4 100644 --- a/src/test/run-pass/lazy-and-or.rs +++ b/src/test/run-pass/lazy-and-or.rs @@ -1,6 +1,6 @@ -fn incr(&x: int) -> bool { x += 1; assert (false); ret false; } +fn incr(&x: int) -> bool { x += 1; assert (false); return false; } fn main() { let x = 1 == 2 || 3 == 3; diff --git a/src/test/run-pass/liveness-assign-imm-local-after-ret.rs b/src/test/run-pass/liveness-assign-imm-local-after-ret.rs index 028bf10201b..cbab7079a46 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-ret.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-ret.rs @@ -1,7 +1,7 @@ fn test() { let _v: int; _v = 1; - ret; + return; _v = 2; //~ WARNING: unreachable statement } diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index eb3bca93c07..bb042f2359b 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -9,7 +9,7 @@ type smallintmap<T> = @{mut v: ~[mut option<T>]}; fn mk<T>() -> smallintmap<T> { let v: ~[mut option<T>] = ~[mut]; - ret @{mut v: v}; + return @{mut v: v}; } fn f<T,U>() { diff --git a/src/test/run-pass/macro-2.rs b/src/test/run-pass/macro-2.rs index 509238e7e48..b5d3d693f6a 100644 --- a/src/test/run-pass/macro-2.rs +++ b/src/test/run-pass/macro-2.rs @@ -3,7 +3,7 @@ fn main() { #macro[[#mylambda[x, body], { - fn f(x: int) -> int { ret body; } + fn f(x: int) -> int { return body; } f }]]; @@ -11,7 +11,7 @@ fn main() { macro_rules! mylambda_tt{ {$x:ident, $body:expr} => { - fn f($x: int) -> int { ret $body; }; + fn f($x: int) -> int { return $body; }; f } } diff --git a/src/test/run-pass/macro-by-example-1.rs b/src/test/run-pass/macro-by-example-1.rs index 020f200998d..ba8c8d93a63 100644 --- a/src/test/run-pass/macro-by-example-1.rs +++ b/src/test/run-pass/macro-by-example-1.rs @@ -6,7 +6,7 @@ fn main() { {$f:expr, ($($x:expr),*)} => {$f($($x),*)} } - fn add(a: int, b: int) -> int { ret a + b; } + fn add(a: int, b: int) -> int { return a + b; } assert(apply!{add, [1, 15]} == 16); assert(apply!{add, [1, 15]} == 16); diff --git a/src/test/run-pass/macro-by-example-2.rs b/src/test/run-pass/macro-by-example-2.rs index eda697156a9..c0693cd059a 100644 --- a/src/test/run-pass/macro-by-example-2.rs +++ b/src/test/run-pass/macro-by-example-2.rs @@ -27,7 +27,7 @@ fn main() { #macro[[#lambda[x, #<t>, body, #<s>], { - fn result(x: t) -> s { ret body } + fn result(x: t) -> s { return body } result }]]; diff --git a/src/test/run-pass/maybe-mutable.rs b/src/test/run-pass/maybe-mutable.rs index abbf50ed67b..f85c4d6d20e 100644 --- a/src/test/run-pass/maybe-mutable.rs +++ b/src/test/run-pass/maybe-mutable.rs @@ -5,7 +5,7 @@ fn len(v: ~[const int]) -> uint { let mut i = 0u; while i < vec::len(v) { i += 1u; } - ret i; + return i; } fn main() { diff --git a/src/test/run-pass/morestack3.rs b/src/test/run-pass/morestack3.rs index 2ba7945894a..7833c12b158 100644 --- a/src/test/run-pass/morestack3.rs +++ b/src/test/run-pass/morestack3.rs @@ -33,7 +33,7 @@ fn getbig(a0: int, a9 - 1); assert j == a0 - 1; } - ret a0; + return a0; } fn main() { diff --git a/src/test/run-pass/move-1-unique.rs b/src/test/run-pass/move-1-unique.rs index 64268bcabaa..ec37e14c47c 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -3,7 +3,7 @@ fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int { let bar = foo; let mut y: ~{x: int, y: int, z: int}; if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; } - ret y.y; + return y.y; } fn main() { diff --git a/src/test/run-pass/move-1.rs b/src/test/run-pass/move-1.rs index 586fa3c89aa..c510626a08c 100644 --- a/src/test/run-pass/move-1.rs +++ b/src/test/run-pass/move-1.rs @@ -2,7 +2,7 @@ fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int { let bar = foo; let mut y: @{x: int, y: int, z: int}; if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; } - ret y.y; + return y.y; } fn main() { diff --git a/src/test/run-pass/move-3-unique.rs b/src/test/run-pass/move-3-unique.rs index ad757d5cc12..02dd0ca999f 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -5,7 +5,7 @@ fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int { let bar = foo; let mut y: ~{x: int, y: int, z: int}; if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; } - ret y.y; + return y.y; } fn main() { diff --git a/src/test/run-pass/move-3.rs b/src/test/run-pass/move-3.rs index 1ba6ed29fbb..467865f8b80 100644 --- a/src/test/run-pass/move-3.rs +++ b/src/test/run-pass/move-3.rs @@ -5,7 +5,7 @@ fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int { let bar = foo; let mut y: @{x: int, y: int, z: int}; if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; } - ret y.y; + return y.y; } fn main() { diff --git a/src/test/run-pass/move-4-unique.rs b/src/test/run-pass/move-4-unique.rs index 1fffce98e52..c2049efdfcb 100644 --- a/src/test/run-pass/move-4-unique.rs +++ b/src/test/run-pass/move-4-unique.rs @@ -6,7 +6,7 @@ fn test(foo: ~{a: int, b: int, c: int}) -> ~{a: int, b: int, c: int} { let bar <- foo; let baz <- bar; let quux <- baz; - ret quux; + return quux; } fn main() { let x = ~{a: 1, b: 2, c: 3}; let y = test(x); assert (y.c == 3); } diff --git a/src/test/run-pass/move-4.rs b/src/test/run-pass/move-4.rs index aaaf05938a8..2d6e71ae346 100644 --- a/src/test/run-pass/move-4.rs +++ b/src/test/run-pass/move-4.rs @@ -7,7 +7,7 @@ fn test(foo: @{a: int, b: int, c: int}) -> @{a: int, b: int, c: int} { let bar <- foo; let baz <- bar; let quux <- baz; - ret quux; + return quux; } fn main() { let x = @{a: 1, b: 2, c: 3}; let y = test(x); assert (y.c == 3); } diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index b0f62cc3ea9..619f3711a2e 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -2,7 +2,7 @@ fn main() { class b { let i: int; - fn do_stuff() -> int { ret 37; } + fn do_stuff() -> int { return 37; } new(i:int) { self.i = i; } } diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index e550155cb60..7ddb2800e9a 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -1,9 +1,9 @@ // Test that the lambda kind is inferred correctly as a return // expression -fn shared() -> fn@() { ret || (); } +fn shared() -> fn@() { return || (); } -fn unique() -> fn~() { ret || (); } +fn unique() -> fn~() { return || (); } fn main() { } diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index dac7b8c4f1f..3b9ce49273f 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -5,7 +5,7 @@ fn f(i: int, f: fn(int) -> int) -> int { f(i) } fn g(g: fn()) { } fn ff() -> fn@(int) -> int { - ret |x| x + 1; + return |x| x + 1; } fn main() { diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index d5f2d62bdfa..fa6b0b86012 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -1,8 +1,8 @@ enum myvec<X> = ~[X]; -fn myvec_deref<X: copy>(mv: myvec<X>) -> ~[X] { ret *mv; } +fn myvec_deref<X: copy>(mv: myvec<X>) -> ~[X] { return *mv; } -fn myvec_elt<X: copy>(mv: myvec<X>) -> X { ret mv[0]; } +fn myvec_elt<X: copy>(mv: myvec<X>) -> X { return mv[0]; } fn main() { let mv = myvec(~[1, 2, 3]); diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index f6a9be124f3..213770b0a66 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -1,6 +1,6 @@ enum mytype = {compute: extern fn(mytype) -> int, val: int}; -fn compute(i: mytype) -> int { ret i.val + 20; } +fn compute(i: mytype) -> int { return i.val + 20; } fn main() { let myval = mytype({compute: compute, val: 30}); diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index da3f19062dd..02926c0eff5 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -12,7 +12,7 @@ pure fn nonempty_list<T: copy>(ls: @list<T>) -> bool { pure_length(ls) > 0u } fn safe_head<T: copy>(ls: @list<T>) -> T { assert is_not_empty(ls); - ret head(ls); + return head(ls); } fn main() { diff --git a/src/test/run-pass/or-pattern.rs b/src/test/run-pass/or-pattern.rs index 8419fc6ee67..aca2232ffc5 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) { ret x + y; } c { ret 0; } } + alt q { a(x, y, _) | b(x, y) { return x + y; } c { return 0; } } } fn main() { diff --git a/src/test/run-pass/osmain.rs b/src/test/run-pass/osmain.rs index f4736e75949..50db95026ea 100644 --- a/src/test/run-pass/osmain.rs +++ b/src/test/run-pass/osmain.rs @@ -11,7 +11,7 @@ fn run(i: int) { log(debug, i); if i == 0 { - ret; + return; } do task::task().sched_mode(task::osmain).unlinked().spawn { diff --git a/src/test/run-pass/output-slot-variants.rs b/src/test/run-pass/output-slot-variants.rs index ae21a487441..ff53e304a72 100644 --- a/src/test/run-pass/output-slot-variants.rs +++ b/src/test/run-pass/output-slot-variants.rs @@ -1,16 +1,16 @@ -fn ret_int_i() -> int { ret 10; } +fn ret_int_i() -> int { return 10; } -fn ret_ext_i() -> @int { ret @10; } +fn ret_ext_i() -> @int { return @10; } -fn ret_int_rec() -> {a: int, b: int} { ret {a: 10, b: 10}; } +fn ret_int_rec() -> {a: int, b: int} { return {a: 10, b: 10}; } -fn ret_ext_rec() -> @{a: int, b: int} { ret @{a: 10, b: 10}; } +fn ret_ext_rec() -> @{a: int, b: int} { return @{a: 10, b: 10}; } -fn ret_ext_mem() -> {a: @int, b: @int} { ret {a: @10, b: @10}; } +fn ret_ext_mem() -> {a: @int, b: @int} { return {a: @10, b: @10}; } -fn ret_ext_ext_mem() -> @{a: @int, b: @int} { ret @{a: @10, b: @10}; } +fn ret_ext_ext_mem() -> @{a: @int, b: @int} { return @{a: @10, b: @10}; } fn main() { let mut int_i: int; diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index c4dbc3eaefd..7aade69c9da 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -73,7 +73,7 @@ mod test { fn client(-chan: pingpong::client::ping) { import pingpong::client; - let chan = client::ping(chan); ret; + let chan = client::ping(chan); return; log(error, "Sent ping"); let pong(_chan) = recv(chan); log(error, "Received pong"); @@ -82,7 +82,7 @@ mod test { fn server(-chan: pingpong::server::ping) { import pingpong::server; - let ping(chan) = recv(chan); ret; + let ping(chan) = recv(chan); return; log(error, "Received ping"); let _chan = server::pong(chan); log(error, "Sent pong"); diff --git a/src/test/run-pass/pred-not-bool.rs b/src/test/run-pass/pred-not-bool.rs index 67b5a877c05..c5549eac33e 100644 --- a/src/test/run-pass/pred-not-bool.rs +++ b/src/test/run-pass/pred-not-bool.rs @@ -1,6 +1,6 @@ // this checks that a pred with a non-bool return // type is rejected, even if the pred is never used -pure fn bad(a: int) -> int { ret 37; } //~ ERROR Non-boolean return type +pure fn bad(a: int) -> int { return 37; } //~ ERROR Non-boolean return type fn main() { } diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index 1b24c65e8fa..66eeb21b754 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -6,7 +6,7 @@ pure fn sums_to(v: ~[int], sum: int) -> bool { sum0 += v[i]; i += 1u; } - ret sum0 == sum; + return sum0 == sum; } pure fn sums_to_using_uniq(v: ~[int], sum: int) -> bool { @@ -15,7 +15,7 @@ pure fn sums_to_using_uniq(v: ~[int], sum: int) -> bool { *sum0 += v[i]; i += 1u; } - ret *sum0 == sum; + return *sum0 == sum; } pure fn sums_to_using_rec(v: ~[int], sum: int) -> bool { @@ -24,7 +24,7 @@ pure fn sums_to_using_rec(v: ~[int], sum: int) -> bool { sum0.f += v[i]; i += 1u; } - ret sum0.f == sum; + return sum0.f == sum; } pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool { @@ -33,7 +33,7 @@ pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool { *sum0.f += v[i]; i += 1u; } - ret *sum0.f == sum; + return *sum0.f == sum; } fn main() { diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index d9cd2640b4d..5aa8dd01733 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -5,7 +5,7 @@ trait get { // Note: impl on a slice impl foo of get for &int { fn get() -> int { - ret *self; + return *self; } } diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index 9a9dcfb21e6..f770fed1969 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -7,7 +7,7 @@ impl foo of sum for &[int] { fn sum() -> int { let mut sum = 0; for vec::each(self) |e| { sum += e; } - ret sum; + return sum; } } diff --git a/src/test/run-pass/rec-tup.rs b/src/test/run-pass/rec-tup.rs index e5375403dfe..8fda72c9684 100644 --- a/src/test/run-pass/rec-tup.rs +++ b/src/test/run-pass/rec-tup.rs @@ -3,8 +3,8 @@ type point = {x: int, y: int}; type rect = (point, point); -fn fst(r: rect) -> point { let (fst, _) = r; ret fst; } -fn snd(r: rect) -> point { let (_, snd) = r; ret snd; } +fn fst(r: rect) -> point { let (fst, _) = r; return fst; } +fn snd(r: rect) -> point { let (_, snd) = r; return snd; } fn f(r: rect, x1: int, y1: int, x2: int, y2: int) { assert (fst(r).x == x1); diff --git a/src/test/run-pass/record-pat.rs b/src/test/run-pass/record-pat.rs index f4d52646e76..1adc8c5838b 100644 --- a/src/test/run-pass/record-pat.rs +++ b/src/test/run-pass/record-pat.rs @@ -4,8 +4,8 @@ enum t3 { c(t2, uint), } fn m(in: t3) -> int { alt in { - c({x: a(m), _}, _) { ret m; } - c({x: b(m), y: y}, z) { ret ((m + z) as int) + y; } + 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/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index 2e38cc4b348..3b6c7d5962c 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -54,147 +54,147 @@ impl ptr_visitor<V: ty_visitor movable_ptr> fn visit_bot() -> bool { self.align_to::<()>(); - if ! self.inner.visit_bot() { ret false; } + if ! self.inner.visit_bot() { return false; } self.bump_past::<()>(); true } fn visit_nil() -> bool { self.align_to::<()>(); - if ! self.inner.visit_nil() { ret false; } + if ! self.inner.visit_nil() { return false; } self.bump_past::<()>(); true } fn visit_bool() -> bool { self.align_to::<bool>(); - if ! self.inner.visit_bool() { ret false; } + if ! self.inner.visit_bool() { return false; } self.bump_past::<bool>(); true } fn visit_int() -> bool { self.align_to::<int>(); - if ! self.inner.visit_int() { ret false; } + if ! self.inner.visit_int() { return false; } self.bump_past::<int>(); true } fn visit_i8() -> bool { self.align_to::<i8>(); - if ! self.inner.visit_i8() { ret false; } + if ! self.inner.visit_i8() { return false; } self.bump_past::<i8>(); true } fn visit_i16() -> bool { self.align_to::<i16>(); - if ! self.inner.visit_i16() { ret false; } + if ! self.inner.visit_i16() { return false; } self.bump_past::<i16>(); true } fn visit_i32() -> bool { self.align_to::<i32>(); - if ! self.inner.visit_i32() { ret false; } + if ! self.inner.visit_i32() { return false; } self.bump_past::<i32>(); true } fn visit_i64() -> bool { self.align_to::<i64>(); - if ! self.inner.visit_i64() { ret false; } + if ! self.inner.visit_i64() { return false; } self.bump_past::<i64>(); true } fn visit_uint() -> bool { self.align_to::<uint>(); - if ! self.inner.visit_uint() { ret false; } + if ! self.inner.visit_uint() { return false; } self.bump_past::<uint>(); true } fn visit_u8() -> bool { self.align_to::<u8>(); - if ! self.inner.visit_u8() { ret false; } + if ! self.inner.visit_u8() { return false; } self.bump_past::<u8>(); true } fn visit_u16() -> bool { self.align_to::<u16>(); - if ! self.inner.visit_u16() { ret false; } + if ! self.inner.visit_u16() { return false; } self.bump_past::<u16>(); true } fn visit_u32() -> bool { self.align_to::<u32>(); - if ! self.inner.visit_u32() { ret false; } + if ! self.inner.visit_u32() { return false; } self.bump_past::<u32>(); true } fn visit_u64() -> bool { self.align_to::<u64>(); - if ! self.inner.visit_u64() { ret false; } + if ! self.inner.visit_u64() { return false; } self.bump_past::<u64>(); true } fn visit_float() -> bool { self.align_to::<float>(); - if ! self.inner.visit_float() { ret false; } + if ! self.inner.visit_float() { return false; } self.bump_past::<float>(); true } fn visit_f32() -> bool { self.align_to::<f32>(); - if ! self.inner.visit_f32() { ret false; } + if ! self.inner.visit_f32() { return false; } self.bump_past::<f32>(); true } fn visit_f64() -> bool { self.align_to::<f64>(); - if ! self.inner.visit_f64() { ret false; } + if ! self.inner.visit_f64() { return false; } self.bump_past::<f64>(); true } fn visit_char() -> bool { self.align_to::<char>(); - if ! self.inner.visit_char() { ret false; } + if ! self.inner.visit_char() { return false; } self.bump_past::<char>(); true } fn visit_str() -> bool { self.align_to::<~str>(); - if ! self.inner.visit_str() { ret false; } + if ! self.inner.visit_str() { return false; } self.bump_past::<~str>(); true } fn visit_estr_box() -> bool { self.align_to::<@str>(); - if ! self.inner.visit_estr_box() { ret false; } + if ! self.inner.visit_estr_box() { return false; } self.bump_past::<@str>(); true } fn visit_estr_uniq() -> bool { self.align_to::<~str>(); - if ! self.inner.visit_estr_uniq() { ret false; } + if ! self.inner.visit_estr_uniq() { return false; } self.bump_past::<~str>(); true } fn visit_estr_slice() -> bool { self.align_to::<&static/str>(); - if ! self.inner.visit_estr_slice() { ret false; } + if ! self.inner.visit_estr_slice() { return false; } self.bump_past::<&static/str>(); true } @@ -203,35 +203,35 @@ impl ptr_visitor<V: ty_visitor movable_ptr> sz: uint, align: uint) -> bool { self.align(align); - if ! self.inner.visit_estr_fixed(n, sz, align) { ret false; } + if ! self.inner.visit_estr_fixed(n, sz, align) { return false; } self.bump(sz); true } fn visit_box(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<@u8>(); - if ! self.inner.visit_box(mtbl, inner) { ret false; } + if ! self.inner.visit_box(mtbl, inner) { return false; } self.bump_past::<@u8>(); true } fn visit_uniq(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<~u8>(); - if ! self.inner.visit_uniq(mtbl, inner) { ret false; } + if ! self.inner.visit_uniq(mtbl, inner) { return false; } self.bump_past::<~u8>(); true } fn visit_ptr(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<*u8>(); - if ! self.inner.visit_ptr(mtbl, inner) { ret false; } + if ! self.inner.visit_ptr(mtbl, inner) { return false; } self.bump_past::<*u8>(); true } fn visit_rptr(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<&static/u8>(); - if ! self.inner.visit_rptr(mtbl, inner) { ret false; } + if ! self.inner.visit_rptr(mtbl, inner) { return false; } self.bump_past::<&static/u8>(); true } @@ -242,34 +242,34 @@ impl ptr_visitor<V: ty_visitor movable_ptr> // or else possibly we could have some weird interface wherein we // read-off a word from inner's pointers, but the read-word has to // always be the same in all sub-pointers? Dubious. - if ! self.inner.visit_vec(mtbl, inner) { ret false; } + if ! self.inner.visit_vec(mtbl, inner) { return false; } true } fn visit_vec(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<~[u8]>(); - if ! self.inner.visit_vec(mtbl, inner) { ret false; } + if ! self.inner.visit_vec(mtbl, inner) { return false; } self.bump_past::<~[u8]>(); true } fn visit_evec_box(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<@[u8]>(); - if ! self.inner.visit_evec_box(mtbl, inner) { ret false; } + if ! self.inner.visit_evec_box(mtbl, inner) { return false; } self.bump_past::<@[u8]>(); true } fn visit_evec_uniq(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<~[u8]>(); - if ! self.inner.visit_evec_uniq(mtbl, inner) { ret false; } + if ! self.inner.visit_evec_uniq(mtbl, inner) { return false; } self.bump_past::<~[u8]>(); true } fn visit_evec_slice(mtbl: uint, inner: *tydesc) -> bool { self.align_to::<&static/[u8]>(); - if ! self.inner.visit_evec_slice(mtbl, inner) { ret false; } + if ! self.inner.visit_evec_slice(mtbl, inner) { return false; } self.bump_past::<&static/[u8]>(); true } @@ -278,7 +278,7 @@ impl ptr_visitor<V: ty_visitor movable_ptr> mtbl: uint, inner: *tydesc) -> bool { self.align(align); if ! self.inner.visit_evec_fixed(n, sz, align, mtbl, inner) { - ret false; + return false; } self.bump(sz); true @@ -286,25 +286,25 @@ impl ptr_visitor<V: ty_visitor movable_ptr> fn visit_enter_rec(n_fields: uint, sz: uint, align: uint) -> bool { self.align(align); - if ! self.inner.visit_enter_rec(n_fields, sz, align) { ret false; } + if ! self.inner.visit_enter_rec(n_fields, sz, align) { return false; } true } fn visit_rec_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool { - if ! self.inner.visit_rec_field(i, name, mtbl, inner) { ret false; } + if ! self.inner.visit_rec_field(i, name, mtbl, inner) { return false; } true } fn visit_leave_rec(n_fields: uint, sz: uint, align: uint) -> bool { - if ! self.inner.visit_leave_rec(n_fields, sz, align) { ret false; } + if ! self.inner.visit_leave_rec(n_fields, sz, align) { return false; } true } fn visit_enter_class(n_fields: uint, sz: uint, align: uint) -> bool { self.align(align); if ! self.inner.visit_enter_class(n_fields, sz, align) { - ret false; + return false; } true } @@ -312,63 +312,63 @@ impl ptr_visitor<V: ty_visitor movable_ptr> fn visit_class_field(i: uint, name: &str, mtbl: uint, inner: *tydesc) -> bool { if ! self.inner.visit_class_field(i, name, mtbl, inner) { - ret false; + return false; } true } fn visit_leave_class(n_fields: uint, sz: uint, align: uint) -> bool { if ! self.inner.visit_leave_class(n_fields, sz, align) { - ret false; + return false; } true } fn visit_enter_tup(n_fields: uint, sz: uint, align: uint) -> bool { self.align(align); - if ! self.inner.visit_enter_tup(n_fields, sz, align) { ret false; } + if ! self.inner.visit_enter_tup(n_fields, sz, align) { return false; } true } fn visit_tup_field(i: uint, inner: *tydesc) -> bool { - if ! self.inner.visit_tup_field(i, inner) { ret false; } + if ! self.inner.visit_tup_field(i, inner) { return false; } true } fn visit_leave_tup(n_fields: uint, sz: uint, align: uint) -> bool { - if ! self.inner.visit_leave_tup(n_fields, sz, align) { ret false; } + if ! self.inner.visit_leave_tup(n_fields, sz, align) { return false; } true } fn visit_enter_fn(purity: uint, proto: uint, n_inputs: uint, retstyle: uint) -> bool { if ! self.inner.visit_enter_fn(purity, proto, n_inputs, retstyle) { - ret false + return false } true } fn visit_fn_input(i: uint, mode: uint, inner: *tydesc) -> bool { - if ! self.inner.visit_fn_input(i, mode, inner) { ret false; } + if ! self.inner.visit_fn_input(i, mode, inner) { return false; } true } fn visit_fn_output(retstyle: uint, inner: *tydesc) -> bool { - if ! self.inner.visit_fn_output(retstyle, inner) { ret false; } + if ! self.inner.visit_fn_output(retstyle, inner) { return false; } true } fn visit_leave_fn(purity: uint, proto: uint, n_inputs: uint, retstyle: uint) -> bool { if ! self.inner.visit_leave_fn(purity, proto, n_inputs, retstyle) { - ret false; + return false; } true } fn visit_enter_enum(n_variants: uint, sz: uint, align: uint) -> bool { self.align(align); - if ! self.inner.visit_enter_enum(n_variants, sz, align) { ret false; } + if ! self.inner.visit_enter_enum(n_variants, sz, align) { return false; } true } @@ -378,13 +378,13 @@ impl ptr_visitor<V: ty_visitor movable_ptr> name: &str) -> bool { if ! self.inner.visit_enter_enum_variant(variant, disr_val, n_fields, name) { - ret false; + return false; } true } fn visit_enum_variant_field(i: uint, inner: *tydesc) -> bool { - if ! self.inner.visit_enum_variant_field(i, inner) { ret false; } + if ! self.inner.visit_enum_variant_field(i, inner) { return false; } true } @@ -394,65 +394,65 @@ impl ptr_visitor<V: ty_visitor movable_ptr> name: &str) -> bool { if ! self.inner.visit_leave_enum_variant(variant, disr_val, n_fields, name) { - ret false; + return false; } true } fn visit_leave_enum(n_variants: uint, sz: uint, align: uint) -> bool { - if ! self.inner.visit_leave_enum(n_variants, sz, align) { ret false; } + if ! self.inner.visit_leave_enum(n_variants, sz, align) { return false; } true } fn visit_trait() -> bool { self.align_to::<ty_visitor>(); - if ! self.inner.visit_trait() { ret false; } + if ! self.inner.visit_trait() { return false; } self.bump_past::<ty_visitor>(); true } fn visit_var() -> bool { - if ! self.inner.visit_var() { ret false; } + if ! self.inner.visit_var() { return false; } true } fn visit_var_integral() -> bool { - if ! self.inner.visit_var_integral() { ret false; } + if ! self.inner.visit_var_integral() { return false; } true } fn visit_param(i: uint) -> bool { - if ! self.inner.visit_param(i) { ret false; } + if ! self.inner.visit_param(i) { return false; } true } fn visit_self() -> bool { self.align_to::<&static/u8>(); - if ! self.inner.visit_self() { ret false; } + if ! self.inner.visit_self() { return false; } self.align_to::<&static/u8>(); true } fn visit_type() -> bool { - if ! self.inner.visit_type() { ret false; } + if ! self.inner.visit_type() { return false; } true } fn visit_opaque_box() -> bool { self.align_to::<@u8>(); - if ! self.inner.visit_opaque_box() { ret false; } + if ! self.inner.visit_opaque_box() { return false; } self.bump_past::<@u8>(); true } fn visit_constr(inner: *tydesc) -> bool { - if ! self.inner.visit_constr(inner) { ret false; } + if ! self.inner.visit_constr(inner) { return false; } true } fn visit_closure_ptr(ck: uint) -> bool { self.align_to::<fn@()>(); - if ! self.inner.visit_closure_ptr(ck) { ret false; } + if ! self.inner.visit_closure_ptr(ck) { return false; } self.bump_past::<fn@()>(); true } diff --git a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs index e9a3d0b3ec3..2fa7db00815 100644 --- a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs +++ b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs @@ -5,7 +5,7 @@ fn get_x(x: &character) -> &int { // interesting case because the scope of this // borrow of the unique pointer is in fact // larger than the fn itself - ret &x.pos.x; + return &x.pos.x; } fn main() { diff --git a/src/test/run-pass/regions-addr-of-ret.rs b/src/test/run-pass/regions-addr-of-ret.rs index f4e1221e3db..2a78eea2f81 100644 --- a/src/test/run-pass/regions-addr-of-ret.rs +++ b/src/test/run-pass/regions-addr-of-ret.rs @@ -1,5 +1,5 @@ fn f(x : &a/int) -> &a/int { - ret &*x; + return &*x; } fn main() { diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index 0f099672f40..2378052b24a 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -1,7 +1,7 @@ type point = {x: int, y: int}; fn x_coord(p: &point) -> &int { - ret &p.x; + return &p.x; } fn main() { diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index de7f0c2739f..6b7848c267c 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -17,7 +17,7 @@ type ccx = { impl arena for arena { fn alloc_inner(sz: uint, _align: uint) -> *() unsafe { - ret unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t)); + return unsafe::reinterpret_cast(libc::malloc(sz as libc::size_t)); } fn alloc(tydesc: *()) -> *() { unsafe { @@ -28,7 +28,7 @@ impl arena for arena { } fn h(bcx : &bcx) -> &bcx { - ret new(*bcx.fcx.arena) { fcx: bcx.fcx }; + return new(*bcx.fcx.arena) { fcx: bcx.fcx }; } fn g(fcx : &fcx) { @@ -42,7 +42,7 @@ fn g(fcx : &fcx) { fn f(ccx : &ccx) { let a = arena(()); let fcx = { arena: &a, ccx: ccx }; - ret g(&fcx); + return g(&fcx); } fn main() { diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs index 15d3b7a4e14..5bbc8412afc 100644 --- a/src/test/run-pass/regions-mock-trans.rs +++ b/src/test/run-pass/regions-mock-trans.rs @@ -16,12 +16,12 @@ type ccx = { }; fn alloc(_bcx : &arena) -> &bcx unsafe { - ret unsafe::reinterpret_cast( + return unsafe::reinterpret_cast( libc::malloc(sys::size_of::<bcx/&blk>() as libc::size_t)); } fn h(bcx : &bcx) -> &bcx { - ret alloc(bcx.fcx.arena); + return alloc(bcx.fcx.arena); } fn g(fcx : &fcx) { @@ -35,7 +35,7 @@ fn g(fcx : &fcx) { fn f(ccx : &ccx) { let a = arena(()); let fcx = { arena: &a, ccx: ccx }; - ret g(&fcx); + return g(&fcx); } fn main() { diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 07457aa492b..40c1ea0e360 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -5,7 +5,7 @@ trait get_chowder { } impl clam of get_chowder for clam { - fn get_chowder() -> &self/int { ret self.chowder; } + fn get_chowder() -> &self/int { return self.chowder; } } fn main() { diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index 9565f7691e9..4cd713c4e3a 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -1,6 +1,6 @@ class shrinky_pointer { let i: @@mut int; - fn look_at() -> int { ret **(self.i); } + fn look_at() -> int { return **(self.i); } new(i: @@mut int) { self.i = i; } drop { log(error, ~"Hello!"); **(self.i) -= 1; } } diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index 122188643de..eb92aa1386e 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -5,7 +5,7 @@ fn my_err(s: ~str) -> ! { log(error, s); fail; } fn okay(i: uint) -> int { - if i == 3u { my_err(~"I don't like three"); } else { ret 42; } + if i == 3u { my_err(~"I don't like three"); } else { return 42; } } fn main() { okay(4u); } diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs index 5dc448a3e6c..f66b6ebf0a9 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -9,7 +9,7 @@ fn iter<T>(v: ~[T], it: fn(T) -> bool) { fn find_pos<T>(n: T, h: ~[T]) -> option<uint> { let mut i = 0u; for iter(h) |e| { - if e == n { ret some(i); } + if e == n { return some(i); } i += 1u; } none @@ -20,7 +20,7 @@ fn bail_deep(x: ~[~[bool]]) { for iter(x) |x| { for iter(x) |x| { assert !seen; - if x { seen = true; ret; } + if x { seen = true; return; } } } assert !seen; @@ -29,10 +29,10 @@ fn bail_deep(x: ~[~[bool]]) { fn ret_deep() -> ~str { for iter(~[1, 2]) |e| { for iter(~[3, 4]) |x| { - if e + x > 4 { ret ~"hi"; } + if e + x > 4 { return ~"hi"; } } } - ret ~"bye"; + return ~"bye"; } fn main() { diff --git a/src/test/run-pass/ret-none.rs b/src/test/run-pass/ret-none.rs index 468dbf5f3f2..1533bb9ef09 100644 --- a/src/test/run-pass/ret-none.rs +++ b/src/test/run-pass/ret-none.rs @@ -2,6 +2,6 @@ enum option<T> { none, some(T), } -fn f<T: copy>() -> option<T> { ret none; } +fn f<T: copy>() -> option<T> { return none; } fn main() { f::<int>(); } diff --git a/src/test/run-pass/return-nil.rs b/src/test/run-pass/return-nil.rs index a7a55e60971..07ce9818193 100644 --- a/src/test/run-pass/return-nil.rs +++ b/src/test/run-pass/return-nil.rs @@ -1,5 +1,5 @@ -fn f() { let x: () = (); ret x; } +fn f() { let x: () = (); return x; } fn main() { let x = f(); } diff --git a/src/test/run-pass/self-shadowing-import.rs b/src/test/run-pass/self-shadowing-import.rs index 7887990f080..af2d419c1d6 100644 --- a/src/test/run-pass/self-shadowing-import.rs +++ b/src/test/run-pass/self-shadowing-import.rs @@ -1,7 +1,7 @@ mod a { mod b { mod a { - fn foo() -> int { ret 1; } + fn foo() -> int { return 1; } } } } diff --git a/src/test/run-pass/sendfn-deep-copy.rs b/src/test/run-pass/sendfn-deep-copy.rs index 666c6805593..94c63a283e4 100644 --- a/src/test/run-pass/sendfn-deep-copy.rs +++ b/src/test/run-pass/sendfn-deep-copy.rs @@ -9,7 +9,7 @@ fn mk_counter<A:copy>() -> fn~(A) -> (A,uint) { // The only reason that the counter is generic is so that it closes // over both a type descriptor and some data. let v = ~[mut 0u]; - ret fn~(a: A) -> (A,uint) { + return fn~(a: A) -> (A,uint) { let n = v[0]; v[0] = n + 1u; (a, n) diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index 2a4d675c321..df3b476358b 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -8,7 +8,7 @@ fn main() { test05(); } type pair<A,B> = { a: A, b: B }; fn make_generic_record<A: copy, B: copy>(a: A, b: B) -> pair<A,B> { - ret {a: a, b: b}; + return {a: a, b: b}; } fn test05_start(&&f: fn~(&&float, &&~str) -> pair<float, ~str>) { @@ -25,7 +25,7 @@ fn test05_start(&&f: fn~(&&float, &&~str) -> pair<float, ~str>) { fn spawn<A: copy, B: copy>(f: extern fn(fn~(A,B)->pair<A,B>)) { let arg = fn~(a: A, b: B) -> pair<A,B> { - ret make_generic_record(a, b); + return make_generic_record(a, b); }; task::spawn(|| f(arg) ); } diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 1476a015828..21af730caba 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -1,8 +1,8 @@ fn test(f: fn(uint) -> uint) -> uint { - ret f(22u); + return f(22u); } fn main() { - let y = test(fn~(x: uint) -> uint { ret 4u * x; }); + let y = test(fn~(x: uint) -> uint { return 4u * x; }); assert y == 88u; } \ No newline at end of file diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index 18f612b19ad..e96a632431a 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -10,12 +10,12 @@ type t_rec = { }; fn mk_rec() -> t_rec { - ret { c8:0u8, t:a_tag(0u64) }; + return { c8:0u8, t:a_tag(0u64) }; } fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool { let p = ptr::addr_of(u) as uint; - ret (p & 7u) == 0u; + return (p & 7u) == 0u; } fn main() { diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 10ea8f80b65..9ceede21207 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -13,12 +13,12 @@ type t_rec<A,B> = { }; fn mk_rec<A:copy,B:copy>(a: A, b: B) -> t_rec<A,B> { - ret { chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) }; + return { chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) }; } fn is_aligned<A>(amnt: uint, &&u: A) -> bool { let p = ptr::addr_of(u) as uint; - ret (p & (amnt-1u)) == 0u; + return (p & (amnt-1u)) == 0u; } fn variant_data_is_aligned<A,B>(amnt: uint, &&u: a_tag<A,B>) -> bool { diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index f0df400cf19..b05fceebeab 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -10,12 +10,12 @@ type t_rec = { }; fn mk_rec() -> t_rec { - ret { c8:0u8, t:a_tag(0u64) }; + return { c8:0u8, t:a_tag(0u64) }; } fn is_8_byte_aligned(&&u: a_tag) -> bool { let p = ptr::addr_of(u) as u64; - ret (p & 7u64) == 0u64; + return (p & 7u64) == 0u64; } fn main() { diff --git a/src/test/run-pass/tail-call-arg-leak.rs b/src/test/run-pass/tail-call-arg-leak.rs index 9b9631867e2..f35e6cc24cc 100644 --- a/src/test/run-pass/tail-call-arg-leak.rs +++ b/src/test/run-pass/tail-call-arg-leak.rs @@ -2,6 +2,6 @@ // use of tail calls causes arg slot leaks, issue #160. -fn inner(dummy: ~str, b: bool) { if b { ret inner(dummy, false); } } +fn inner(dummy: ~str, b: bool) { if b { return inner(dummy, false); } } fn main() { inner(~"hi", true); } diff --git a/src/test/run-pass/tail-cps.rs b/src/test/run-pass/tail-cps.rs index 88344eb3174..2b921bd7726 100644 --- a/src/test/run-pass/tail-cps.rs +++ b/src/test/run-pass/tail-cps.rs @@ -2,18 +2,18 @@ // -*- rust -*- -fn checktrue(rs: bool) -> bool { assert (rs); ret true; } +fn checktrue(rs: bool) -> bool { assert (rs); return true; } fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } fn evenk(n: int, k: extern fn(bool) -> bool) -> bool { debug!{"evenk"}; log(debug, n); - if n == 0 { ret k(true); } else { ret oddk(n - 1, k); } + if n == 0 { return k(true); } else { return oddk(n - 1, k); } } fn oddk(n: int, k: extern fn(bool) -> bool) -> bool { debug!{"oddk"}; log(debug, n); - if n == 0 { ret k(false); } else { ret evenk(n - 1, k); } + if n == 0 { return k(false); } else { return evenk(n - 1, k); } } diff --git a/src/test/run-pass/tail-direct.rs b/src/test/run-pass/tail-direct.rs index bfb0b19340e..ad95a0d831f 100644 --- a/src/test/run-pass/tail-direct.rs +++ b/src/test/run-pass/tail-direct.rs @@ -4,6 +4,6 @@ // -*- rust -*- fn main() { assert (even(42)); assert (odd(45)); } -fn even(n: int) -> bool { if n == 0 { ret true; } else { ret odd(n - 1); } } +fn even(n: int) -> bool { if n == 0 { return true; } else { return odd(n - 1); } } -fn odd(n: int) -> bool { if n == 0 { ret false; } else { ret even(n - 1); } } +fn odd(n: int) -> bool { if n == 0 { return false; } else { return even(n - 1); } } diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index 3064583b752..a6091fc3170 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -8,7 +8,7 @@ fn test_break() { loop { let x: @int = break; } } fn test_cont() { let mut i = 0; while i < 1 { i += 1; let x: @int = again; } } -fn test_ret() { let x: @int = ret; } +fn test_ret() { let x: @int = return; } fn test_fail() { fn f() { let x: @int = fail; } diff --git a/src/test/run-pass/test-ignore-cfg.rs b/src/test/run-pass/test-ignore-cfg.rs index 49fc6e88ec4..c983a442f7a 100644 --- a/src/test/run-pass/test-ignore-cfg.rs +++ b/src/test/run-pass/test-ignore-cfg.rs @@ -18,7 +18,7 @@ fn shouldnotignore() { #[test] fn checktests() { - // Pull the tests out of the secret test module + // Pull the tests out of the secreturn test module let tests = __test::tests(); let shouldignore = option::get( diff --git a/src/test/run-pass/type-namespace.rs b/src/test/run-pass/type-namespace.rs index 03c8ce0972a..3aef58301ce 100644 --- a/src/test/run-pass/type-namespace.rs +++ b/src/test/run-pass/type-namespace.rs @@ -1,5 +1,5 @@ type a = {a: int}; -fn a(a: a) -> int { ret a.a; } +fn a(a: a) -> int { return a.a; } fn main() { let x: a = {a: 1}; assert (a(x) == 1); } diff --git a/src/test/run-pass/type-ptr.rs b/src/test/run-pass/type-ptr.rs index dd572d8655c..d980ad34b9b 100644 --- a/src/test/run-pass/type-ptr.rs +++ b/src/test/run-pass/type-ptr.rs @@ -1,5 +1,5 @@ -fn f(a: *int) -> *int { ret a; } +fn f(a: *int) -> *int { return a; } -fn g(a: *int) -> *int { let b = f(a); ret b; } +fn g(a: *int) -> *int { let b = f(a); return b; } -fn main(args: ~[~str]) { ret; } +fn main(args: ~[~str]) { return; } diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index d72c8f82cba..5c7e2228ab4 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -13,7 +13,7 @@ fn make_uniq_closure<A:send copy>(a: A) -> fn~() -> uint { } fn empty_pointy() -> @pointy { - ret @{ + return @{ mut a : none, d : make_uniq_closure(~"hi") } diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs index f238e3e4e9f..95007591783 100644 --- a/src/test/run-pass/uniq-cc.rs +++ b/src/test/run-pass/uniq-cc.rs @@ -10,7 +10,7 @@ type pointy = { }; fn empty_pointy() -> @pointy { - ret @{ + return @{ mut a : none, c : ~22, d : fn~()->(){}, diff --git a/src/test/run-pass/unit.rs b/src/test/run-pass/unit.rs index 7fb75242349..ccbd1564658 100644 --- a/src/test/run-pass/unit.rs +++ b/src/test/run-pass/unit.rs @@ -2,11 +2,11 @@ // -*- rust -*- -fn f(u: ()) { ret u; } +fn f(u: ()) { return u; } fn main() { let u1: () = (); let mut u2: () = f(u1); u2 = (); - ret (); + return (); } diff --git a/src/test/run-pass/unreachable-code-1.rs b/src/test/run-pass/unreachable-code-1.rs index fba080ac7f5..75fe81e5cd7 100644 --- a/src/test/run-pass/unreachable-code-1.rs +++ b/src/test/run-pass/unreachable-code-1.rs @@ -7,7 +7,7 @@ fn call_id() { id(c); //~ WARNING unreachable statement } -fn call_id_3() { id(ret) && id(ret); } +fn call_id_3() { id(return) && id(return); } fn main() { } diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index 0d1a4991751..2747ed2755e 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -7,23 +7,23 @@ fn call_id() { id(c); } -fn call_id_2() { id(true) && id(ret); } +fn call_id_2() { id(true) && id(return); } -fn call_id_3() { id(ret) && id(ret); } +fn call_id_3() { id(return) && id(return); } fn log_fail() { log(error, fail); } -fn log_ret() { log(error, ret); } +fn log_ret() { log(error, return); } fn log_break() { loop { log(error, break); } } fn log_again() { loop { log(error, again); } } -fn ret_ret() -> int { ret (ret 2) + 3; } +fn ret_ret() -> int { return (return 2) + 3; } fn ret_guard() { alt 2 { - x if (ret) { x; } + x if (return) { x; } _ {} } } diff --git a/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs b/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs index af2b09cc37a..d7ad4e2faf1 100644 --- a/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs +++ b/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs @@ -2,7 +2,7 @@ // // See also: compile-fail/unsafe-fn-called-from-safe.rs -unsafe fn f() { ret; } +unsafe fn f() { return; } fn g() { unsafe { diff --git a/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs b/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs index 445fdff80aa..9cfc86bafbe 100644 --- a/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs +++ b/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs @@ -2,12 +2,12 @@ // // See also: compile-fail/unsafe-fn-called-from-safe.rs -unsafe fn f() { ret; } +unsafe fn f() { return; } unsafe fn g() { f(); } fn main() { - ret; + return; } diff --git a/src/test/run-pass/use-import-export.rs b/src/test/run-pass/use-import-export.rs index 99b87578d8d..798bcb8c84f 100644 --- a/src/test/run-pass/use-import-export.rs +++ b/src/test/run-pass/use-import-export.rs @@ -1,11 +1,11 @@ mod foo { - fn x() -> int { ret 1; } + fn x() -> int { return 1; } } mod bar { - fn y() -> int { ret 1; } + fn y() -> int { return 1; } } fn main() { foo::x(); bar::y(); } diff --git a/src/test/run-pass/use-uninit-alt.rs b/src/test/run-pass/use-uninit-alt.rs index 3280e61b855..76e1c95ca58 100644 --- a/src/test/run-pass/use-uninit-alt.rs +++ b/src/test/run-pass/use-uninit-alt.rs @@ -3,7 +3,7 @@ fn foo<T>(o: myoption<T>) -> int { let mut x: int = 5; alt o { none::<T> { } some::<T>(t) { x += 1; } } - ret x; + return x; } enum myoption<T> { none, some(T), } diff --git a/src/test/run-pass/use-uninit-alt2.rs b/src/test/run-pass/use-uninit-alt2.rs index 283c4c630a3..0479d3c9555 100644 --- a/src/test/run-pass/use-uninit-alt2.rs +++ b/src/test/run-pass/use-uninit-alt2.rs @@ -3,7 +3,7 @@ fn foo<T>(o: myoption<T>) -> int { let mut x: int; alt o { none::<T> { fail; } some::<T>(t) { x = 5; } } - ret x; + return x; } enum myoption<T> { none, some(T), } diff --git a/src/test/run-pass/utf8_idents.rs b/src/test/run-pass/utf8_idents.rs index 993a6c9aa42..3d842c2731c 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -31,5 +31,5 @@ fn საჭმელად_გემრიელი_სადილი() -> int assert 10 == ארוחת_צהריי; assert ランチ + 午餐 + μεσημεριανό == 30; assert ăn_trưa + อาหารกลางวัน == 20; - ret (абед + լանչ) >> غداء; + return (абед + լանչ) >> غداء; } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 0b0f20a8b31..5dd7d91640e 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -1,14 +1,14 @@ // Just a grab bag of stuff that you wouldn't want to actually write. -fn strange() -> bool { let _x: bool = ret true; } +fn strange() -> bool { let _x: bool = return true; } fn funny() { fn f(_x: ()) { } - f(ret); + f(return); } fn what() { - fn the(x: @mut bool) { ret while !*x { *x = true; }; } + fn the(x: @mut bool) { return while !*x { *x = true; }; } let i = @mut false; let dont = {||the(i)}; dont(); @@ -17,23 +17,23 @@ fn what() { fn zombiejesus() { loop { - while (ret) { - if (ret) { - alt (ret) { + while (return) { + if (return) { + alt (return) { 1 { - if (ret) { - ret + if (return) { + return } else { - ret + return } } - _ { ret } + _ { return } }; - } else if (ret) { - ret; + } else if (return) { + return; } } - if (ret) { break; } + if (return) { break; } } } @@ -46,14 +46,14 @@ fn notsure() { } fn hammertime() -> int { - let _x = log(debug, true == (ret 0)); + let _x = log(debug, true == (return 0)); } fn canttouchthis() -> uint { pure fn p() -> bool { true } let _a = (assert (true)) == (assert (p())); let _c = (assert (p())) == (); - let _b: bool = (log(debug, 0) == (ret 0u)); + let _b: bool = (log(debug, 0) == (return 0u)); } fn angrydome() { diff --git a/src/test/run-pass/while-prelude-drop.rs b/src/test/run-pass/while-prelude-drop.rs index dcc19b8ca20..6315a92ca2d 100644 --- a/src/test/run-pass/while-prelude-drop.rs +++ b/src/test/run-pass/while-prelude-drop.rs @@ -2,12 +2,12 @@ enum t { a, b(~str), } fn make(i: int) -> t { - if i > 10 { ret a; } + if i > 10 { return a; } let mut s = ~"hello"; // Ensure s is non-const. s += ~"there"; - ret b(s); + return b(s); } fn main() { diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs index 3ae9f1c1eba..8e05abe75f3 100644 --- a/src/test/run-pass/zip-same-length.rs +++ b/src/test/run-pass/zip-same-length.rs @@ -10,7 +10,7 @@ fn enum_chars(start: u8, end: u8) -> ~[char] { let mut i = start; let mut r = ~[]; while i <= end { vec::push(r, i as char); i += 1u as u8; } - ret r; + return r; } fn enum_uints(start: uint, end: uint) -> ~[uint] { @@ -18,7 +18,7 @@ fn enum_uints(start: uint, end: uint) -> ~[uint] { let mut i = start; let mut r = ~[]; while i <= end { vec::push(r, i); i += 1u; } - ret r; + return r; } fn main() { |
