diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 5b93c55ddc6..9d4becd63d3 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -12,16 +12,15 @@ use cmp; -enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, } - -impl mode : cmp::Eq { - pure fn eq(&self, other: &mode) -> bool { - (*other) as int == (*self) as int - } - pure fn ne(&self, other: &mode) -> bool { !(*self).eq(other) } +#[deriving_eq] +pub enum mode { + mode_compile_fail, + mode_run_fail, + mode_run_pass, + mode_pretty, } -type config = { +pub type config = { // The library paths required for running the compiler compile_lib_path: ~str, diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 8a868e14f08..4f9c86b70f0 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -11,7 +11,6 @@ #[crate_type = "bin"]; #[no_core]; -#[legacy_exports]; #[legacy_records]; #[allow(vecs_implicitly_copyable)]; @@ -24,17 +23,11 @@ extern mod std(vers = "0.6"); use core::*; -#[legacy_exports] mod procsrv; -#[legacy_exports] mod util; -#[legacy_exports] mod header; -#[legacy_exports] mod runtest; -#[legacy_exports] mod common; -#[legacy_exports] mod errors; use std::getopts; @@ -51,14 +44,14 @@ use common::mode_pretty; use common::mode; use util::logv; -fn main() { +pub fn main() { let args = os::args(); let config = parse_config(args); log_config(config); run_tests(config); } -fn parse_config(args: ~[~str]) -> config { +pub fn parse_config(args: ~[~str]) -> config { let opts = ~[getopts::reqopt(~"compile-lib-path"), getopts::reqopt(~"run-lib-path"), @@ -105,7 +98,7 @@ fn parse_config(args: ~[~str]) -> config { verbose: getopts::opt_present(matches, ~"verbose")}; } -fn log_config(config: config) { +pub fn log_config(config: config) { let c = config; logv(c, fmt!("configuration:")); logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path)); @@ -124,15 +117,15 @@ fn log_config(config: config) { logv(c, fmt!("\n")); } -fn opt_str(maybestr: Option<~str>) -> ~str { +pub fn opt_str(maybestr: Option<~str>) -> ~str { match maybestr { option::Some(s) => s, option::None => ~"(none)" } } -fn str_opt(maybestr: ~str) -> Option<~str> { +pub fn str_opt(maybestr: ~str) -> Option<~str> { if maybestr != ~"(none)" { option::Some(maybestr) } else { option::None } } -fn str_mode(s: ~str) -> mode { +pub fn str_mode(s: ~str) -> mode { match s { ~"compile-fail" => mode_compile_fail, ~"run-fail" => mode_run_fail, @@ -142,7 +135,7 @@ fn str_mode(s: ~str) -> mode { } } -fn mode_str(mode: mode) -> ~str { +pub fn mode_str(mode: mode) -> ~str { match mode { mode_compile_fail => ~"compile-fail", mode_run_fail => ~"run-fail", @@ -151,14 +144,14 @@ fn mode_str(mode: mode) -> ~str { } } -fn run_tests(config: config) { +pub fn run_tests(config: config) { let opts = test_opts(config); let tests = make_tests(config); let res = test::run_tests_console(&opts, tests); if !res { fail ~"Some tests failed"; } } -fn test_opts(config: config) -> test::TestOpts { +pub fn test_opts(config: config) -> test::TestOpts { test::TestOpts { filter: config.filter, run_ignored: config.run_ignored, @@ -166,7 +159,7 @@ fn test_opts(config: config) -> test::TestOpts { } } -fn make_tests(config: config) -> ~[test::TestDesc] { +pub fn make_tests(config: config) -> ~[test::TestDesc] { debug!("making tests from %s", config.src_base.to_str()); let mut tests = ~[]; @@ -180,7 +173,7 @@ fn make_tests(config: config) -> ~[test::TestDesc] { move tests } -fn is_test(config: config, testfile: &Path) -> bool { +pub fn is_test(config: config, testfile: &Path) -> bool { // Pretty-printer does not work with .rc files yet let valid_extensions = match config.mode { @@ -203,7 +196,7 @@ fn is_test(config: config, testfile: &Path) -> bool { return valid; } -fn make_test(config: config, testfile: &Path) -> +pub fn make_test(config: config, testfile: &Path) -> test::TestDesc { test::TestDesc { name: make_test_name(config, testfile), @@ -213,11 +206,11 @@ fn make_test(config: config, testfile: &Path) -> } } -fn make_test_name(config: config, testfile: &Path) -> ~str { +pub fn make_test_name(config: config, testfile: &Path) -> ~str { fmt!("[%s] %s", mode_str(config.mode), testfile.to_str()) } -fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { +pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { let testfile = testfile.to_str(); fn~() { runtest::run(config, testfile) } } diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index 2dc48118edd..d41a4b7360c 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -15,13 +15,10 @@ use io::ReaderUtil; use str; -export load_errors; -export ExpectedError; - -struct ExpectedError { line: uint, kind: ~str, msg: ~str } +pub struct ExpectedError { line: uint, kind: ~str, msg: ~str } // Load any test directives embedded in the file -fn load_errors(testfile: &Path) -> ~[ExpectedError] { +pub fn load_errors(testfile: &Path) -> ~[ExpectedError] { let mut error_patterns = ~[]; let rdr = io::file_reader(testfile).get(); let mut line_num = 1u; diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index db6677347cc..64192e523db 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -17,11 +17,7 @@ use os; use str; -export TestProps; -export load_props; -export is_test_ignored; - -struct TestProps { +pub struct TestProps { // Lines that should be expected, in order, on standard out error_patterns: ~[~str], // Extra flags to pass to the compiler @@ -36,7 +32,7 @@ struct TestProps { } // Load any test directives embedded in the file -fn load_props(testfile: &Path) -> TestProps { +pub fn load_props(testfile: &Path) -> TestProps { let mut error_patterns = ~[]; let mut aux_builds = ~[]; let mut exec_env = ~[]; @@ -73,7 +69,7 @@ fn load_props(testfile: &Path) -> TestProps { }; } -fn is_test_ignored(config: config, testfile: &Path) -> bool { +pub fn is_test_ignored(config: config, testfile: &Path) -> bool { let mut found = false; for iter_header(testfile) |ln| { if parse_name_directive(ln, ~"xfail-test") { return true; } diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 398820a5a63..8e575ca36f6 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -22,8 +22,6 @@ use task; use vec; -export run; - #[cfg(target_os = "win32")] fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] { @@ -54,12 +52,11 @@ fn target_env(_lib_path: ~str, _prog: ~str) -> ~[(~str,~str)] { struct Result {status: int, out: ~str, err: ~str} // FIXME (#2659): This code is duplicated in core::run::program_output -fn run(lib_path: ~str, - prog: ~str, - args: ~[~str], - env: ~[(~str, ~str)], - input: Option<~str>) -> Result { - +pub fn run(lib_path: ~str, + prog: ~str, + args: ~[~str], + env: ~[(~str, ~str)], + input: Option<~str>) -> Result { let pipe_in = os::pipe(); let pipe_out = os::pipe(); let pipe_err = os::pipe(); diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 5ccad97dce3..e9c37115c49 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -31,9 +31,7 @@ use util; use util::logv; -export run; - -fn run(config: config, testfile: ~str) { +pub fn run(config: config, testfile: ~str) { if config.verbose { // We're going to be dumping a lot of info. Start on a new line. io::stdout().write_str(~"\n\n"); diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index 13614c58855..e4028549f28 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -17,7 +17,7 @@ use common; use common::config; -fn make_new_path(path: ~str) -> ~str { +pub fn make_new_path(path: ~str) -> ~str { // Windows just uses PATH as the library search path, so we have to // maintain the current value while adding our own @@ -31,23 +31,23 @@ fn make_new_path(path: ~str) -> ~str { #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] -fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" } +pub fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" } #[cfg(target_os = "macos")] -fn lib_path_env_var() -> ~str { ~"DYLD_LIBRARY_PATH" } +pub fn lib_path_env_var() -> ~str { ~"DYLD_LIBRARY_PATH" } #[cfg(target_os = "win32")] -fn lib_path_env_var() -> ~str { ~"PATH" } +pub fn lib_path_env_var() -> ~str { ~"PATH" } #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] -fn path_div() -> ~str { ~":" } +pub fn path_div() -> ~str { ~":" } #[cfg(target_os = "win32")] -fn path_div() -> ~str { ~";" } +pub fn path_div() -> ~str { ~";" } -fn logv(config: config, s: ~str) { +pub fn logv(config: config, s: ~str) { log(debug, s); if config.verbose { io::println(s); } } diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index d6efcbc4642..8e1a916e2f1 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -37,14 +37,12 @@ stage2_tests.sort() c = open("tmp/run_pass_stage2.rc", "w") i = 0 c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n") -c.write("#[legacy_exports];\n") c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n") for t in stage2_tests: p = os.path.join(run_pass, t) p = p.replace("\\", "\\\\") c.write("#[path = \"%s\"]" % p); - c.write("#[legacy_exports]"); - c.write("mod t_%d;\n" % i) + c.write("pub mod t_%d;\n" % i) i += 1 c.close() diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index 64bf8ef05ba..f2a7c5c3cf4 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -26,7 +26,6 @@ #[crate_type = "lib"]; #[no_core]; -#[legacy_exports]; #[legacy_modes]; @@ -42,7 +41,6 @@ extern mod std(vers = "0.6"); extern mod rustc(vers = "0.6"); extern mod syntax(vers = "0.6"); -#[legacy_exports] mod pgp; use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest}; @@ -62,7 +60,7 @@ use syntax::diagnostic::span_handler; use syntax::diagnostic; use syntax::{ast, codemap, parse, visit, attr}; -struct Package { +pub struct Package { name: ~str, uuid: ~str, url: ~str, @@ -73,7 +71,7 @@ struct Package { versions: ~[(~str, ~str)] } -impl Package : cmp::Ord { +pub impl Package : cmp::Ord { pure fn lt(&self, other: &Package) -> bool { if (*self).name.lt(&(*other).name) { return true; } if (*other).name.lt(&(*self).name) { return false; } @@ -95,7 +93,7 @@ impl Package : cmp::Ord { pure fn gt(&self, other: &Package) -> bool { (*other).lt(&(*self)) } } -struct Source { +pub struct Source { name: ~str, mut url: ~str, mut method: ~str, @@ -104,7 +102,7 @@ struct Source { packages: DVec } -struct Cargo { +pub struct Cargo { pgp: bool, root: Path, installdir: Path, @@ -118,7 +116,7 @@ struct Cargo { opts: Options } -struct Crate { +pub struct Crate { name: ~str, vers: ~str, uuid: ~str, @@ -128,28 +126,22 @@ struct Crate { deps: ~[~str] } -struct Options { +pub struct Options { test: bool, mode: Mode, free: ~[~str], help: bool, } -enum Mode { SystemMode, UserMode, LocalMode } +#[deriving_eq] +pub enum Mode { SystemMode, UserMode, LocalMode } -impl Mode : cmp::Eq { - pure fn eq(&self, other: &Mode) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &Mode) -> bool { !(*self).eq(other) } -} - -fn opts() -> ~[getopts::Opt] { +pub fn opts() -> ~[getopts::Opt] { ~[optflag(~"g"), optflag(~"G"), optflag(~"test"), optflag(~"h"), optflag(~"help")] } -fn info(msg: ~str) { +pub fn info(msg: ~str) { let out = io::stdout(); if term::color_supported() { @@ -160,7 +152,7 @@ fn info(msg: ~str) { } else { out.write_line(~"info: " + msg); } } -fn warn(msg: ~str) { +pub fn warn(msg: ~str) { let out = io::stdout(); if term::color_supported() { @@ -171,7 +163,7 @@ fn warn(msg: ~str) { }else { out.write_line(~"warning: " + msg); } } -fn error(msg: ~str) { +pub fn error(msg: ~str) { let out = io::stdout(); if term::color_supported() { @@ -183,7 +175,7 @@ fn error(msg: ~str) { else { out.write_line(~"error: " + msg); } } -fn is_uuid(id: ~str) -> bool { +pub fn is_uuid(id: ~str) -> bool { let parts = str::split_str(id, ~"-"); if vec::len(parts) == 5u { let mut correct = 0u; @@ -225,7 +217,7 @@ fn is_uuid(id: ~str) -> bool { } #[test] -fn test_is_uuid() { +pub fn test_is_uuid() { assert is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaafAF09"); assert !is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaaaa"); assert !is_uuid(~""); @@ -238,7 +230,7 @@ fn test_is_uuid() { // FIXME (#2661): implement url/URL parsing so we don't have to resort // to weak checks -fn has_archive_extension(p: ~str) -> bool { +pub fn has_archive_extension(p: ~str) -> bool { str::ends_with(p, ~".tar") || str::ends_with(p, ~".tar.gz") || str::ends_with(p, ~".tar.bz2") || @@ -254,11 +246,11 @@ fn has_archive_extension(p: ~str) -> bool { str::ends_with(p, ~".txz") } -fn is_archive_path(u: ~str) -> bool { +pub fn is_archive_path(u: ~str) -> bool { has_archive_extension(u) && os::path_exists(&Path(u)) } -fn is_archive_url(u: ~str) -> bool { +pub fn is_archive_url(u: ~str) -> bool { // FIXME (#2661): this requires the protocol bit - if we had proper // url parsing, we wouldn't need it @@ -268,14 +260,14 @@ fn is_archive_url(u: ~str) -> bool { } } -fn is_git_url(url: ~str) -> bool { +pub fn is_git_url(url: ~str) -> bool { if str::ends_with(url, ~"/") { str::ends_with(url, ~".git/") } else { str::starts_with(url, ~"git://") || str::ends_with(url, ~".git") } } -fn assume_source_method(url: ~str) -> ~str { +pub fn assume_source_method(url: ~str) -> ~str { if is_git_url(url) { return ~"git"; } @@ -286,9 +278,9 @@ fn assume_source_method(url: ~str) -> ~str { ~"curl" } -fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, - Option<~str>, - Option<~str>) { +pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, + Option<~str>, + Option<~str>) { let mut name = None; let mut vers = None; let mut uuid = None; @@ -309,7 +301,7 @@ fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, (name, vers, uuid) } -fn load_crate(filename: &Path) -> Option { +pub fn load_crate(filename: &Path) -> Option { let sess = parse::new_parse_sess(None); let c = parse::parse_crate_from_file(filename, ~[], sess); @@ -428,11 +420,11 @@ fn load_crate(filename: &Path) -> Option { } } -fn print(s: ~str) { +pub fn print(s: ~str) { io::stdout().write_line(s); } -fn rest(s: ~str, start: uint) -> ~str { +pub fn rest(s: ~str, start: uint) -> ~str { if (start >= str::len(s)) { ~"" } else { @@ -440,14 +432,14 @@ fn rest(s: ~str, start: uint) -> ~str { } } -fn need_dir(s: &Path) { +pub fn need_dir(s: &Path) { if os::path_is_dir(s) { return; } if !os::make_dir(s, 493_i32 /* oct: 755 */) { fail fmt!("can't make_dir %s", s.to_str()); } } -fn valid_pkg_name(s: &str) -> bool { +pub fn valid_pkg_name(s: &str) -> bool { fn is_valid_digit(+c: char) -> bool { ('0' <= c && c <= '9') || ('a' <= c && c <= 'z') || @@ -459,7 +451,7 @@ fn valid_pkg_name(s: &str) -> bool { s.all(is_valid_digit) } -fn parse_source(name: ~str, j: &json::Json) -> @Source { +pub fn parse_source(name: ~str, j: &json::Json) -> @Source { if !valid_pkg_name(name) { fail fmt!("'%s' is an invalid source name", name); } @@ -497,7 +489,8 @@ fn parse_source(name: ~str, j: &json::Json) -> @Source { }; } -fn try_parse_sources(filename: &Path, sources: map::HashMap<~str, @Source>) { +pub fn try_parse_sources(filename: &Path, + sources: map::HashMap<~str, @Source>) { if !os::path_exists(filename) { return; } let c = io::read_whole_file_str(filename); match json::from_str(c.get()) { @@ -512,7 +505,7 @@ fn try_parse_sources(filename: &Path, sources: map::HashMap<~str, @Source>) { } } -fn load_one_source_package(src: @Source, p: &json::Object) { +pub fn load_one_source_package(src: @Source, p: &json::Object) { let name = match p.find(&~"name") { Some(&json::String(n)) => { if !valid_pkg_name(n) { @@ -614,7 +607,7 @@ fn load_one_source_package(src: @Source, p: &json::Object) { log(debug, ~" loaded package: " + src.name + ~"/" + name); } -fn load_source_info(c: &Cargo, src: @Source) { +pub fn load_source_info(c: &Cargo, src: @Source) { let dir = c.sourcedir.push(src.name); let srcfile = dir.push("source.json"); if !os::path_exists(&srcfile) { return; } @@ -635,7 +628,7 @@ fn load_source_info(c: &Cargo, src: @Source) { } }; } -fn load_source_packages(c: &Cargo, src: @Source) { +pub fn load_source_packages(c: &Cargo, src: @Source) { log(debug, ~"loading source: " + src.name); let dir = c.sourcedir.push(src.name); let pkgfile = dir.push("packages.json"); @@ -665,7 +658,7 @@ fn load_source_packages(c: &Cargo, src: @Source) { }; } -fn build_cargo_options(argv: ~[~str]) -> Options { +pub fn build_cargo_options(argv: ~[~str]) -> Options { let matches = &match getopts::getopts(argv, opts()) { result::Ok(m) => m, result::Err(f) => { @@ -696,7 +689,7 @@ fn build_cargo_options(argv: ~[~str]) -> Options { Options {test: test, mode: mode, free: matches.free, help: help} } -fn configure(opts: Options) -> Cargo { +pub fn configure(opts: Options) -> Cargo { let home = match get_cargo_root() { Ok(home) => home, Err(_err) => get_cargo_sysroot().get() @@ -754,7 +747,7 @@ fn configure(opts: Options) -> Cargo { move c } -fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { +pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { for c.sources.each_value |v| { for v.packages.each |p| { b(v, p); @@ -763,7 +756,7 @@ fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { } // Runs all programs in directory -fn run_programs(buildpath: &Path) { +pub fn run_programs(buildpath: &Path) { let newv = os::list_dir_path(buildpath); for newv.each |ct| { run::run_program(ct.to_str(), ~[]); @@ -772,8 +765,8 @@ fn run_programs(buildpath: &Path) { // Runs rustc in with the given flags // and returns -fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path, - extra_flags: ~[~str]) -> Option { +pub fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path, + extra_flags: ~[~str]) -> Option { let buildpath = path.push_rel(subdir); need_dir(&buildpath); debug!("%s: %s -> %s", what, cf.to_str(), buildpath.to_str()); @@ -788,7 +781,7 @@ fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path, Some(buildpath) } -fn test_one_crate(_c: &Cargo, path: &Path, cf: &Path) { +pub fn test_one_crate(_c: &Cargo, path: &Path, cf: &Path) { let buildpath = match run_in_buildpath(~"testing", path, &Path("test"), cf, @@ -799,7 +792,7 @@ fn test_one_crate(_c: &Cargo, path: &Path, cf: &Path) { run_programs(&buildpath); } -fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) { +pub fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) { let buildpath = match run_in_buildpath(~"installing", path, &Path("build"), cf, ~[]) { @@ -829,7 +822,7 @@ fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) { } -fn rustc_sysroot() -> ~str { +pub fn rustc_sysroot() -> ~str { match os::self_exe_path() { Some(path) => { let rustc = path.push_many([~"..", ~"bin", ~"rustc"]); @@ -840,7 +833,7 @@ fn rustc_sysroot() -> ~str { } } -fn install_source(c: &Cargo, path: &Path) { +pub fn install_source(c: &Cargo, path: &Path) { debug!("source: %s", path.to_str()); os::change_dir(path); @@ -879,7 +872,7 @@ fn install_source(c: &Cargo, path: &Path) { } } -fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) { +pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) { run::program_output(~"git", ~[~"clone", url, wd.to_str()]); if reference.is_some() { let r = reference.get(); @@ -890,7 +883,7 @@ fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) { install_source(c, wd); } -fn install_curl(c: &Cargo, wd: &Path, url: ~str) { +pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) { let tarpath = wd.push("pkg.tar"); let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", tarpath.to_str(), url]); @@ -903,14 +896,14 @@ fn install_curl(c: &Cargo, wd: &Path, url: ~str) { install_source(c, wd); } -fn install_file(c: &Cargo, wd: &Path, path: &Path) { +pub fn install_file(c: &Cargo, wd: &Path, path: &Path) { run::program_output(~"tar", ~[~"-x", ~"--strip-components=1", ~"-C", wd.to_str(), ~"-f", path.to_str()]); install_source(c, wd); } -fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) { +pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) { let url = copy pkg.url; let method = match pkg.method { ~"git" => ~"git", @@ -928,8 +921,7 @@ fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) { } } -fn cargo_suggestion(c: &Cargo, fallback: fn()) -{ +pub fn cargo_suggestion(c: &Cargo, fallback: fn()) { if c.sources.size() == 0u { error(~"no sources defined - you may wish to run " + ~"`cargo init`"); @@ -938,7 +930,7 @@ fn cargo_suggestion(c: &Cargo, fallback: fn()) fallback(); } -fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) { +pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) { let mut ps = ~[]; for_each_package(c, |s, p| { if p.uuid == uuid { @@ -962,7 +954,7 @@ fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) { } } -fn install_named(c: &Cargo, wd: &Path, name: ~str) { +pub fn install_named(c: &Cargo, wd: &Path, name: ~str) { let mut ps = ~[]; for_each_package(c, |s, p| { if p.name == name { @@ -986,7 +978,7 @@ fn install_named(c: &Cargo, wd: &Path, name: ~str) { } } -fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) { +pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) { match c.sources.find(src) { Some(s) => { for s.packages.each |p| { @@ -1001,7 +993,7 @@ fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) { error(~"can't find package: " + src + ~"/" + uuid); } -fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) { +pub fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) { match c.sources.find(src) { Some(s) => { for s.packages.each |p| { @@ -1016,7 +1008,7 @@ fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) { error(~"can't find package: " + src + ~"/" + name); } -fn cmd_uninstall(c: &Cargo) { +pub fn cmd_uninstall(c: &Cargo) { if vec::len(c.opts.free) < 3u { cmd_usage(); return; @@ -1068,7 +1060,7 @@ fn cmd_uninstall(c: &Cargo) { } } -fn install_query(c: &Cargo, wd: &Path, target: ~str) { +pub fn install_query(c: &Cargo, wd: &Path, target: ~str) { match c.dep_cache.find(target) { Some(inst) => { if inst { @@ -1128,7 +1120,7 @@ fn install_query(c: &Cargo, wd: &Path, target: ~str) { } } -fn get_temp_workdir(c: &Cargo) -> Path { +pub fn get_temp_workdir(c: &Cargo) -> Path { match tempfile::mkdtemp(&c.workdir, "cargo") { Some(wd) => wd, None => fail fmt!("needed temp dir: %s", @@ -1136,7 +1128,7 @@ fn get_temp_workdir(c: &Cargo) -> Path { } } -fn cmd_install(c: &Cargo) { +pub fn cmd_install(c: &Cargo) { unsafe { let wd = get_temp_workdir(c); @@ -1162,7 +1154,7 @@ fn cmd_install(c: &Cargo) { } } -fn sync(c: &Cargo) { +pub fn sync(c: &Cargo) { for c.sources.each_key |k| { let mut s = c.sources.get(k); sync_one(c, s); @@ -1170,7 +1162,7 @@ fn sync(c: &Cargo) { } } -fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool { +pub fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool { let name = src.name; let srcfile = dir.push("source.json.new"); let destsrcfile = dir.push("source.json"); @@ -1248,7 +1240,7 @@ fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool { return true; } -fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool { +pub fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool { let name = src.name; let srcfile = dir.push("source.json"); let pkgfile = dir.push("packages.json"); @@ -1351,7 +1343,7 @@ fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool { return true; } -fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool { +pub fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool { let name = src.name; let srcfile = dir.push("source.json.new"); let destsrcfile = dir.push("source.json"); @@ -1467,7 +1459,7 @@ fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool { return true; } -fn sync_one(c: &Cargo, src: @Source) { +pub fn sync_one(c: &Cargo, src: @Source) { let name = src.name; let dir = c.sourcedir.push(name); @@ -1487,7 +1479,7 @@ fn sync_one(c: &Cargo, src: @Source) { } } -fn cmd_init(c: &Cargo) { +pub fn cmd_init(c: &Cargo) { let srcurl = ~"http://www.rust-lang.org/cargo/sources.json"; let sigurl = ~"http://www.rust-lang.org/cargo/sources.json.sig"; @@ -1525,7 +1517,7 @@ fn cmd_init(c: &Cargo) { info(fmt!("initialized .cargo in %s", c.root.to_str())); } -fn print_pkg(s: @Source, p: &Package) { +pub fn print_pkg(s: @Source, p: &Package) { let mut m = s.name + ~"/" + p.name + ~" (" + p.uuid + ~")"; if vec::len(p.tags) > 0u { m = m + ~" [" + str::connect(p.tags, ~", ") + ~"]"; @@ -1536,7 +1528,7 @@ fn print_pkg(s: @Source, p: &Package) { } } -fn print_source(s: @Source) { +pub fn print_source(s: @Source) { info(s.name + ~" (" + s.url + ~")"); let pks = sort::merge_sort(s.packages.get(), sys::shape_lt); @@ -1557,7 +1549,7 @@ fn print_source(s: @Source) { })); } -fn cmd_list(c: &Cargo) { +pub fn cmd_list(c: &Cargo) { sync(c); if vec::len(c.opts.free) >= 3u { @@ -1583,7 +1575,7 @@ fn cmd_list(c: &Cargo) { } } -fn cmd_search(c: &Cargo) { +pub fn cmd_search(c: &Cargo) { if vec::len(c.opts.free) < 3u { cmd_usage(); return; @@ -1604,7 +1596,7 @@ fn cmd_search(c: &Cargo) { info(fmt!("found %d packages", n)); } -fn install_to_dir(srcfile: &Path, destdir: &Path) { +pub fn install_to_dir(srcfile: &Path, destdir: &Path) { let newfile = destdir.push(srcfile.filename().get()); let status = run::run_program(~"cp", ~[~"-r", srcfile.to_str(), @@ -1616,7 +1608,7 @@ fn install_to_dir(srcfile: &Path, destdir: &Path) { } } -fn dump_cache(c: &Cargo) { +pub fn dump_cache(c: &Cargo) { need_dir(&c.root); let out = c.root.push("cache.json"); @@ -1626,7 +1618,8 @@ fn dump_cache(c: &Cargo) { copy_warn(&out, &c.root.push("cache.json.old")); } } -fn dump_sources(c: &Cargo) { + +pub fn dump_sources(c: &Cargo) { if c.sources.size() < 1u { return; } @@ -1673,14 +1666,14 @@ fn dump_sources(c: &Cargo) { } } -fn copy_warn(srcfile: &Path, destfile: &Path) { +pub fn copy_warn(srcfile: &Path, destfile: &Path) { if !os::copy_file(srcfile, destfile) { warn(fmt!("copying %s to %s failed", srcfile.to_str(), destfile.to_str())); } } -fn cmd_sources(c: &Cargo) { +pub fn cmd_sources(c: &Cargo) { if vec::len(c.opts.free) < 3u { for c.sources.each_value |v| { info(fmt!("%s (%s) via %s", @@ -1845,7 +1838,7 @@ fn cmd_sources(c: &Cargo) { } } -fn cmd_usage() { +pub fn cmd_usage() { print(~"Usage: cargo [options] [args..] e.g. cargo install @@ -1860,14 +1853,14 @@ Options: "); } -fn cmd_usage_init() { +pub fn cmd_usage_init() { print(~"cargo init Re-initialize cargo in ~/.cargo. Clears all sources and then adds the default sources from ."); } -fn cmd_usage_install() { +pub fn cmd_usage_install() { print(~"cargo install cargo install [source/][@version] cargo install [source/][@version] @@ -1886,7 +1879,7 @@ the current working directory. If a source is provided, only install from that source, otherwise it installs from any source."); } -fn cmd_usage_uninstall() { +pub fn cmd_usage_uninstall() { print(~"cargo uninstall [source/][@version] cargo uninstall [source/][@version] cargo uninstall [@version] @@ -1903,7 +1896,7 @@ If a crate was installed directly (git, tarball, etc.), you can remove it by metadata."); } -fn cmd_usage_list() { +pub fn cmd_usage_list() { print(~"cargo list [sources..] If no arguments are provided, list all sources and their packages. @@ -1911,13 +1904,13 @@ If source names are provided, list those sources and their packages. "); } -fn cmd_usage_search() { +pub fn cmd_usage_search() { print(~"cargo search [tags..] Search packages."); } -fn cmd_usage_sources() { +pub fn cmd_usage_sources() { print(~"cargo sources cargo sources add cargo sources remove @@ -1936,7 +1929,7 @@ Commands: set-method Change the method for a source."); } -fn main() { +pub fn main() { let argv = os::args(); let o = build_cargo_options(argv); @@ -1987,3 +1980,4 @@ fn main() { dump_cache(c); dump_sources(c); } + diff --git a/src/libcargo/pgp.rs b/src/libcargo/pgp.rs index 9d90df334e5..7eee0f9b96b 100644 --- a/src/libcargo/pgp.rs +++ b/src/libcargo/pgp.rs @@ -12,11 +12,11 @@ use core::path::Path; use core::run; -fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } { +pub fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } { return run::program_output(~"gpgv", args); } -fn signing_key() -> ~str { +pub fn signing_key() -> ~str { ~" -----BEGIN PGP PUBLIC KEY BLOCK----- Version: SKS 1.1.0 @@ -68,16 +68,16 @@ fn signing_key() -> ~str { " } -fn signing_key_fp() -> ~str { +pub fn signing_key_fp() -> ~str { ~"FE79 EDB0 3DEF B0D8 27D2 6C41 0B2D 6A28 3033 6376" } -fn supported() -> bool { +pub fn supported() -> bool { let r = gpgv(~[~"--version"]); r.status == 0 } -fn init(root: &Path) { +pub fn init(root: &Path) { let p = root.push("gpg"); if !os::path_is_dir(&p) { os::make_dir(&p, 0x1c0i32); @@ -92,7 +92,7 @@ fn init(root: &Path) { } } -fn add(root: &Path, key: &Path) { +pub fn add(root: &Path, key: &Path) { let path = root.push("gpg"); let p = run::program_output(~"gpg", ~[~"--homedir", path.to_str(), @@ -102,7 +102,7 @@ fn add(root: &Path, key: &Path) { } } -fn verify(root: &Path, data: &Path, sig: &Path) -> bool { +pub fn verify(root: &Path, data: &Path, sig: &Path) -> bool { let path = root.push("gpg"); let res = gpgv(~[~"--homedir", path.to_str(), ~"--keyring", ~"pubring.gpg", diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 569a8df1a51..03b96e34e75 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -20,7 +20,6 @@ #[no_core]; #[legacy_modes]; -#[legacy_exports]; #[allow(vecs_implicitly_copyable)]; #[allow(non_camel_case_types)]; @@ -40,27 +39,22 @@ use syntax::parse; use syntax::print::pprust; use syntax::diagnostic; -enum test_mode { tm_converge, tm_run, } -struct Context { mode: test_mode } // + rng +#[deriving_eq] +pub enum test_mode { tm_converge, tm_run, } -impl test_mode : cmp::Eq { - pure fn eq(&self, other: &test_mode) -> bool { - ((*self) as uint) == ((*other) as uint) - } - pure fn ne(&self, other: &test_mode) -> bool { !(*self).eq(other) } -} +pub struct Context { mode: test_mode } // + rng -fn write_file(filename: &Path, content: ~str) { +pub fn write_file(filename: &Path, content: ~str) { result::get( &io::file_writer(filename, ~[io::Create, io::Truncate])) .write_str(content); } -fn contains(haystack: ~str, needle: ~str) -> bool { +pub fn contains(haystack: ~str, needle: ~str) -> bool { str::contains(haystack, needle) } -fn find_rust_files(files: &mut ~[Path], path: &Path) { +pub fn find_rust_files(files: &mut ~[Path], path: &Path) { if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") { // ignoring "utf8" tests because something is broken files.push(*path); @@ -74,7 +68,7 @@ fn find_rust_files(files: &mut ~[Path], path: &Path) { } -fn common_exprs() -> ~[ast::expr] { +pub fn common_exprs() -> ~[ast::expr] { fn dse(e: ast::expr_) -> ast::expr { ast::expr { id: 0, @@ -104,11 +98,11 @@ fn common_exprs() -> ~[ast::expr] { ] } -pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool { +pub pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool { safe_to_use_expr(*e, tm) } -pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool { +pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool { match tm { tm_converge => { match e.node { @@ -142,33 +136,37 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool { } } -fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool { +pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool { // Restrictions happen to be the same. safe_to_replace_ty(t.node, tm) } // Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED) -fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, - es: @mut ~[ast::expr], - e: @ast::expr, - tm: test_mode) { +pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, + es: @mut ~[ast::expr], + e: @ast::expr, + tm: test_mode) { if c(e, tm) { *es += ~[*e]; - } else {/* now my indices are wrong :( */ } + } else { + /* now my indices are wrong :( */ + } } -fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool, - es: @mut ~[ast::Ty], - e: @ast::Ty, - tm: test_mode) { +pub fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool, + es: @mut ~[ast::Ty], + e: @ast::Ty, + tm: test_mode) { if c(e, tm) { es.push(*e); - } else {/* now my indices are wrong :( */ } + } else { + /* now my indices are wrong :( */ + } } -struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]} +pub struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]} -fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff { +pub fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff { let exprs = @mut ~[]; let tys = @mut ~[]; let v = visit::mk_simple_visitor(@visit::SimpleVisitor { @@ -181,7 +179,7 @@ fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff { } -fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool { +pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool { match e { // https://github.com/mozilla/rust/issues/652 ast::expr_if(*) => { false } @@ -194,7 +192,7 @@ fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool { } } -fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool { +pub fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool { match t { ast::ty_infer => { false } // always implicit, always top level ast::ty_bot => { false } // in source, can only appear @@ -205,8 +203,8 @@ fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool { } // Replace the |i|th expr (in fold order) of |crate| with |newexpr|. -fn replace_expr_in_crate(crate: ast::crate, i: uint, - newexpr: ast::expr, tm: test_mode) -> +pub fn replace_expr_in_crate(crate: ast::crate, i: uint, + newexpr: ast::expr, tm: test_mode) -> ast::crate { let j: @mut uint = @mut 0u; fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_, @@ -233,8 +231,8 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint, // Replace the |i|th ty (in fold order) of |crate| with |newty|. -fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty, - tm: test_mode) -> ast::crate { +pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty, + tm: test_mode) -> ast::crate { let j: @mut uint = @mut 0u; fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_, original: ast::ty_, fld: fold::ast_fold, @@ -254,17 +252,17 @@ fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty, *crate2 } -fn under(n: uint, it: fn(uint)) { +pub fn under(n: uint, it: fn(uint)) { let mut i: uint = 0u; while i < n { it(i); i += 1u; } } -fn as_str(f: fn@(+x: io::Writer)) -> ~str { +pub fn as_str(f: fn@(+x: io::Writer)) -> ~str { io::with_str_writer(f) } -fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap, - filename: &Path, cx: Context) { +pub fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap, + filename: &Path, cx: Context) { let stolen = steal(crate, cx.mode); let extra_exprs = do common_exprs().filtered |a| { safe_to_use_expr(*a, cx.mode) @@ -276,7 +274,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap, pprust::ty_to_str, replace_ty_in_crate, cx); } -fn check_variants_T( +pub fn check_variants_T( crate: ast::crate, codemap: @codemap::CodeMap, filename: &Path, @@ -334,12 +332,12 @@ fn check_variants_T( } } -fn last_part(filename: ~str) -> ~str { +pub fn last_part(filename: ~str) -> ~str { let ix = option::get(str::rfind_char(filename, '/')); str::slice(filename, ix + 1u, str::len(filename) - 3u) } -enum happiness { +pub enum happiness { passed, cleanly_rejected(~str), known_bug(~str), @@ -351,8 +349,8 @@ enum happiness { // - that would be tricky, requiring use of tasks or serialization // or randomness. // This seems to find plenty of bugs as it is :) -fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path, - allow_running: bool) { +pub fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path, + allow_running: bool) { let filename = &suggested_filename_prefix.with_filetype("rs"); write_file(filename, code); @@ -376,19 +374,19 @@ fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path, } } -fn removeIfExists(filename: &Path) { +pub fn removeIfExists(filename: &Path) { // So sketchy! assert !contains(filename.to_str(), ~" "); run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]); } -fn removeDirIfExists(filename: &Path) { +pub fn removeDirIfExists(filename: &Path) { // So sketchy! assert !contains(filename.to_str(), ~" "); run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]); } -fn check_running(exe_filename: &Path) -> happiness { +pub fn check_running(exe_filename: &Path) -> happiness { let p = run::program_output( ~"/Users/jruderman/scripts/timed_run_rust_program.py", ~[exe_filename.to_str()]); @@ -427,7 +425,7 @@ fn check_running(exe_filename: &Path) -> happiness { } } -fn check_compiling(filename: &Path) -> happiness { +pub fn check_compiling(filename: &Path) -> happiness { let p = run::program_output( ~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\ stage1/bin/rustc", @@ -460,7 +458,7 @@ fn check_compiling(filename: &Path) -> happiness { } -fn parse_and_print(code: @~str) -> ~str { +pub fn parse_and_print(code: @~str) -> ~str { let filename = Path("tmp.rs"); let sess = parse::new_parse_sess(option::None); write_file(&filename, *code); @@ -481,7 +479,7 @@ fn parse_and_print(code: @~str) -> ~str { } } -fn has_raw_pointers(c: ast::crate) -> bool { +pub fn has_raw_pointers(c: ast::crate) -> bool { let has_rp = @mut false; fn visit_ty(flag: @mut bool, t: @ast::Ty) { match t.node { @@ -497,7 +495,7 @@ fn has_raw_pointers(c: ast::crate) -> bool { return *has_rp; } -fn content_is_dangerous_to_run(code: ~str) -> bool { +pub fn content_is_dangerous_to_run(code: ~str) -> bool { let dangerous_patterns = ~[~"xfail-test", ~"import", // espeically fs, run @@ -509,7 +507,7 @@ fn content_is_dangerous_to_run(code: ~str) -> bool { return false; } -fn content_is_dangerous_to_compile(code: ~str) -> bool { +pub fn content_is_dangerous_to_compile(code: ~str) -> bool { let dangerous_patterns = ~[~"xfail-test"]; @@ -517,7 +515,7 @@ fn content_is_dangerous_to_compile(code: ~str) -> bool { return false; } -fn content_might_not_converge(code: ~str) -> bool { +pub fn content_might_not_converge(code: ~str) -> bool { let confusing_patterns = ~[~"xfail-test", ~"xfail-pretty", @@ -533,7 +531,7 @@ fn content_might_not_converge(code: ~str) -> bool { return false; } -fn file_might_not_converge(filename: &Path) -> bool { +pub fn file_might_not_converge(filename: &Path) -> bool { let confusing_files = ~[ ~"expr-alt.rs", // pretty-printing "(a = b) = c" // vs "a = b = c" and wrapping @@ -552,7 +550,7 @@ fn file_might_not_converge(filename: &Path) -> bool { return false; } -fn check_roundtrip_convergence(code: @~str, maxIters: uint) { +pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) { let mut i = 0u; let mut newv = code; @@ -579,7 +577,7 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) { } } -fn check_convergence(files: &[Path]) { +pub fn check_convergence(files: &[Path]) { error!("pp convergence tests: %u files", vec::len(files)); for files.each |file| { if !file_might_not_converge(file) { @@ -594,7 +592,7 @@ fn check_convergence(files: &[Path]) { } } -fn check_variants(files: &[Path], cx: Context) { +pub fn check_variants(files: &[Path], cx: Context) { for files.each |file| { if cx.mode == tm_converge && file_might_not_converge(file) { @@ -639,7 +637,7 @@ fn check_variants(files: &[Path], cx: Context) { } } -fn main() { +pub fn main() { let args = os::args(); if vec::len(args) != 2u { error!("usage: %s ", args[0]); diff --git a/src/librustdoc/demo.rs b/src/librustdoc/demo.rs index bb8f37dc7ad..4a046aaf503 100644 --- a/src/librustdoc/demo.rs +++ b/src/librustdoc/demo.rs @@ -75,7 +75,6 @@ fn take_my_order_please( } mod fortress_of_solitude { - #[legacy_exports]; /*! * Superman's vacation home * @@ -90,7 +89,6 @@ mod fortress_of_solitude { } mod blade_runner { - #[legacy_exports]; /*! * Blade Runner is probably the best movie ever * diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index d73d7b2c279..b652c8d8eb4 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -343,8 +343,6 @@ fn should_extract_struct_fields() { #[cfg(test)] mod test { - #[legacy_exports]; - use astsrv; use doc; use extract::{extract, from_srv}; @@ -352,20 +350,20 @@ mod test { use core::vec; - fn mk_doc(+source: ~str) -> doc::Doc { + pub fn mk_doc(+source: ~str) -> doc::Doc { let ast = parse::from_str(source); extract(ast, ~"") } #[test] - fn extract_empty_crate() { + pub fn extract_empty_crate() { let doc = mk_doc(~""); assert vec::is_empty(doc.cratemod().mods()); assert vec::is_empty(doc.cratemod().fns()); } #[test] - fn extract_mods() { + pub fn extract_mods() { let doc = mk_doc(~"mod a { mod b { } mod c { } }"); assert doc.cratemod().mods()[0].name() == ~"a"; assert doc.cratemod().mods()[0].mods()[0].name() == ~"b"; @@ -373,47 +371,47 @@ fn extract_mods() { } #[test] - fn extract_foreign_mods() { + pub fn extract_foreign_mods() { let doc = mk_doc(~"extern mod a { }"); assert doc.cratemod().nmods()[0].name() == ~"a"; } #[test] - fn extract_fns_from_foreign_mods() { + pub fn extract_fns_from_foreign_mods() { let doc = mk_doc(~"extern mod a { fn a(); }"); assert doc.cratemod().nmods()[0].fns[0].name() == ~"a"; } #[test] - fn extract_mods_deep() { + pub fn extract_mods_deep() { let doc = mk_doc(~"mod a { mod b { mod c { } } }"); assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c"; } #[test] - fn extract_should_set_mod_ast_id() { + pub fn extract_should_set_mod_ast_id() { let doc = mk_doc(~"mod a { }"); assert doc.cratemod().mods()[0].id() != 0; } #[test] - fn extract_fns() { + pub fn extract_fns() { let doc = mk_doc( ~"fn a() { } \ mod b { - #[legacy_exports]; fn c() { } }"); + } }"); assert doc.cratemod().fns()[0].name() == ~"a"; assert doc.cratemod().mods()[0].fns()[0].name() == ~"c"; } #[test] - fn extract_should_set_fn_ast_id() { + pub fn extract_should_set_fn_ast_id() { let doc = mk_doc(~"fn a() { }"); assert doc.cratemod().fns()[0].id() != 0; } #[test] - fn extract_should_use_default_crate_name() { + pub fn extract_should_use_default_crate_name() { let source = ~""; let ast = parse::from_str(source); let doc = extract(ast, ~"burp"); @@ -421,7 +419,7 @@ fn extract_should_use_default_crate_name() { } #[test] - fn extract_from_seq_srv() { + pub fn extract_from_seq_srv() { let source = ~""; do astsrv::from_str(source) |srv| { let doc = from_srv(srv, ~"name"); diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index f0e840dfdce..b908187953f 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -96,7 +96,7 @@ fn should_write_modules_last() { ~"mod a { }\ fn b() { }\ mod c { - #[legacy_exports]; }\ + }\ fn d() { }" ); @@ -371,7 +371,7 @@ fn should_write_sections() { # Header\n\ Body\"]\ mod a { - #[legacy_exports]; }"); + }"); assert str::contains(markdown, ~"#### Header\n\nBody\n\n"); } @@ -832,8 +832,6 @@ fn should_write_struct_header() { #[cfg(test)] mod test { - #[legacy_exports]; - use astsrv; use attr_pass; use config; @@ -853,14 +851,14 @@ mod test { use core::path::Path; use core::str; - fn render(+source: ~str) -> ~str { + pub fn render(+source: ~str) -> ~str { let (srv, doc) = create_doc_srv(source); let markdown = write_markdown_str_srv(srv, doc); debug!("markdown: %s", markdown); markdown } - fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) { + pub fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) { do astsrv::from_str(source) |srv| { let config = config::Config { @@ -890,12 +888,12 @@ fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) { } } - fn create_doc(+source: ~str) -> doc::Doc { + pub fn create_doc(+source: ~str) -> doc::Doc { let (_, doc) = create_doc_srv(source); doc } - fn write_markdown_str( + pub fn write_markdown_str( +doc: doc::Doc ) -> ~str { let (writer_factory, po) = markdown_writer::future_writer_factory(); @@ -903,7 +901,7 @@ fn write_markdown_str( return oldcomm::recv(po).second(); } - fn write_markdown_str_srv( + pub fn write_markdown_str_srv( srv: astsrv::Srv, +doc: doc::Doc ) -> ~str { @@ -914,13 +912,13 @@ fn write_markdown_str_srv( } #[test] - fn write_markdown_should_write_mod_headers() { + pub fn write_markdown_should_write_mod_headers() { let markdown = render(~"mod moo { }"); assert str::contains(markdown, ~"# Module `moo`"); } #[test] - fn should_leave_blank_line_after_header() { + pub fn should_leave_blank_line_after_header() { let markdown = render(~"mod morp { }"); assert str::contains(markdown, ~"Module `morp`\n\n"); } diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index ab6da1cf403..b1bc0ee9b28 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -272,14 +272,12 @@ fn should_name_mod_file_names_by_path() { #[cfg(test)] mod test { - #[legacy_exports]; - use astsrv; use doc; use extract; use path_pass; - fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc { + pub fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { let doc = extract::from_srv(srv, name); let doc = (path_pass::mk_pass().f)(srv, doc); diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index be0c1d3aaaf..4d6cb29f68d 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -10,8 +10,6 @@ //! Prune things that are private -#[legacy_exports]; - use core::prelude::*; use astsrv; @@ -24,10 +22,7 @@ use core::vec; use syntax::ast; -export mk_pass; -export run; - -fn mk_pass() -> Pass { +pub fn mk_pass() -> Pass { Pass { name: ~"prune_private", f: run diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index 706aecf49b9..7e7363802ed 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -171,7 +171,7 @@ fn should_create_section_headers() { # Header\n\ Body\"]\ mod a { - #[legacy_exports]; }"); + }"); assert str::contains( doc.cratemod().mods()[0].item.sections[0].header, ~"Header"); @@ -184,7 +184,7 @@ fn should_create_section_bodies() { # Header\n\ Body\"]\ mod a { - #[legacy_exports]; }"); + }"); assert str::contains( doc.cratemod().mods()[0].item.sections[0].body, ~"Body"); @@ -197,7 +197,7 @@ fn should_not_create_sections_from_indented_headers() { Text\n # Header\n\ Body\"]\ mod a { - #[legacy_exports]; }"); + }"); assert vec::is_empty(doc.cratemod().mods()[0].item.sections); } @@ -209,7 +209,7 @@ fn should_remove_section_text_from_main_desc() { # Header\n\ Body\"]\ mod a { - #[legacy_exports]; }"); + }"); assert !str::contains( doc.cratemod().mods()[0].desc().get(), ~"Header"); @@ -225,7 +225,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() { # Header\n\ Body\"]\ mod a { - #[legacy_exports]; }"); + }"); assert doc.cratemod().mods()[0].desc() == None; } diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs index 332c2082e4b..ad737567d01 100644 --- a/src/librustdoc/sort_item_type_pass.rs +++ b/src/librustdoc/sort_item_type_pass.rs @@ -46,7 +46,7 @@ fn test() { let source = ~"mod imod { } \ extern mod inmod { - #[legacy_exports]; } \ + } \ const iconst: int = 0; \ fn ifn() { } \ enum ienum { ivar } \ diff --git a/src/librustdoc/trim_pass.rs b/src/librustdoc/trim_pass.rs index 4ac8b51a6bc..76a10dba33c 100644 --- a/src/librustdoc/trim_pass.rs +++ b/src/librustdoc/trim_pass.rs @@ -31,7 +31,7 @@ pub fn mk_pass() -> Pass { fn should_trim_text() { let doc = test::mk_doc(~"#[doc = \" desc \"] \ mod m { - #[legacy_exports]; }"); + }"); assert doc.cratemod().mods()[0].desc() == Some(~"desc"); }