diff options
author | Aleksey Kladov <[email protected]> | 2019-09-28 16:49:00 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-28 16:49:00 +0100 |
commit | e60677178ed27254211958b1f54ff73b4588ab5b (patch) | |
tree | 872d7fcd8cfc5ec7e1a1ec15aacfbc3e9c6a9ff0 /crates/ra_hir | |
parent | 21fa889cf3f70c507e3b9f2f6362e65cbb8ed955 (diff) |
correctly reset chalk state after a panic
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 90a11ac7d..b0f67ae50 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -1,9 +1,8 @@ | |||
1 | //! Trait solving using Chalk. | 1 | //! Trait solving using Chalk. |
2 | use std::sync::Arc; | 2 | use std::sync::{Arc, Mutex}; |
3 | 3 | ||
4 | use chalk_ir::cast::Cast; | 4 | use chalk_ir::cast::Cast; |
5 | use log::debug; | 5 | use log::debug; |
6 | use parking_lot::Mutex; | ||
7 | use ra_db::salsa; | 6 | use ra_db::salsa; |
8 | use ra_prof::profile; | 7 | use ra_prof::profile; |
9 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
@@ -30,9 +29,6 @@ impl PartialEq for TraitSolver { | |||
30 | 29 | ||
31 | impl Eq for TraitSolver {} | 30 | impl Eq for TraitSolver {} |
32 | 31 | ||
33 | // FIXME: this impl is WRONG, chalk is not RefUnwindSafe, and this causes #1927 | ||
34 | impl std::panic::RefUnwindSafe for TraitSolver {} | ||
35 | |||
36 | impl TraitSolver { | 32 | impl TraitSolver { |
37 | fn solve( | 33 | fn solve( |
38 | &self, | 34 | &self, |
@@ -41,7 +37,14 @@ impl TraitSolver { | |||
41 | ) -> Option<chalk_solve::Solution> { | 37 | ) -> Option<chalk_solve::Solution> { |
42 | let context = ChalkContext { db, krate: self.krate }; | 38 | let context = ChalkContext { db, krate: self.krate }; |
43 | debug!("solve goal: {:?}", goal); | 39 | debug!("solve goal: {:?}", goal); |
44 | let solution = self.inner.lock().solve(&context, goal); | 40 | let mut solver = match self.inner.lock() { |
41 | Ok(it) => it, | ||
42 | // Our cancellation works via unwinding, but, as chalk is not | ||
43 | // panic-safe, we need to make sure to propagate the cancellation. | ||
44 | // Ideally, we should also make chalk panic-safe. | ||
45 | Err(_) => ra_db::Canceled::throw(), | ||
46 | }; | ||
47 | let solution = solver.solve(&context, goal); | ||
45 | debug!("solve({:?}) => {:?}", goal, solution); | 48 | debug!("solve({:?}) => {:?}", goal, solution); |
46 | solution | 49 | solution |
47 | } | 50 | } |