fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
-lazy_static = "1.0.0"
num_cpus = "1.0"
scoped-tls = "1.0"
log = { version = "0.4", features = ["release_max_level_info", "std"] }
#[macro_use] extern crate bitflags;
extern crate getopts;
-#[macro_use] extern crate lazy_static;
#[macro_use] extern crate scoped_tls;
#[cfg(windows)]
extern crate libc;
use std::cell::{RefCell, Cell};
use std::fmt::Debug;
use std::hash::Hash;
-use std::panic;
-use std::env;
use std::time::{Duration, Instant};
use std::sync::mpsc::{Sender};
use syntax_pos::{SpanData};
use syntax::symbol::{Symbol, sym};
use rustc_macros::HashStable;
-use crate::ty::TyCtxt;
use crate::dep_graph::{DepNode};
-use lazy_static;
use crate::session::Session;
#[cfg(test)]
thread_local!(static TIME_DEPTH: Cell<usize> = Cell::new(0));
-lazy_static! {
- static ref DEFAULT_HOOK: Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static> = {
- let hook = panic::take_hook();
- panic::set_hook(Box::new(panic_hook));
- hook
- };
-}
-
-fn panic_hook(info: &panic::PanicInfo<'_>) {
- (*DEFAULT_HOOK)(info);
-
- let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
-
- if backtrace {
- TyCtxt::try_print_query_stack();
- }
-
- #[cfg(windows)]
- unsafe {
- if env::var("RUSTC_BREAK_ON_ICE").is_ok() {
- extern "system" {
- fn DebugBreak();
- }
- // Trigger a debugger if we crashed during bootstrap.
- DebugBreak();
- }
- }
-}
-
-pub fn install_panic_hook() {
- lazy_static::initialize(&DEFAULT_HOOK);
-}
-
/// Parameters to the `Dump` variant of type `ProfileQueriesMsg`.
#[derive(Clone,Debug)]
pub struct ProfQDumpParams {
use rustc::lint::Lint;
use rustc::lint;
use rustc::hir::def_id::LOCAL_CRATE;
-use rustc::util::common::{ErrorReported, install_panic_hook, print_time_passes_entry};
-use rustc::util::common::{set_time_depth, time};
+use rustc::ty::TyCtxt;
+use rustc::util::common::{set_time_depth, time, print_time_passes_entry, ErrorReported};
use rustc_metadata::locator;
use rustc_metadata::cstore::CStore;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
None => return Ok(()),
};
- install_panic_hook();
-
let (sopts, cfg) = config::build_session_options_and_crate_config(&matches);
let mut dummy_config = |sopts, cfg, diagnostic_output| {
}
pub fn report_ice(info: &panic::PanicInfo<'_>) {
+ // Invoke the default handler, which prints the actual panic message and optionally a backtrace
(*DEFAULT_HOOK)(info);
- // Thread panicked without emitting a fatal diagnostic
+ // Print the infamous ICE message
eprintln!();
let emitter = Box::new(errors::emitter::EmitterWriter::stderr(
note,
errors::Level::Note);
}
+
+ // If backtraces are enabled, also print the query stack
+ let backtrace = env::var_os("RUST_BACKTRACE").map(|x| &x != "0").unwrap_or(false);
+
+ if backtrace {
+ TyCtxt::try_print_query_stack();
+ }
+
+ #[cfg(windows)]
+ unsafe {
+ if env::var("RUSTC_BREAK_ON_ICE").is_ok() {
+ extern "system" {
+ fn DebugBreak();
+ }
+ // Trigger a debugger if we crashed during bootstrap
+ DebugBreak();
+ }
+ }
}
pub fn install_ice_hook() {