Remove unused automatic cfg bindings Fixes #7169

This commit is contained in:
Nick Desaulniers 2013-08-13 17:06:27 -07:00
parent 0d817ee869
commit 0932ab336f
6 changed files with 27 additions and 32 deletions

View File

@ -65,14 +65,14 @@ pub fn source_name(input: &input) -> @str {
}
}
pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
pub fn default_configuration(sess: Session) ->
ast::CrateConfig {
let (libc, tos) = match sess.targ_cfg.os {
session::os_win32 => (@"msvcrt.dll", @"win32"),
session::os_macos => (@"libc.dylib", @"macos"),
session::os_linux => (@"libc.so.6", @"linux"),
session::os_android => (@"libc.so", @"android"),
session::os_freebsd => (@"libc.so.7", @"freebsd")
let tos = match sess.targ_cfg.os {
session::os_win32 => @"win32",
session::os_macos => @"macos",
session::os_linux => @"linux",
session::os_android => @"android",
session::os_freebsd => @"freebsd"
};
// ARM is bi-endian, however using NDK seems to default
@ -92,10 +92,7 @@ pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
mk(@"target_arch", arch),
mk(@"target_endian", end),
mk(@"target_word_size", wordsz),
mk(@"target_libc", libc),
// Build bindings.
mk(@"build_compiler", argv0),
mk(@"build_input", source_name(input))];
];
}
pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
@ -104,11 +101,11 @@ pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
}
}
pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
pub fn build_configuration(sess: Session) ->
ast::CrateConfig {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items
let default_cfg = default_configuration(sess, argv0, input);
let default_cfg = default_configuration(sess);
let mut user_cfg = sess.opts.cfg.clone();
// If the user wants a test runner, then add the test cfg
if sess.opts.test { append_configuration(&mut user_cfg, @"test") }
@ -980,7 +977,7 @@ pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) {
mod test {
use driver::driver::{build_configuration, build_session};
use driver::driver::{build_session_options, optgroups, str_input};
use driver::driver::{build_session_options, optgroups};
use extra::getopts::groups::getopts;
use extra::getopts;
@ -998,7 +995,7 @@ fn test_switch_implies_cfg_test() {
let sessopts = build_session_options(
@"rustc", matches, diagnostic::emit);
let sess = build_session(sessopts, diagnostic::emit);
let cfg = build_configuration(sess, @"whatever", &str_input(@""));
let cfg = build_configuration(sess);
assert!((attr::contains_name(cfg, "test")));
}
@ -1016,7 +1013,7 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
let sessopts = build_session_options(
@"rustc", matches, diagnostic::emit);
let sess = build_session(sessopts, diagnostic::emit);
let cfg = build_configuration(sess, @"whatever", &str_input(@""));
let cfg = build_configuration(sess);
let mut test_items = cfg.iter().filter(|m| "test" == m.name());
assert!(test_items.next().is_some());
assert!(test_items.next().is_none());

View File

@ -252,7 +252,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
let sess = build_session(sopts, demitter);
let odir = getopts::opt_maybe_str(matches, "out-dir").map_move(|o| Path(o));
let ofile = getopts::opt_maybe_str(matches, "o").map_move(|o| Path(o));
let cfg = build_configuration(sess, binary, &input);
let cfg = build_configuration(sess);
let pretty = do getopts::opt_default(matches, "pretty", "normal").map_move |a| {
parse_pretty(sess, a)
};

View File

@ -10,8 +10,6 @@
//! AST-parsing helpers
use rustc::driver::driver::{file_input, str_input};
use rustc::driver::driver;
use rustc::driver::session;
use syntax::ast;
@ -29,14 +27,15 @@ pub fn from_str(source: @str) -> @ast::Crate {
pub fn from_file_sess(sess: session::Session, file: &Path) -> @ast::Crate {
parse::parse_crate_from_file(
file, cfg(sess, file_input((*file).clone())), sess.parse_sess)
file, cfg(sess), sess.parse_sess)
}
pub fn from_str_sess(sess: session::Session, source: @str) -> @ast::Crate {
parse::parse_crate_from_source_str(
@"-", source, cfg(sess, str_input(source)), sess.parse_sess)
@"-", source, cfg(sess), sess.parse_sess)
}
fn cfg(sess: session::Session, input: driver::input) -> ast::CrateConfig {
driver::build_configuration(sess, @"rustdoc", &input)
fn cfg(sess: session::Session) -> ast::CrateConfig {
driver::build_configuration(sess)
}

View File

@ -142,7 +142,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
// Stage 1: parse the input and filter it into the program (as necessary)
//
debug!("parsing: %s", input);
let crate = parse_input(sess, binary, input);
let crate = parse_input(sess, binary);
let mut to_run = ~[]; // statements to run (emitted back into code)
let new_locals = @mut ~[]; // new locals being defined
let mut result = None; // resultant expression (to print via pp)
@ -222,7 +222,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
let test = program.test_code(input, &result, *new_locals);
debug!("testing with ^^^^^^ %?", (||{ println(test) })());
let dinput = driver::str_input(test.to_managed());
let cfg = driver::build_configuration(sess, binary, &dinput);
let cfg = driver::build_configuration(sess);
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &dinput);
let expanded_crate = driver::phase_2_configure_and_expand(sess, cfg, crate);
@ -241,7 +241,7 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
let code = program.code(input, &result);
debug!("actually running ^^^^^^ %?", (||{ println(code) })());
let input = driver::str_input(code.to_managed());
let cfg = driver::build_configuration(sess, binary, &input);
let cfg = driver::build_configuration(sess);
let outputs = driver::build_output_filenames(&input, &None, &None, [], sess);
let sess = driver::build_session(options, diagnostic::emit);
@ -266,11 +266,10 @@ fn run(mut program: ~Program, binary: ~str, lib_search_paths: ~[~str],
//
return (program, jit::consume_engine());
fn parse_input(sess: session::Session, binary: @str,
input: &str) -> @ast::Crate {
fn parse_input(sess: session::Session, input: &str) -> @ast::Crate {
let code = fmt!("fn main() {\n %s \n}", input);
let input = driver::str_input(code.to_managed());
let cfg = driver::build_configuration(sess, binary, &input);
let cfg = driver::build_configuration(sess);
driver::phase_1_parse_input(sess, cfg.clone(), &input)
}
@ -308,7 +307,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
let input = driver::file_input(src_path.clone());
let sess = driver::build_session(options, diagnostic::emit);
*sess.building_library = true;
let cfg = driver::build_configuration(sess, binary, &input);
let cfg = driver::build_configuration(sess);
let outputs = driver::build_output_filenames(
&input, &None, &None, [], sess);
// If the library already exists and is newer than the source

View File

@ -108,7 +108,7 @@ fn parse<'a>(script: Path, workspace: &Path, id: &'a PkgId) -> PkgScript<'a> {
};
let input = driver::file_input(script);
let sess = driver::build_session(options, diagnostic::emit);
let cfg = driver::build_configuration(sess, binary, &input);
let cfg = driver::build_configuration(sess);
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
let crate = driver::phase_2_configure_and_expand(sess, cfg.clone(), crate);
let work_dir = build_pkg_id_in_workspace(id, workspace);

View File

@ -225,7 +225,7 @@ pub fn compile_input(ctxt: &Ctx,
// Infer dependencies that rustpkg needs to build, by scanning for
// `extern mod` directives.
let cfg = driver::build_configuration(sess, binary, &input);
let cfg = driver::build_configuration(sess);
let mut crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
crate = driver::phase_2_configure_and_expand(sess, cfg, crate);