From 35f1655b0bc0452ee5f2bed521ebb12c17a8a20d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 27 Sep 2019 20:47:36 +0300 Subject: replace horrible hack with a slightly less horrible one --- crates/ra_hir/src/ty/traits.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index d11dab294..90a11ac7d 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs @@ -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, -- cgit v1.2.3 From e60677178ed27254211958b1f54ff73b4588ab5b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 28 Sep 2019 18:49:00 +0300 Subject: correctly reset chalk state after a panic --- crates/ra_hir/src/ty/traits.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src') 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 @@ //! Trait solving using Chalk. -use std::sync::Arc; +use std::sync::{Arc, Mutex}; use chalk_ir::cast::Cast; use log::debug; -use parking_lot::Mutex; use ra_db::salsa; use ra_prof::profile; use rustc_hash::FxHashSet; @@ -30,9 +29,6 @@ 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, @@ -41,7 +37,14 @@ impl TraitSolver { ) -> Option { let context = ChalkContext { db, krate: self.krate }; debug!("solve goal: {:?}", goal); - let solution = self.inner.lock().solve(&context, goal); + let mut solver = match self.inner.lock() { + Ok(it) => it, + // Our cancellation works via unwinding, but, as chalk is not + // panic-safe, we need to make sure to propagate the cancellation. + // Ideally, we should also make chalk panic-safe. + Err(_) => ra_db::Canceled::throw(), + }; + let solution = solver.solve(&context, goal); debug!("solve({:?}) => {:?}", goal, solution); solution } -- cgit v1.2.3 From 5a4b4f507e9b90bfe41b451763868cba0a70c392 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Mon, 30 Sep 2019 05:15:03 +0800 Subject: Fix API of Attr --- crates/ra_hir/src/lang_item.rs | 2 +- crates/ra_hir/src/nameres/raw.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src') diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs index bcce314d8..dbba433fe 100644 --- a/crates/ra_hir/src/lang_item.rs +++ b/crates/ra_hir/src/lang_item.rs @@ -151,7 +151,7 @@ impl LangItems { fn lang_item_name(node: &T) -> Option { node.attrs() - .filter_map(|a| a.as_key_value()) + .filter_map(|a| a.as_simple_key_value()) .filter(|(key, _)| key == "lang") .map(|(_, val)| val) .nth(0) diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index c494b95b0..0e27dd2db 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs @@ -353,8 +353,7 @@ impl RawItemsCollector<&DB> { let name = m.name().map(|it| it.as_name()); let ast_id = self.source_ast_id_map.ast_id(&m); - let export = m.has_atom_attr("macro_export") - || m.attrs().filter_map(|x| x.as_call()).any(|(name, _)| name == "macro_export"); + let export = m.attrs().filter_map(|x| x.simple_name()).any(|name| name == "macro_export"); let m = self.raw_items.macros.alloc(MacroData { ast_id, path, name, export }); self.push_item(current_module, RawItem::Macro(m)); @@ -385,7 +384,7 @@ impl RawItemsCollector<&DB> { fn extract_mod_path_attribute(module: &ast::Module) -> Option { module.attrs().into_iter().find_map(|attr| { - attr.as_key_value().and_then(|(name, value)| { + attr.as_simple_key_value().and_then(|(name, value)| { let is_path = name == "path"; if is_path { Some(value) -- cgit v1.2.3