Make it opt-in

This commit is contained in:
Jonas Schievink 2021-06-03 16:11:20 +02:00
parent e5a2c6596d
commit 9fdb8f9037
9 changed files with 44 additions and 4 deletions

View file

@ -51,6 +51,9 @@ pub trait InternDatabase: SourceDatabase {
#[salsa::query_group(DefDatabaseStorage)]
pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
#[salsa::input]
fn enable_proc_attr_macros(&self) -> bool;
#[salsa::invoke(ItemTree::file_item_tree_query)]
fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;

View file

@ -1067,6 +1067,10 @@ impl DefCollector<'_> {
}
}
if !self.db.enable_proc_attr_macros() {
return true;
}
// Not resolved to a derive helper, so try to resolve as a macro.
match attr_macro_as_call_id(
ast_id,

View file

@ -30,12 +30,19 @@ use crate::{
crate::db::InternDatabaseStorage,
crate::db::DefDatabaseStorage
)]
#[derive(Default)]
pub(crate) struct TestDB {
storage: salsa::Storage<TestDB>,
events: Mutex<Option<Vec<salsa::Event>>>,
}
impl Default for TestDB {
fn default() -> Self {
let mut this = Self { storage: Default::default(), events: Default::default() };
this.set_enable_proc_attr_macros(true);
this
}
}
impl Upcast<dyn AstDatabase> for TestDB {
fn upcast(&self) -> &(dyn AstDatabase + 'static) {
&*self