From 3105bcfdc11030abf9855af7a693cbf904460813 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 29 Jan 2013 15:16:07 -0800 Subject: [PATCH] librustc: De-export driver. rs=deexport --- src/librustc/back/link.rs | 25 +++--- src/librustc/back/rpath.rs | 36 ++++---- src/librustc/driver/driver.rs | 101 ++++++++++----------- src/librustc/driver/mod.rs | 15 +--- src/librustc/driver/session.rs | 127 +++++++++++++------------- src/librustc/rustc.rc | 159 ++++++++++++++++----------------- 6 files changed, 221 insertions(+), 242 deletions(-) diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 03639b289e7a9..f5ae2628b0268 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -94,8 +94,6 @@ pub fn WriteOutputFile(sess: Session, } pub mod jit { - #[legacy_exports]; - use back::link::llvm_err; use lib::llvm::llvm; use lib::llvm::{ModuleRef, PassManagerRef, mk_target_data}; @@ -109,21 +107,20 @@ pub mod jit { #[nolink] #[abi = "rust-intrinsic"] - extern mod rusti { - #[legacy_exports]; - fn morestack_addr() -> *(); + pub extern mod rusti { + pub fn morestack_addr() -> *(); } - struct Closure { + pub struct Closure { code: *(), env: *(), } - fn exec(sess: Session, - pm: PassManagerRef, - m: ModuleRef, - opt: c_int, - stacks: bool) { + pub fn exec(sess: Session, + pm: PassManagerRef, + m: ModuleRef, + opt: c_int, + stacks: bool) { unsafe { let manager = llvm::LLVMRustPrepareJIT(rusti::morestack_addr()); @@ -174,8 +171,6 @@ pub mod jit { } mod write { - #[legacy_exports]; - use back::link::jit; use back::link::{ModuleRef, WriteOutputFile, output_type}; use back::link::{output_type_assembly, output_type_bitcode}; @@ -193,7 +188,7 @@ mod write { use core::str; use core::vec; - fn is_object_or_assembly_or_exe(ot: output_type) -> bool { + pub fn is_object_or_assembly_or_exe(ot: output_type) -> bool { if ot == output_type_assembly || ot == output_type_object || ot == output_type_exe { return true; @@ -201,7 +196,7 @@ mod write { return false; } - fn run_passes(sess: Session, llmod: ModuleRef, output: &Path) { + pub fn run_passes(sess: Session, llmod: ModuleRef, output: &Path) { unsafe { let opts = sess.opts; if sess.time_llvm_passes() { llvm::LLVMRustEnableTimePasses(); } diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 1896730285f53..9308b89a7b10d 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -208,8 +208,6 @@ fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { #[cfg(unix)] mod test { - #[legacy_exports]; - use core::prelude::*; use back::rpath::{get_absolute_rpath, get_install_prefix_rpath}; @@ -221,14 +219,14 @@ mod test { use core::str; #[test] - fn test_rpaths_to_flags() { + pub fn test_rpaths_to_flags() { let flags = rpaths_to_flags(~[Path("path1"), Path("path2")]); assert flags == ~[~"-Wl,-rpath,path1", ~"-Wl,-rpath,path2"]; } #[test] - fn test_prefix_rpath() { + pub fn test_prefix_rpath() { let res = get_install_prefix_rpath("triple"); let d = Path(env!("CFG_PREFIX")) .push_rel(&Path("lib/rustc/triple/lib")); @@ -239,13 +237,13 @@ mod test { } #[test] - fn test_prefix_rpath_abs() { + pub fn test_prefix_rpath_abs() { let res = get_install_prefix_rpath("triple"); assert res.is_absolute; } #[test] - fn test_minimize1() { + pub fn test_minimize1() { let res = minimize_rpaths([Path("rpath1"), Path("rpath2"), Path("rpath1")]); @@ -253,7 +251,7 @@ mod test { } #[test] - fn test_minimize2() { + pub fn test_minimize2() { let res = minimize_rpaths(~[Path("1a"), Path("2"), Path("2"), Path("1a"), Path("4a"),Path("1a"), Path("2"), Path("3"), Path("4a"), @@ -262,7 +260,7 @@ mod test { } #[test] - fn test_relative_to1() { + pub fn test_relative_to1() { let p1 = Path("/usr/bin/rustc"); let p2 = Path("/usr/lib/mylib"); let res = get_relative_to(&p1, &p2); @@ -270,7 +268,7 @@ mod test { } #[test] - fn test_relative_to2() { + pub fn test_relative_to2() { let p1 = Path("/usr/bin/rustc"); let p2 = Path("/usr/bin/../lib/mylib"); let res = get_relative_to(&p1, &p2); @@ -278,7 +276,7 @@ mod test { } #[test] - fn test_relative_to3() { + pub fn test_relative_to3() { let p1 = Path("/usr/bin/whatever/rustc"); let p2 = Path("/usr/lib/whatever/mylib"); let res = get_relative_to(&p1, &p2); @@ -286,7 +284,7 @@ mod test { } #[test] - fn test_relative_to4() { + pub fn test_relative_to4() { let p1 = Path("/usr/bin/whatever/../rustc"); let p2 = Path("/usr/lib/whatever/mylib"); let res = get_relative_to(&p1, &p2); @@ -294,7 +292,7 @@ mod test { } #[test] - fn test_relative_to5() { + pub fn test_relative_to5() { let p1 = Path("/usr/bin/whatever/../rustc"); let p2 = Path("/usr/lib/whatever/../mylib"); let res = get_relative_to(&p1, &p2); @@ -302,7 +300,7 @@ mod test { } #[test] - fn test_relative_to6() { + pub fn test_relative_to6() { let p1 = Path("/1"); let p2 = Path("/2/3"); let res = get_relative_to(&p1, &p2); @@ -310,7 +308,7 @@ mod test { } #[test] - fn test_relative_to7() { + pub fn test_relative_to7() { let p1 = Path("/1/2"); let p2 = Path("/3"); let res = get_relative_to(&p1, &p2); @@ -318,7 +316,7 @@ mod test { } #[test] - fn test_relative_to8() { + pub fn test_relative_to8() { let p1 = Path("/home/brian/Dev/rust/build/").push_rel( &Path("stage2/lib/rustc/i686-unknown-linux-gnu/lib/librustc.so")); let p2 = Path("/home/brian/Dev/rust/build/stage2/bin/..").push_rel( @@ -333,7 +331,7 @@ mod test { #[test] #[cfg(target_os = "linux")] #[cfg(target_os = "andorid")] - fn test_rpath_relative() { + pub fn test_rpath_relative() { let o = session::os_linux; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); @@ -342,7 +340,7 @@ mod test { #[test] #[cfg(target_os = "freebsd")] - fn test_rpath_relative() { + pub fn test_rpath_relative() { let o = session::os_freebsd; let res = get_rpath_relative_to_output(o, &Path("bin/rustc"), &Path("lib/libstd.so")); @@ -351,7 +349,7 @@ mod test { #[test] #[cfg(target_os = "macos")] - fn test_rpath_relative() { + pub fn test_rpath_relative() { // this is why refinements would be nice let o = session::os_macos; let res = get_rpath_relative_to_output(o, @@ -361,7 +359,7 @@ mod test { } #[test] - fn test_get_absolute_rpath() { + pub fn test_get_absolute_rpath() { let res = get_absolute_rpath(&Path("lib/libstd.so")); debug!("test_get_absolute_rpath: %s vs. %s", res.to_str(), diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 70cad499e4cb7..12281e0b9803f 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -46,7 +46,7 @@ use syntax::parse; use syntax::print::{pp, pprust}; use syntax; -enum pp_mode { +pub enum pp_mode { ppm_normal, ppm_expanded, ppm_typed, @@ -58,16 +58,16 @@ enum pp_mode { * The name used for source code that doesn't originate in a file * (e.g. source from stdin or a string) */ -fn anon_src() -> ~str { ~"" } +pub fn anon_src() -> ~str { ~"" } -fn source_name(input: input) -> ~str { +pub fn source_name(input: input) -> ~str { match input { file_input(ref ifile) => (*ifile).to_str(), str_input(_) => anon_src() } } -fn default_configuration(sess: Session, +argv0: ~str, input: input) -> +pub fn default_configuration(sess: Session, +argv0: ~str, input: input) -> ast::crate_cfg { let libc = match sess.targ_cfg.os { session::os_win32 => ~"msvcrt.dll", @@ -106,7 +106,8 @@ fn default_configuration(sess: Session, +argv0: ~str, input: input) -> mk(~"build_input", source_name(input))]; } -fn append_configuration(+cfg: ast::crate_cfg, +name: ~str) -> ast::crate_cfg { +pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str) + -> ast::crate_cfg { if attr::contains_name(cfg, name) { return cfg; } else { @@ -114,7 +115,7 @@ fn append_configuration(+cfg: ast::crate_cfg, +name: ~str) -> ast::crate_cfg { } } -fn build_configuration(sess: Session, +argv0: ~str, input: input) -> +pub fn build_configuration(sess: Session, +argv0: ~str, input: input) -> ast::crate_cfg { // Combine the configuration requested by the session (command line) with // some default and generated configuration items @@ -132,7 +133,7 @@ fn build_configuration(sess: Session, +argv0: ~str, input: input) -> } // Convert strings provided as --cfg [cfgspec] into a crate_cfg -fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg { +pub fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg { // FIXME (#2399): It would be nice to use the parser to parse all // varieties of meta_item here. At the moment we just support the // meta_word variant. @@ -143,14 +144,14 @@ fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg { return words; } -enum input { +pub enum input { /// Load source from file file_input(Path), /// The string is the source str_input(~str) } -fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input) +pub fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input) -> @ast::crate { match input { file_input(ref file) => { @@ -164,7 +165,7 @@ fn parse_input(sess: Session, +cfg: ast::crate_cfg, input: input) } } -fn time(do_it: bool, what: ~str, thunk: fn() -> T) -> T { +pub fn time(do_it: bool, what: ~str, thunk: fn() -> T) -> T { if !do_it { return thunk(); } let start = std::time::precise_time_s(); let rv = thunk(); @@ -174,7 +175,7 @@ fn time(do_it: bool, what: ~str, thunk: fn() -> T) -> T { move rv } -enum compile_upto { +pub enum compile_upto { cu_parse, cu_expand, cu_typeck, @@ -182,17 +183,17 @@ enum compile_upto { cu_everything, } -impl compile_upto : cmp::Eq { +pub impl compile_upto : cmp::Eq { pure fn eq(&self, other: &compile_upto) -> bool { ((*self) as uint) == ((*other) as uint) } pure fn ne(&self, other: &compile_upto) -> bool { !(*self).eq(other) } } -fn compile_upto(sess: Session, cfg: ast::crate_cfg, - input: input, upto: compile_upto, - outputs: Option) - -> {crate: @ast::crate, tcx: Option} { +pub fn compile_upto(sess: Session, cfg: ast::crate_cfg, + input: input, upto: compile_upto, + outputs: Option) + -> {crate: @ast::crate, tcx: Option} { let time_passes = sess.time_passes(); let mut crate = time(time_passes, ~"parsing", || parse_input(sess, copy cfg, input) ); @@ -337,8 +338,8 @@ fn compile_upto(sess: Session, cfg: ast::crate_cfg, return {crate: crate, tcx: None}; } -fn compile_input(sess: Session, +cfg: ast::crate_cfg, input: input, - outdir: &Option, output: &Option) { +pub fn compile_input(sess: Session, +cfg: ast::crate_cfg, input: input, + outdir: &Option, output: &Option) { let upto = if sess.opts.parse_only { cu_parse } else if sess.opts.no_trans { cu_no_trans } @@ -347,8 +348,8 @@ fn compile_input(sess: Session, +cfg: ast::crate_cfg, input: input, compile_upto(sess, cfg, input, upto, Some(outputs)); } -fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input, - ppm: pp_mode) { +pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input, + ppm: pp_mode) { fn ann_paren_for_expr(node: pprust::ann_node) { match node { pprust::node_expr(s, _) => pprust::popen(s), @@ -424,7 +425,7 @@ fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input, } } -fn get_os(triple: ~str) -> Option { +pub fn get_os(triple: ~str) -> Option { if str::contains(triple, ~"win32") || str::contains(triple, ~"mingw32") { Some(session::os_win32) @@ -439,7 +440,7 @@ fn get_os(triple: ~str) -> Option { } else { None } } -fn get_arch(triple: ~str) -> Option { +pub fn get_arch(triple: ~str) -> Option { if str::contains(triple, ~"i386") || str::contains(triple, ~"i486") || str::contains(triple, ~"i586") || @@ -454,8 +455,9 @@ fn get_arch(triple: ~str) -> Option { } else { None } } -fn build_target_config(sopts: @session::options, - demitter: diagnostic::emitter) -> @session::config { +pub fn build_target_config(sopts: @session::options, + demitter: diagnostic::emitter) + -> @session::config { let os = match get_os(sopts.target_triple) { Some(os) => os, None => early_error(demitter, ~"unknown operating system") @@ -481,7 +483,7 @@ fn build_target_config(sopts: @session::options, return target_cfg; } -fn host_triple() -> ~str { +pub fn host_triple() -> ~str { // Get the host triple out of the build environment. This ensures that our // idea of the host triple is the same as for the set of libraries we've // actually built. We can't just take LLVM's host triple because they @@ -498,9 +500,10 @@ fn host_triple() -> ~str { }; } -fn build_session_options(+binary: ~str, - matches: &getopts::Matches, - demitter: diagnostic::emitter) -> @session::options { +pub fn build_session_options(+binary: ~str, + matches: &getopts::Matches, + demitter: diagnostic::emitter) + -> @session::options { let crate_type = if opt_present(matches, ~"lib") { session::lib_crate } else if opt_present(matches, ~"bin") { @@ -637,8 +640,8 @@ fn build_session_options(+binary: ~str, return sopts; } -fn build_session(sopts: @session::options, - demitter: diagnostic::emitter) -> Session { +pub fn build_session(sopts: @session::options, + demitter: diagnostic::emitter) -> Session { let codemap = @codemap::CodeMap::new(); let diagnostic_handler = diagnostic::mk_handler(Some(demitter)); @@ -647,11 +650,11 @@ fn build_session(sopts: @session::options, build_session_(sopts, codemap, demitter, span_diagnostic_handler) } -fn build_session_(sopts: @session::options, - cm: @codemap::CodeMap, - demitter: diagnostic::emitter, - span_diagnostic_handler: diagnostic::span_handler) - -> Session { +pub fn build_session_(sopts: @session::options, + cm: @codemap::CodeMap, + demitter: diagnostic::emitter, + span_diagnostic_handler: diagnostic::span_handler) + -> Session { let target_cfg = build_target_config(sopts, demitter); let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, cm); @@ -675,7 +678,7 @@ fn build_session_(sopts: @session::options, lint_settings: lint_settings}) } -fn parse_pretty(sess: Session, &&name: ~str) -> pp_mode { +pub fn parse_pretty(sess: Session, &&name: ~str) -> pp_mode { match name { ~"normal" => ppm_normal, ~"expanded" => ppm_expanded, @@ -691,7 +694,7 @@ fn parse_pretty(sess: Session, &&name: ~str) -> pp_mode { } // rustc command line options -fn optgroups() -> ~[getopts::groups::OptGroup] { +pub fn optgroups() -> ~[getopts::groups::OptGroup] { ~[ optflag(~"", ~"bin", ~"Compile an executable crate (default)"), optflag(~"c", ~"", ~"Compile and assemble, but do not link"), @@ -755,13 +758,13 @@ fn optgroups() -> ~[getopts::groups::OptGroup] { ] } -type output_filenames = @{out_filename:Path, obj_filename:Path}; +pub type output_filenames = @{out_filename:Path, obj_filename:Path}; -fn build_output_filenames(input: input, - odir: &Option, - ofile: &Option, - sess: Session) - -> output_filenames { +pub fn build_output_filenames(input: input, + odir: &Option, + ofile: &Option, + sess: Session) + -> output_filenames { let obj_path; let out_path; let sopts = sess.opts; @@ -831,21 +834,19 @@ fn build_output_filenames(input: input, obj_filename: obj_path}; } -fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! { +pub fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! { emitter(None, msg, diagnostic::fatal); fail; } -fn list_metadata(sess: Session, path: &Path, out: io::Writer) { +pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) { metadata::loader::list_file_metadata( sess.parse_sess.interner, session::sess_os_to_meta_os(sess.targ_cfg.os), path, out); } #[cfg(test)] -mod test { - #[legacy_exports]; - +pub mod test { use core::prelude::*; use driver::driver::{build_configuration, build_session}; @@ -859,7 +860,7 @@ mod test { // When the user supplies --test we should implicitly supply --cfg test #[test] - fn test_switch_implies_cfg_test() { + pub fn test_switch_implies_cfg_test() { let matches = &match getopts(~[~"--test"], optgroups()) { Ok(copy m) => m, @@ -876,7 +877,7 @@ mod test { // When the user supplies --test and --cfg test, don't implicitly add // another --cfg test #[test] - fn test_switch_implies_cfg_test_unless_cfg_test() { + pub fn test_switch_implies_cfg_test_unless_cfg_test() { let matches = &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { Ok(copy m) => m, diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index 3e87f835fc3ff..2508e6d8aabc6 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -8,16 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[legacy_exports]; +pub use syntax::diagnostic; -use syntax::diagnostic; - -export diagnostic; - -export driver; -export session; - -#[legacy_exports] -mod driver; -#[legacy_exports] -mod session; +pub mod driver; +pub mod session; diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index e7c78cd48eeef..3b32952ba3175 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -29,27 +29,27 @@ use syntax::parse::parse_sess; use syntax::{ast, codemap}; use syntax; -enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, } +pub enum os { os_win32, os_macos, os_linux, os_android, os_freebsd, } -impl os : cmp::Eq { +pub impl os : cmp::Eq { pure fn eq(&self, other: &os) -> bool { ((*self) as uint) == ((*other) as uint) } pure fn ne(&self, other: &os) -> bool { !(*self).eq(other) } } -enum arch { arch_x86, arch_x86_64, arch_arm, } +pub enum arch { arch_x86, arch_x86_64, arch_arm, } -impl arch : cmp::Eq { +pub impl arch : cmp::Eq { pure fn eq(&self, other: &arch) -> bool { ((*self) as uint) == ((*other) as uint) } pure fn ne(&self, other: &arch) -> bool { !(*self).eq(other) } } -enum crate_type { bin_crate, lib_crate, unknown_crate, } +pub enum crate_type { bin_crate, lib_crate, unknown_crate, } -type config = +pub type config = {os: os, arch: arch, target_strs: target_strs::t, @@ -57,26 +57,26 @@ type config = uint_type: uint_ty, float_type: float_ty}; -const verbose: uint = 1 << 0; -const time_passes: uint = 1 << 1; -const count_llvm_insns: uint = 1 << 2; -const time_llvm_passes: uint = 1 << 3; -const trans_stats: uint = 1 << 4; -const no_asm_comments: uint = 1 << 5; -const no_verify: uint = 1 << 6; -const trace: uint = 1 << 7; -const coherence: uint = 1 << 8; -const borrowck_stats: uint = 1 << 9; -const borrowck_note_pure: uint = 1 << 10; -const borrowck_note_loan: uint = 1 << 11; -const no_landing_pads: uint = 1 << 12; -const debug_llvm: uint = 1 << 13; -const count_type_sizes: uint = 1 << 14; -const meta_stats: uint = 1 << 15; -const no_opt: uint = 1 << 16; -const no_monomorphic_collapse: uint = 1 << 17; - -fn debugging_opts_map() -> ~[(~str, ~str, uint)] { +pub const verbose: uint = 1 << 0; +pub const time_passes: uint = 1 << 1; +pub const count_llvm_insns: uint = 1 << 2; +pub const time_llvm_passes: uint = 1 << 3; +pub const trans_stats: uint = 1 << 4; +pub const no_asm_comments: uint = 1 << 5; +pub const no_verify: uint = 1 << 6; +pub const trace: uint = 1 << 7; +pub const coherence: uint = 1 << 8; +pub const borrowck_stats: uint = 1 << 9; +pub const borrowck_note_pure: uint = 1 << 10; +pub const borrowck_note_loan: uint = 1 << 11; +pub const no_landing_pads: uint = 1 << 12; +pub const debug_llvm: uint = 1 << 13; +pub const count_type_sizes: uint = 1 << 14; +pub const meta_stats: uint = 1 << 15; +pub const no_opt: uint = 1 << 16; +pub const no_monomorphic_collapse: uint = 1 << 17; + +pub fn debugging_opts_map() -> ~[(~str, ~str, uint)] { ~[(~"verbose", ~"in general, enable more debug printouts", verbose), (~"time-passes", ~"measure time of each rustc pass", time_passes), (~"count-llvm-insns", ~"count where LLVM \ @@ -105,21 +105,21 @@ fn debugging_opts_map() -> ~[(~str, ~str, uint)] { ] } -enum OptLevel { +pub enum OptLevel { No, // -O0 Less, // -O1 Default, // -O2 Aggressive // -O3 } -impl OptLevel : cmp::Eq { +pub impl OptLevel : cmp::Eq { pure fn eq(&self, other: &OptLevel) -> bool { ((*self) as uint) == ((*other) as uint) } pure fn ne(&self, other: &OptLevel) -> bool { !(*self).eq(other) } } -type options = +pub type options = // The crate config requested for the session, which may be combined // with additional crate configurations during the compile process {crate_type: crate_type, @@ -147,26 +147,26 @@ type options = debugging_opts: uint, }; -type crate_metadata = {name: ~str, data: ~[u8]}; - -type Session_ = {targ_cfg: @config, - opts: @options, - cstore: metadata::cstore::CStore, - parse_sess: parse_sess, - codemap: @codemap::CodeMap, - // For a library crate, this is always none - mut main_fn: Option<(node_id, codemap::span)>, - span_diagnostic: diagnostic::span_handler, - filesearch: filesearch::FileSearch, - mut building_library: bool, - working_dir: Path, - lint_settings: lint::lint_settings}; - -enum Session { +pub type crate_metadata = {name: ~str, data: ~[u8]}; + +pub type Session_ = {targ_cfg: @config, + opts: @options, + cstore: metadata::cstore::CStore, + parse_sess: parse_sess, + codemap: @codemap::CodeMap, + // For a library crate, this is always none + mut main_fn: Option<(node_id, codemap::span)>, + span_diagnostic: diagnostic::span_handler, + filesearch: filesearch::FileSearch, + mut building_library: bool, + working_dir: Path, + lint_settings: lint::lint_settings}; + +pub enum Session { Session_(@Session_) } -impl Session { +pub impl Session { fn span_fatal(sp: span, msg: ~str) -> ! { self.span_diagnostic.span_fatal(sp, msg) } @@ -271,7 +271,7 @@ impl Session { } /// Some reasonable defaults -fn basic_options() -> @options { +pub fn basic_options() -> @options { @{ crate_type: session::lib_crate, static: false, @@ -296,12 +296,15 @@ fn basic_options() -> @options { } // Seems out of place, but it uses session, so I'm putting it here -fn expect(sess: Session, opt: Option, msg: fn() -> ~str) -> T { +pub fn expect(sess: Session, + opt: Option, + msg: fn() -> ~str) + -> T { diagnostic::expect(sess.diagnostic(), opt, msg) } -fn building_library(req_crate_type: crate_type, crate: @ast::crate, - testing: bool) -> bool { +pub fn building_library(req_crate_type: crate_type, crate: @ast::crate, + testing: bool) -> bool { match req_crate_type { bin_crate => false, lib_crate => true, @@ -320,7 +323,7 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate, } } -fn sess_os_to_meta_os(os: os) -> metadata::loader::os { +pub fn sess_os_to_meta_os(os: os) -> metadata::loader::os { use metadata::loader; match os { @@ -333,9 +336,7 @@ fn sess_os_to_meta_os(os: os) -> metadata::loader::os { } #[cfg(test)] -mod test { - #[legacy_exports]; - +pub mod test { use core::prelude::*; use driver::session::{bin_crate, building_library, lib_crate}; @@ -344,7 +345,7 @@ mod test { use syntax::ast; use syntax::ast_util; - fn make_crate_type_attr(+t: ~str) -> ast::attribute { + pub fn make_crate_type_attr(+t: ~str) -> ast::attribute { ast_util::respan(ast_util::dummy_sp(), ast::attribute_ { style: ast::attr_outer, value: ast_util::respan(ast_util::dummy_sp(), @@ -356,7 +357,7 @@ mod test { }) } - fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { + pub fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate { let mut attrs = ~[]; if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; } if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; } @@ -368,43 +369,43 @@ mod test { } #[test] - fn bin_crate_type_attr_results_in_bin_output() { + pub fn bin_crate_type_attr_results_in_bin_output() { let crate = make_crate(true, false); assert !building_library(unknown_crate, crate, false); } #[test] - fn lib_crate_type_attr_results_in_lib_output() { + pub fn lib_crate_type_attr_results_in_lib_output() { let crate = make_crate(false, true); assert building_library(unknown_crate, crate, false); } #[test] - fn bin_option_overrides_lib_crate_type() { + pub fn bin_option_overrides_lib_crate_type() { let crate = make_crate(false, true); assert !building_library(bin_crate, crate, false); } #[test] - fn lib_option_overrides_bin_crate_type() { + pub fn lib_option_overrides_bin_crate_type() { let crate = make_crate(true, false); assert building_library(lib_crate, crate, false); } #[test] - fn bin_crate_type_is_default() { + pub fn bin_crate_type_is_default() { let crate = make_crate(false, false); assert !building_library(unknown_crate, crate, false); } #[test] - fn test_option_overrides_lib_crate_type() { + pub fn test_option_overrides_lib_crate_type() { let crate = make_crate(false, true); assert !building_library(unknown_crate, crate, true); } #[test] - fn test_option_does_not_override_requested_lib_type() { + pub fn test_option_does_not_override_requested_lib_type() { let crate = make_crate(false, false); assert building_library(lib_crate, crate, true); } diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 059ada8b46efc..fcb0416858495 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -19,7 +19,6 @@ #[crate_type = "lib"]; #[legacy_modes]; -#[legacy_exports]; #[legacy_records]; #[allow(non_implicitly_copyable_typarams)]; @@ -49,153 +48,147 @@ use driver_ = driver; use middle_ = middle; use back_ = back; -mod middle { - #[legacy_exports]; - mod trans { - #[legacy_exports]; +pub mod middle { + pub mod trans { #[legacy_exports] - mod inline; + pub mod inline; #[legacy_exports] - mod monomorphize; + pub mod monomorphize; #[legacy_exports] - mod controlflow; + pub mod controlflow; #[legacy_exports] - mod glue; + pub mod glue; #[legacy_exports] - mod datum; + pub mod datum; #[legacy_exports] - mod callee; + pub mod callee; #[legacy_exports] - mod expr; + pub mod expr; #[legacy_exports] - mod common; + pub mod common; #[legacy_exports] - mod consts; + pub mod consts; #[legacy_exports] - mod type_of; + pub mod type_of; #[legacy_exports] - mod build; + pub mod build; #[legacy_exports] - mod base; + pub mod base; #[legacy_exports] - mod _match; + pub mod _match; #[legacy_exports] - mod uniq; + pub mod uniq; #[legacy_exports] - mod closure; + pub mod closure; #[legacy_exports] - mod tvec; + pub mod tvec; #[legacy_exports] - mod meth; + pub mod meth; #[legacy_exports] - mod cabi; + pub mod cabi; #[legacy_exports] - mod cabi_x86_64; + pub mod cabi_x86_64; #[legacy_exports] - mod foreign; + pub mod foreign; #[legacy_exports] - mod reflect; + pub mod reflect; #[legacy_exports] - mod shape; + pub mod shape; #[legacy_exports] - mod debuginfo; + pub mod debuginfo; #[legacy_exports] - mod type_use; + pub mod type_use; #[legacy_exports] - mod reachable; - mod machine; + pub mod reachable; + pub mod machine; } #[legacy_exports] - mod ty; + pub mod ty; #[legacy_exports] - mod resolve; + pub mod resolve; #[path = "typeck/mod.rs"] pub mod typeck; #[legacy_exports] - mod check_loop; + pub mod check_loop; #[legacy_exports] - mod check_match; + pub mod check_match; #[legacy_exports] - mod check_const; + pub mod check_const; #[legacy_exports] - mod lint; + pub mod lint; #[path = "borrowck/mod.rs"] pub mod borrowck; #[legacy_exports] - mod mem_categorization; + pub mod mem_categorization; #[legacy_exports] - mod liveness; + pub mod liveness; #[legacy_exports] - mod kind; + pub mod kind; #[legacy_exports] - mod freevars; + pub mod freevars; #[legacy_exports] - mod capture; + pub mod capture; #[legacy_exports] - mod pat_util; + pub mod pat_util; #[legacy_exports] - mod region; + pub mod region; #[legacy_exports] - mod const_eval; + pub mod const_eval; #[legacy_exports] - mod astencode; + pub mod astencode; #[legacy_exports] - mod lang_items; + pub mod lang_items; #[legacy_exports] - mod privacy; - mod mode; + pub mod privacy; + pub mod mode; } -mod front { - #[legacy_exports]; +pub mod front { #[legacy_exports] - mod config; + pub mod config; #[legacy_exports] - mod test; + pub mod test; #[legacy_exports] - mod core_inject; + pub mod core_inject; #[legacy_exports] - mod intrinsic_inject; + pub mod intrinsic_inject; } -mod back { - #[legacy_exports]; +pub mod back { #[legacy_exports] - mod link; + pub mod link; #[legacy_exports] - mod abi; + pub mod abi; #[legacy_exports] - mod upcall; + pub mod upcall; #[legacy_exports] - mod arm; + pub mod arm; #[legacy_exports] - mod x86; + pub mod x86; #[legacy_exports] - mod x86_64; + pub mod x86_64; #[legacy_exports] - mod rpath; + pub mod rpath; #[legacy_exports] - mod target_strs; + pub mod target_strs; } #[path = "metadata/mod.rs"] -mod metadata; +pub mod metadata; #[path = "driver/mod.rs"] -mod driver; +pub mod driver; -mod util { - #[legacy_exports]; +pub mod util { #[legacy_exports] - mod common; + pub mod common; #[legacy_exports] - mod ppaux; + pub mod ppaux; } -mod lib { - #[legacy_exports]; +pub mod lib { #[legacy_exports] - mod llvm; + pub mod llvm; } use result::{Ok, Err}; @@ -214,7 +207,7 @@ use driver::driver::{host_triple, optgroups, early_error, use driver::session; use middle::lint; -fn version(argv0: &str) { +pub fn version(argv0: &str) { let mut vers = ~"unknown version"; let env_vers = env!("CFG_VERSION"); if env_vers.len() != 0 { vers = env_vers; } @@ -222,7 +215,7 @@ fn version(argv0: &str) { io::println(fmt!("host: %s", host_triple())); } -fn usage(argv0: &str) { +pub fn usage(argv0: &str) { let message = fmt!("Usage: %s [OPTIONS] INPUT", argv0); io::println(groups::usage(message, optgroups()) + ~"Additional help: @@ -231,7 +224,7 @@ fn usage(argv0: &str) { "); } -fn describe_warnings() { +pub fn describe_warnings() { io::println(fmt!(" Available lint options: -W Warn about @@ -266,7 +259,7 @@ Available lint options: io::println(~""); } -fn describe_debug_flags() { +pub fn describe_debug_flags() { io::println(fmt!("\nAvailable debug options:\n")); for session::debugging_opts_map().each |pair| { let (name, desc, _) = /*bad*/copy *pair; @@ -274,7 +267,7 @@ fn describe_debug_flags() { } } -fn run_compiler(args: &~[~str], demitter: diagnostic::emitter) { +pub fn run_compiler(args: &~[~str], demitter: diagnostic::emitter) { // Don't display log spew by default. Can override with RUST_LOG. logging::console_off(); @@ -361,12 +354,12 @@ fn run_compiler(args: &~[~str], demitter: diagnostic::emitter) { compile_input(sess, cfg, input, &odir, &ofile); } -enum monitor_msg { +pub enum monitor_msg { fatal, done, } -impl monitor_msg : cmp::Eq { +pub impl monitor_msg : cmp::Eq { pure fn eq(&self, other: &monitor_msg) -> bool { ((*self) as uint) == ((*other) as uint) } @@ -385,7 +378,7 @@ diagnostic emitter which records when we hit a fatal error. If the task fails without recording a fatal error then we've encountered a compiler bug and need to present an error. */ -fn monitor(+f: fn~(diagnostic::emitter)) { +pub fn monitor(+f: fn~(diagnostic::emitter)) { let p = oldcomm::Port(); let ch = oldcomm::Chan(&p); @@ -435,7 +428,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { } } -fn main() { +pub fn main() { let mut args = os::args(); do monitor |move args, demitter| { run_compiler(&args, demitter);