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.
This commit is contained in:
Aleksey Kladov 2019-06-01 10:57:44 +03:00
parent 5023860a55
commit f89d34be6a
2 changed files with 5 additions and 3 deletions

View File

@ -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};

View File

@ -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
}