diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index dc30b4f91a985..ea06d236c6534 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -127,7 +127,8 @@ pub fn abort_on_err(result: Result, sess: &Session) -> T { } pub fn run(args: Vec) -> isize { - monitor(move || { + // args is moved to a child thread (cfg.spawn()) whose lifetime is unknown to Rust + monitor(&args.clone(), move || { let (result, session) = run_compiler(&args, &mut RustcDefaultCalls); if let Err(err_count) = result { if err_count > 0 { @@ -614,7 +615,11 @@ impl RustcDefaultCalls { } } -/// Returns a version string such as "0.12.0-dev". +// These three functions were originally intended to provide some reflectional +// information on the compiler version, but they are no longer very useful since +// librustc_driver was market as "private", + +/// Returns a version string such as "1.9.0-dev". pub fn release_str() -> Option<&'static str> { option_env!("CFG_RELEASE") } @@ -1010,7 +1015,7 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec(f: F) { +pub fn monitor(args: &[String], f: F) { const STACK_SIZE: usize = 8 * 1024 * 1024; // 8MB struct Sink(Arc>>); @@ -1050,8 +1055,12 @@ pub fn monitor(f: F) { emitter.emit(None, "unexpected panic", None, errors::Level::Bug); } - let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(), - format!("we would appreciate a bug report: {}", BUG_REPORT_URL)]; + let xs = [format!("the compiler unexpectedly panicked. this is a bug."), + format!("we would appreciate a bug report:"), + format!(" {}", BUG_REPORT_URL), + format!("version: {}", option_env!("CFG_VERSION").unwrap_or("unknown")), + format!("host: {}", config::host_triple()), + format!("arguments: {:?}", args)]; for note in &xs { emitter.emit(None, ¬e[..], None, errors::Level::Note) } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 90cb78f46a67c..597e9bc668f5f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -277,7 +277,7 @@ pub fn main_args(args: &[String]) -> isize { !matches.opt_present("markdown-no-toc")), (false, false) => {} } - let out = match acquire_input(input, externs, &matches) { + let out = match acquire_input(input, externs, &matches, args) { Ok(out) => out, Err(s) => { println!("input error: {}", s); @@ -311,16 +311,17 @@ pub fn main_args(args: &[String]) -> isize { /// and files and then generates the necessary rustdoc output for formatting. fn acquire_input(input: &str, externs: core::Externs, - matches: &getopts::Matches) -> Result { + matches: &getopts::Matches, + cmdline_args: &[String]) -> Result { match matches.opt_str("r").as_ref().map(|s| &**s) { - Some("rust") => Ok(rust_input(input, externs, matches)), + Some("rust") => Ok(rust_input(input, externs, matches, cmdline_args)), Some("json") => json_input(input), Some(s) => Err(format!("unknown input format: {}", s)), None => { if input.ends_with(".json") { json_input(input) } else { - Ok(rust_input(input, externs, matches)) + Ok(rust_input(input, externs, matches, cmdline_args)) } } } @@ -348,7 +349,8 @@ fn parse_externs(matches: &getopts::Matches) -> Result { /// generated from the cleaned AST of the crate. /// /// This form of input will run all of the plug/cleaning passes -fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matches) -> Output { +fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matches, + cmdline_args: &[String]) -> Output { let mut default_passes = !matches.opt_present("no-defaults"); let mut passes = matches.opt_strs("passes"); let mut plugins = matches.opt_strs("plugins"); @@ -365,7 +367,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche info!("starting to run rustc"); let (tx, rx) = channel(); - rustc_driver::monitor(move || { + rustc_driver::monitor(cmdline_args, move || { use rustc::session::config::Input; tx.send(core::run_core(paths, cfgs, externs, Input::File(cr), diff --git a/src/tools/rustbook/build.rs b/src/tools/rustbook/build.rs index 6014439fafcf9..ce78dc11e85a9 100644 --- a/src/tools/rustbook/build.rs +++ b/src/tools/rustbook/build.rs @@ -137,7 +137,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> { fs::create_dir_all(&out_path)?; - let rustdoc_args: &[String] = &[ + let rustdoc_args = vec![ "".to_string(), preprocessed_path.display().to_string(), format!("-o{}", out_path.display()), @@ -147,7 +147,7 @@ fn render(book: &Book, tgt: &Path) -> CliResult<()> { format!("--markdown-css={}", item.path_to_root.join("rustbook.css").display()), "--markdown-no-toc".to_string(), ]; - let output_result = rustdoc::main_args(rustdoc_args); + let output_result = rustdoc::main_args(&rustdoc_args); if output_result != 0 { let message = format!("Could not execute `rustdoc` with {:?}: {}", rustdoc_args, output_result);