"fmt_macros 0.0.0",
"graphviz 0.0.0",
"jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc_macro 0.0.0",
"rustc_apfloat 0.0.0",
"rustc_back 0.0.0",
"rustc_const_math 0.0.0",
})
}
+ pub fn in_sess() -> bool
+ {
+ let p = CURRENT_SESS.with(|p| p.get());
+ !p.0.is_null()
+ }
+
pub fn with_sess<F, R>(f: F) -> R
where F: FnOnce((&ParseSess, Mark)) -> R
{
fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
+lazy_static = "1.0.0"
log = { version = "0.4", features = ["release_max_level_info", "std"] }
+proc_macro = { path = "../libproc_macro" }
rustc_apfloat = { path = "../librustc_apfloat" }
rustc_back = { path = "../librustc_back" }
rustc_const_math = { path = "../librustc_const_math" }
#![feature(never_type)]
#![feature(non_exhaustive)]
#![feature(nonzero)]
+#![feature(proc_macro_internals)]
#![feature(quote)]
#![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)]
extern crate fmt_macros;
extern crate getopts;
extern crate graphviz;
+#[macro_use] extern crate lazy_static;
#[cfg(windows)]
extern crate libc;
extern crate rustc_back;
#[macro_use] extern crate syntax;
extern crate syntax_pos;
extern crate jobserver;
+extern crate proc_macro;
extern crate serialize as rustc_serialize; // used by deriving
use std::fmt::Debug;
use std::hash::{Hash, BuildHasher};
use std::iter::repeat;
+use std::panic;
use std::path::Path;
use std::time::{Duration, Instant};
use syntax_pos::{SpanData};
use ty::maps::{QueryMsg};
use dep_graph::{DepNode};
+use proc_macro;
+use lazy_static;
// The name of the associated type for `Fn` return types
pub const FN_OUTPUT_NAME: &'static str = "Output";
thread_local!(static TIME_DEPTH: Cell<usize> = Cell::new(0));
+lazy_static! {
+ static ref DEFAULT_HOOK: Box<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) {
+ if !proc_macro::__internal::in_sess() {
+ (*DEFAULT_HOOK)(info)
+ }
+}
+
+pub fn install_panic_hook() {
+ lazy_static::initialize(&DEFAULT_HOOK);
+}
+
/// Initialized for -Z profile-queries
thread_local!(static PROFQ_CHAN: RefCell<Option<Sender<ProfileQueriesMsg>>> = RefCell::new(None));
use rustc::middle::privacy::AccessLevels;
use rustc::ty::{self, TyCtxt, Resolutions, AllArenas};
use rustc::traits;
-use rustc::util::common::{ErrorReported, time};
+use rustc::util::common::{ErrorReported, time, install_panic_hook};
use rustc_allocator as allocator;
use rustc_borrowck as borrowck;
use rustc_incremental;
let outputs = build_output_filenames(input, outdir, output, &krate.attrs, sess);
let crate_name =
::rustc_trans_utils::link::find_crate_name(Some(sess), &krate.attrs, input);
+ install_panic_hook();
+
let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
phase_2_configure_and_expand(
sess,
// except according to those terms.
// aux-build:derive-panic.rs
+// compile-flags:--error-format human
#[macro_use]
extern crate derive_panic;
error: proc-macro derive panicked
- --> $DIR/load-panic.rs:16:10
+ --> $DIR/load-panic.rs:17:10
|
-16 | #[derive(A)]
+17 | #[derive(A)]
| ^
|
= help: message: nope!