replace horrible hack with a slightly less horrible one

This commit is contained in:
Aleksey Kladov 2019-09-27 20:47:36 +03:00
parent 2b69c84396
commit 35f1655b0b
2 changed files with 5 additions and 3 deletions

View File

@ -32,11 +32,10 @@ pub trait CheckCanceled {
fn catch_canceled<F, T>(&self, f: F) -> Result<T, Canceled>
where
Self: Sized,
Self: Sized + panic::RefUnwindSafe,
F: FnOnce(&Self) -> T + panic::UnwindSafe,
{
let this = panic::AssertUnwindSafe(self);
panic::catch_unwind(|| f(*this)).map_err(|err| match err.downcast::<Canceled>() {
panic::catch_unwind(|| f(self)).map_err(|err| match err.downcast::<Canceled>() {
Ok(canceled) => *canceled,
Err(payload) => panic::resume_unwind(payload),
})

View File

@ -30,6 +30,9 @@ impl PartialEq for TraitSolver {
impl Eq for TraitSolver {}
// FIXME: this impl is WRONG, chalk is not RefUnwindSafe, and this causes #1927
impl std::panic::RefUnwindSafe for TraitSolver {}
impl TraitSolver {
fn solve(
&self,