1930: replace horrible hack with a slightly less horrible one r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2019-09-27 17:48:00 +00:00 committed by GitHub
commit 21fa889cf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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,