diff --git a/src/driver.rs b/src/driver.rs index 22271460b02..0166f9ea5ba 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -307,7 +307,7 @@ fn codegen_mono_items<'tcx>( } for (mono_item, (linkage, visibility)) in mono_items { - crate::unimpl::try_unimpl(tcx, mono_item.to_string(tcx, true), || { + crate::unimpl::try_unimpl(tcx, || { let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); trans_mono_item(&mut cx, mono_item, linkage); }); diff --git a/src/unimpl.rs b/src/unimpl.rs index 3e7dddc6445..b668235e75e 100644 --- a/src/unimpl.rs +++ b/src/unimpl.rs @@ -1,14 +1,8 @@ //! The unimpl! macro is defined here. It is used to generate //! a non-fatal error on not yet implemented things. -use std::cell::RefCell; - use rustc::ty::TyCtxt; -thread_local! { - static CURRENT_MSG: RefCell = RefCell::new(String::new()); -} - // Just public, because of the unimpl macro #[doc(hidden)] pub struct NonFatal(pub String); @@ -20,21 +14,15 @@ panic!(NonFatal(format!($($tt)*))); } -pub fn try_unimpl(tcx: TyCtxt, msg: String, f: impl FnOnce()) { - CURRENT_MSG.with(|current_msg| { - let old = std::mem::replace(&mut *current_msg.borrow_mut(), msg); +pub fn try_unimpl(tcx: TyCtxt, f: impl FnOnce()) { + let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); - let res = ::std::panic::catch_unwind(::std::panic::AssertUnwindSafe(|| f())); - - if let Err(err) = res { - match err.downcast::() { - Ok(non_fatal) => { - tcx.sess.err(&format!("at {}: {}", current_msg.borrow(), non_fatal.0)); - } - Err(err) => ::std::panic::resume_unwind(err), + if let Err(err) = res { + match err.downcast::() { + Ok(non_fatal) => { + tcx.sess.err(&non_fatal.0); } + Err(err) => ::std::panic::resume_unwind(err), } - - *current_msg.borrow_mut() = old; - }); + } }