Revert "Don't PrintOnPanic on fatal errors"
This reverts commit b5ac64b4cf33809b182a6f7c63a7c4e874fb3056. It entirely breaks PrintOnPanic as ICE seems to be considered a fatal error too.
This commit is contained in:
parent
14ca1df478
commit
ab0e2aaed2
11
src/base.rs
11
src/base.rs
@ -29,9 +29,8 @@ pub(crate) fn codegen_and_compile_fn<'tcx>(
|
|||||||
module: &mut dyn Module,
|
module: &mut dyn Module,
|
||||||
instance: Instance<'tcx>,
|
instance: Instance<'tcx>,
|
||||||
) {
|
) {
|
||||||
let _inst_guard = crate::PrintOnPanic(Some(tcx.sess), || {
|
let _inst_guard =
|
||||||
format!("{:?} {}", instance, tcx.symbol_name(instance).name)
|
crate::PrintOnPanic(|| format!("{:?} {}", instance, tcx.symbol_name(instance).name));
|
||||||
});
|
|
||||||
|
|
||||||
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
let cached_func = std::mem::replace(&mut cached_context.func, Function::new());
|
||||||
let codegened_func = codegen_fn(tcx, cx, cached_func, module, instance);
|
let codegened_func = codegen_fn(tcx, cx, cached_func, module, instance);
|
||||||
@ -49,7 +48,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
|||||||
debug_assert!(!instance.substs.needs_infer());
|
debug_assert!(!instance.substs.needs_infer());
|
||||||
|
|
||||||
let mir = tcx.instance_mir(instance.def);
|
let mir = tcx.instance_mir(instance.def);
|
||||||
let _mir_guard = crate::PrintOnPanic(Some(tcx.sess), || {
|
let _mir_guard = crate::PrintOnPanic(|| {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
with_no_trimmed_paths!({
|
with_no_trimmed_paths!({
|
||||||
rustc_middle::mir::pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut buf)
|
rustc_middle::mir::pretty::write_mir_fn(tcx, mir, &mut |_, _| Ok(()), &mut buf)
|
||||||
@ -177,7 +176,7 @@ pub(crate) fn compile_fn(
|
|||||||
write!(clif, " {}", isa_flag).unwrap();
|
write!(clif, " {}", isa_flag).unwrap();
|
||||||
}
|
}
|
||||||
writeln!(clif, "\n").unwrap();
|
writeln!(clif, "\n").unwrap();
|
||||||
crate::PrintOnPanic(None, move || {
|
crate::PrintOnPanic(move || {
|
||||||
let mut clif = clif.clone();
|
let mut clif = clif.clone();
|
||||||
::cranelift_codegen::write::decorate_function(
|
::cranelift_codegen::write::decorate_function(
|
||||||
&mut &clif_comments_clone,
|
&mut &clif_comments_clone,
|
||||||
@ -498,7 +497,7 @@ fn codegen_stmt<'tcx>(
|
|||||||
#[allow(unused_variables)] cur_block: Block,
|
#[allow(unused_variables)] cur_block: Block,
|
||||||
stmt: &Statement<'tcx>,
|
stmt: &Statement<'tcx>,
|
||||||
) {
|
) {
|
||||||
let _print_guard = crate::PrintOnPanic(Some(fx.tcx.sess), || format!("stmt {:?}", stmt));
|
let _print_guard = crate::PrintOnPanic(|| format!("stmt {:?}", stmt));
|
||||||
|
|
||||||
fx.set_debug_loc(stmt.source_info);
|
fx.set_debug_loc(stmt.source_info);
|
||||||
|
|
||||||
|
@ -23,8 +23,7 @@ fn predefine_mono_items<'tcx>(
|
|||||||
match mono_item {
|
match mono_item {
|
||||||
MonoItem::Fn(instance) => {
|
MonoItem::Fn(instance) => {
|
||||||
let name = tcx.symbol_name(instance).name;
|
let name = tcx.symbol_name(instance).name;
|
||||||
let _inst_guard =
|
let _inst_guard = crate::PrintOnPanic(|| format!("{:?} {}", instance, name));
|
||||||
crate::PrintOnPanic(Some(tcx.sess), || format!("{:?} {}", instance, name));
|
|
||||||
let sig =
|
let sig =
|
||||||
get_function_sig(tcx, module.target_config().default_call_conv, instance);
|
get_function_sig(tcx, module.target_config().default_call_conv, instance);
|
||||||
let linkage = crate::linkage::get_clif_linkage(
|
let linkage = crate::linkage::get_clif_linkage(
|
||||||
|
@ -113,11 +113,11 @@ mod prelude {
|
|||||||
pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue};
|
pub(crate) use crate::value_and_place::{CPlace, CPlaceInner, CValue};
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PrintOnPanic<'a, F: Fn() -> String>(Option<&'a Session>, F);
|
struct PrintOnPanic<F: Fn() -> String>(F);
|
||||||
impl<'a, F: Fn() -> String> Drop for PrintOnPanic<'a, F> {
|
impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if ::std::thread::panicking() && self.0.map_or(true, |sess| sess.has_errors().is_none()) {
|
if ::std::thread::panicking() {
|
||||||
println!("{}", (self.1)());
|
println!("{}", (self.0)());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user