Skip to content

Add more info to an ICE message #32371

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
19 changes: 14 additions & 5 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ pub fn abort_on_err<T>(result: Result<T, usize>, sess: &Session) -> T {
}

pub fn run(args: Vec<String>) -> 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 {
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -1010,7 +1015,7 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
///
/// The diagnostic emitter yielded to the procedure should be used for reporting
/// errors of the compiler.
pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
pub fn monitor<F: FnOnce() + Send + 'static>(args: &[String], f: F) {
const STACK_SIZE: usize = 8 * 1024 * 1024; // 8MB

struct Sink(Arc<Mutex<Vec<u8>>>);
Expand Down Expand Up @@ -1050,8 +1055,12 @@ pub fn monitor<F: FnOnce() + Send + 'static>(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, &note[..], None, errors::Level::Note)
}
Expand Down
14 changes: 8 additions & 6 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<Output, String> {
matches: &getopts::Matches,
cmdline_args: &[String]) -> Result<Output, String> {
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))
}
}
}
Expand Down Expand Up @@ -348,7 +349,8 @@ fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
/// 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");
Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/tools/rustbook/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -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);
Expand Down