Skip to content

Remove unused automatic cfg bindings Fixes #7169 #8499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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") }
Expand Down Expand Up @@ -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;
Expand All @@ -998,7 +995,7 @@ mod 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")));
}

Expand All @@ -1016,7 +1013,7 @@ mod 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());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down
11 changes: 5 additions & 6 deletions src/librustdoc/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
}

13 changes: 6 additions & 7 deletions src/librusti/rusti.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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)
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/rustpkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl<'self> PkgScript<'self> {
};
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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustpkg/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down