From f89d34be6a93263d7fa506bba6da1d1d7de237bc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Jun 2019 10:57:44 +0300 Subject: [PATCH] don't poison mutex around chalk We use panics for cancellation, so we could trigger panic while holding the solver. std::sync::Mutex will be poisoned as a result, which and all further attempts to use solver (from other threads) will panic as well. This commit switches to parking_lot::Mutex which just unlocks on panic. --- crates/ra_hir/src/db.rs | 3 ++- crates/ra_hir/src/ty/traits.rs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 11cdf9c349..d84e1598b7 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -1,5 +1,6 @@ -use std::sync::{Arc, Mutex}; +use std::sync::Arc; +use parking_lot::Mutex; use ra_syntax::{SyntaxNode, TreeArc, SmolStr, ast}; use ra_db::{SourceDatabase, salsa}; diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index fc90f56d50..db78f25ca3 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs @@ -1,6 +1,7 @@ //! Trait solving using Chalk. -use std::sync::{Arc, Mutex}; +use std::sync::Arc; +use parking_lot::Mutex; use rustc_hash::FxHashSet; use log::debug; use chalk_ir::cast::Cast; @@ -61,7 +62,7 @@ fn solve( let context = ChalkContext { db, krate }; let solver = db.solver(krate); debug!("solve goal: {:?}", goal); - let solution = solver.lock().unwrap().solve_with_fuel(&context, goal, Some(1000)); + let solution = solver.lock().solve_with_fuel(&context, goal, Some(1000)); debug!("solve({:?}) => {:?}", goal, solution); solution }