aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/db.rs3
-rw-r--r--crates/hir_def/src/nameres/collector.rs4
-rw-r--r--crates/hir_def/src/test_db.rs9
3 files changed, 15 insertions, 1 deletions
diff --git a/crates/hir_def/src/db.rs b/crates/hir_def/src/db.rs
index 7eadc8e0d..c977971cd 100644
--- a/crates/hir_def/src/db.rs
+++ b/crates/hir_def/src/db.rs
@@ -51,6 +51,9 @@ pub trait InternDatabase: SourceDatabase {
51 51
52#[salsa::query_group(DefDatabaseStorage)] 52#[salsa::query_group(DefDatabaseStorage)]
53pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> { 53pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
54 #[salsa::input]
55 fn enable_proc_attr_macros(&self) -> bool;
56
54 #[salsa::invoke(ItemTree::file_item_tree_query)] 57 #[salsa::invoke(ItemTree::file_item_tree_query)]
55 fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>; 58 fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;
56 59
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 874a4ebb1..b2ce739bd 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -1067,6 +1067,10 @@ impl DefCollector<'_> {
1067 } 1067 }
1068 } 1068 }
1069 1069
1070 if !self.db.enable_proc_attr_macros() {
1071 return true;
1072 }
1073
1070 // Not resolved to a derive helper, so try to resolve as a macro. 1074 // Not resolved to a derive helper, so try to resolve as a macro.
1071 match attr_macro_as_call_id( 1075 match attr_macro_as_call_id(
1072 ast_id, 1076 ast_id,
diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs
index e840fe5e8..b20b066e2 100644
--- a/crates/hir_def/src/test_db.rs
+++ b/crates/hir_def/src/test_db.rs
@@ -30,12 +30,19 @@ use crate::{
30 crate::db::InternDatabaseStorage, 30 crate::db::InternDatabaseStorage,
31 crate::db::DefDatabaseStorage 31 crate::db::DefDatabaseStorage
32)] 32)]
33#[derive(Default)]
34pub(crate) struct TestDB { 33pub(crate) struct TestDB {
35 storage: salsa::Storage<TestDB>, 34 storage: salsa::Storage<TestDB>,
36 events: Mutex<Option<Vec<salsa::Event>>>, 35 events: Mutex<Option<Vec<salsa::Event>>>,
37} 36}
38 37
38impl Default for TestDB {
39 fn default() -> Self {
40 let mut this = Self { storage: Default::default(), events: Default::default() };
41 this.set_enable_proc_attr_macros(true);
42 this
43 }
44}
45
39impl Upcast<dyn AstDatabase> for TestDB { 46impl Upcast<dyn AstDatabase> for TestDB {
40 fn upcast(&self) -> &(dyn AstDatabase + 'static) { 47 fn upcast(&self) -> &(dyn AstDatabase + 'static) {
41 &*self 48 &*self