//! This API is completely unstable and subject to change.
#![crate_name = "rustc_driver"]
-#![unstable(feature = "unnamed_feature", since = "1.0.0")]
+#![unstable(feature = "rustc_private")]
#![staged_api]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
-#![allow(unknown_features)]
-#![feature(quote)]
-#![feature(slicing_syntax, unsafe_destructor)]
#![feature(box_syntax)]
+#![feature(collections)]
+#![feature(core)]
+#![feature(env)]
+#![feature(int_uint)]
+#![feature(io)]
+#![feature(libc)]
+#![feature(os)]
+#![feature(path)]
+#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
-#![feature(unnamed_feature)]
-#![allow(unknown_features)] #![feature(int_uint)]
+#![feature(rustc_private)]
+#![feature(slicing_syntax, unsafe_destructor)]
+#![feature(staged_api)]
+#![feature(std_misc)]
+#![feature(unicode)]
extern crate arena;
extern crate flate;
use rustc::lint;
use rustc::metadata;
use rustc::metadata::creader::CrateOrString::Str;
-use rustc::DIAGNOSTICS;
use rustc::util::common::time;
use std::cmp::Ordering::Equal;
-use std::io;
+use std::old_io;
use std::iter::repeat;
-use std::os;
+use std::env;
use std::sync::mpsc::channel;
use std::thread;
None => return
};
- let descriptions = diagnostics::registry::Registry::new(&DIAGNOSTICS);
+ let descriptions = diagnostics_registry();
match matches.opt_str("explain") {
Some(ref code) => {
match descriptions.find_description(&code[]) {
1u => {
let ifile = &matches.free[0][];
if ifile == "-" {
- let contents = io::stdin().read_to_end().unwrap();
+ let contents = old_io::stdin().read_to_end().unwrap();
let src = String::from_utf8(contents).unwrap();
(Input::Str(src), None)
} else {
return
}
- let pretty = matches.opt_default("pretty", "normal").map(|a| {
- // stable pretty-print variants only
- pretty::parse_pretty(&sess, a.as_slice(), false)
- });
+ let pretty = if sess.opts.debugging_opts.unstable_options {
+ matches.opt_default("pretty", "normal").map(|a| {
+ // stable pretty-print variants only
+ pretty::parse_pretty(&sess, a.as_slice(), false)
+ })
+ } else {
+ None
+ };
let pretty = if pretty.is_none() &&
sess.unstable_options() {
matches.opt_str("xpretty").map(|a| {
if r.contains(&("ls".to_string())) {
match input {
Input::File(ref ifile) => {
- let mut stdout = io::stdout();
+ let mut stdout = old_io::stdout();
list_metadata(&sess, &(*ifile), &mut stdout).unwrap();
}
Input::Str(_) => {
// subverting the unstable features lints
let bootstrap_secret_key = option_env!("CFG_BOOTSTRAP_KEY");
// The matching key to the above, only known by the build system
- let bootstrap_provided_key = os::getenv("RUSTC_BOOTSTRAP_KEY");
+ let bootstrap_provided_key = env::var_string("RUSTC_BOOTSTRAP_KEY").ok();
match (disable_unstable_features, bootstrap_secret_key, bootstrap_provided_key) {
(_, Some(ref s), Some(ref p)) if s == p => UnstableFeatures::Cheat,
(true, _, _) => UnstableFeatures::Disallow,
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
let print_lints = |&: lints: Vec<&Lint>| {
- for lint in lints.into_iter() {
+ for lint in lints {
let name = lint.name_lower().replace("_", "-");
println!(" {} {:7.7} {}",
padded(&name[]), lint.default_level.as_str(), lint.desc);
println!(" {} {}", padded("----"), "---------");
let print_lint_groups = |&: lints: Vec<(&'static str, Vec<lint::LintId>)>| {
- for (name, to) in lints.into_iter() {
+ for (name, to) in lints {
let name = name.chars().map(|x| x.to_lowercase())
.collect::<String>().replace("_", "-");
let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))
fn describe_debug_flags() {
println!("\nAvailable debug options:\n");
- for &(name, _, opt_type_desc, desc) in config::DB_OPTIONS.iter() {
+ for &(name, _, opt_type_desc, desc) in config::DB_OPTIONS {
let (width, extra) = match opt_type_desc {
Some(..) => (21, "=val"),
None => (25, "")
fn describe_codegen_flags() {
println!("\nAvailable codegen options:\n");
- for &(name, _, opt_type_desc, desc) in config::CG_OPTIONS.iter() {
+ for &(name, _, opt_type_desc, desc) in config::CG_OPTIONS {
let (width, extra) = match opt_type_desc {
Some(..) => (21, "=val"),
None => (25, "")
if sess.opts.prints.len() == 0 { return false }
let attrs = input.map(|input| parse_crate_attrs(sess, input));
- for req in sess.opts.prints.iter() {
+ for req in &sess.opts.prints {
match *req {
PrintRequest::Sysroot => println!("{}", sess.sysroot().display()),
PrintRequest::FileNames |
let crate_types = driver::collect_crate_types(sess, attrs);
let metadata = driver::collect_crate_metadata(sess, attrs);
*sess.crate_metadata.borrow_mut() = metadata;
- for &style in crate_types.iter() {
+ for &style in &crate_types {
let fname = link::filename_for_input(sess, style,
id.as_slice(),
&t_outputs.with_extension(""));
}
pub fn list_metadata(sess: &Session, path: &Path,
- out: &mut io::Writer) -> io::IoResult<()> {
+ out: &mut old_io::Writer) -> old_io::IoResult<()> {
metadata::loader::list_file_metadata(sess.target.target.options.is_like_osx, path, out)
}
static STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
let (tx, rx) = channel();
- let w = io::ChanWriter::new(tx);
- let mut r = io::ChanReader::new(rx);
+ let w = old_io::ChanWriter::new(tx);
+ let mut r = old_io::ChanReader::new(rx);
let mut cfg = thread::Builder::new().name("rustc".to_string());
// FIXME: Hacks on hacks. If the env is trying to override the stack size
// then *don't* set it explicitly.
- if os::getenv("RUST_MIN_STACK").is_none() {
+ if env::var("RUST_MIN_STACK").is_none() {
cfg = cfg.stack_size(STACK_SIZE);
}
- match cfg.scoped(move || { std::io::stdio::set_stderr(box w); f() }).join() {
+ match cfg.scoped(move || { std::old_io::stdio::set_stderr(box w); f() }).join() {
Ok(()) => { /* fallthrough */ }
Err(value) => {
// Thread panicked without emitting a fatal diagnostic
BUG_REPORT_URL),
"run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
];
- for note in xs.iter() {
+ for note in &xs {
emitter.emit(None, ¬e[], None, diagnostic::Note)
}
// Panic so the process returns a failure code, but don't pollute the
// output with some unnecessary panic messages, we've already
// printed everything that we needed to.
- io::stdio::set_stderr(box io::util::NullWriter);
+ old_io::stdio::set_stderr(box old_io::util::NullWriter);
panic!();
}
}
}
+pub fn diagnostics_registry() -> diagnostics::registry::Registry {
+ use syntax::diagnostics::registry::Registry;
+
+ let all_errors = Vec::new() +
+ rustc::diagnostics::DIAGNOSTICS.as_slice() +
+ rustc_typeck::diagnostics::DIAGNOSTICS.as_slice() +
+ rustc_resolve::diagnostics::DIAGNOSTICS.as_slice();
+
+ Registry::new(&*all_errors)
+}
+
pub fn main() {
- let args = std::os::args();
- let result = run(args);
- std::os::set_exit_status(result);
+ let args = env::args().map(|s| s.into_string().unwrap());
+ let result = run(args.collect());
+ std::env::set_exit_status(result as i32);
}
+