about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/hir-def/src/data.rs2
-rw-r--r--crates/hir-def/src/db.rs2
-rw-r--r--crates/hir-def/src/nameres/collector.rs2
-rw-r--r--crates/hir-def/src/test_db.rs7
-rw-r--r--crates/hir-ty/src/test_db.rs5
-rw-r--r--crates/ide-assists/src/tests.rs4
-rw-r--r--crates/ide-completion/src/tests.rs4
-rw-r--r--crates/ide-db/src/lib.rs6
-rw-r--r--crates/ide/src/fixture.rs13
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs3
-rw-r--r--crates/rust-analyzer/src/reload.rs13
11 files changed, 33 insertions, 28 deletions
diff --git a/crates/hir-def/src/data.rs b/crates/hir-def/src/data.rs
index 1633a33bedd..dcc21db7409 100644
--- a/crates/hir-def/src/data.rs
+++ b/crates/hir-def/src/data.rs
@@ -590,7 +590,7 @@ impl<'a> AssocItemCollector<'a> {
                 ) {
                     self.attr_calls.push((ast_id, call_id));
                     // If proc attribute macro expansion is disabled, skip expanding it here
-                    if !self.db.enable_proc_attr_macros() {
+                    if !self.db.expand_proc_attr_macros() {
                         continue 'attrs;
                     }
                     let loc = self.db.lookup_intern_macro_call(call_id);
diff --git a/crates/hir-def/src/db.rs b/crates/hir-def/src/db.rs
index e6986dd1fce..8d236aca367 100644
--- a/crates/hir-def/src/db.rs
+++ b/crates/hir-def/src/db.rs
@@ -66,7 +66,7 @@ pub trait InternDatabase: SourceDatabase {
 #[salsa::query_group(DefDatabaseStorage)]
 pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDatabase> {
     #[salsa::input]
-    fn enable_proc_attr_macros(&self) -> bool;
+    fn expand_proc_attr_macros(&self) -> bool;
 
     #[salsa::invoke(ItemTree::file_item_tree_query)]
     fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index b3ce913d9ab..84c7a80e150 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -1282,7 +1282,7 @@ impl DefCollector<'_> {
                     let loc: MacroCallLoc = self.db.lookup_intern_macro_call(call_id);
 
                     // If proc attribute macro expansion is disabled, skip expanding it here
-                    if !self.db.enable_proc_attr_macros() {
+                    if !self.db.expand_proc_attr_macros() {
                         self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro(
                             directive.module_id,
                             loc.kind,
diff --git a/crates/hir-def/src/test_db.rs b/crates/hir-def/src/test_db.rs
index ee143b19ae5..a6d388105bb 100644
--- a/crates/hir-def/src/test_db.rs
+++ b/crates/hir-def/src/test_db.rs
@@ -6,8 +6,9 @@ use std::{
 };
 
 use base_db::{
-    salsa, AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, FilePosition,
-    SourceDatabase, Upcast,
+    salsa::{self, Durability},
+    AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, FilePosition, SourceDatabase,
+    Upcast,
 };
 use hir_expand::{db::ExpandDatabase, InFile};
 use stdx::hash::NoHashHashSet;
@@ -35,7 +36,7 @@ pub(crate) struct TestDB {
 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.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
         this
     }
 }
diff --git a/crates/hir-ty/src/test_db.rs b/crates/hir-ty/src/test_db.rs
index 8c48331b94b..10e08f01720 100644
--- a/crates/hir-ty/src/test_db.rs
+++ b/crates/hir-ty/src/test_db.rs
@@ -6,7 +6,8 @@ use std::{
 };
 
 use base_db::{
-    salsa, AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
+    salsa::{self, Durability},
+    AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
 };
 use hir_def::{db::DefDatabase, ModuleId};
 use hir_expand::db::ExpandDatabase;
@@ -30,7 +31,7 @@ pub(crate) struct TestDB {
 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.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
         this
     }
 }
diff --git a/crates/ide-assists/src/tests.rs b/crates/ide-assists/src/tests.rs
index 94be99fd7ab..6e161ca4396 100644
--- a/crates/ide-assists/src/tests.rs
+++ b/crates/ide-assists/src/tests.rs
@@ -3,7 +3,7 @@ mod generated;
 mod sourcegen;
 
 use expect_test::expect;
-use hir::{db::DefDatabase, Semantics};
+use hir::Semantics;
 use ide_db::{
     base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt},
     imports::insert_use::{ImportGranularity, InsertUseConfig},
@@ -161,7 +161,7 @@ fn check_with_config(
     assist_label: Option<&str>,
 ) {
     let (mut db, file_with_caret_id, range_or_offset) = RootDatabase::with_range_or_offset(before);
-    db.set_enable_proc_attr_macros(true);
+    db.enable_proc_attr_macros();
     let text_without_caret = db.file_text(file_with_caret_id).to_string();
 
     let frange = FileRange { file_id: file_with_caret_id, range: range_or_offset.into() };
diff --git a/crates/ide-completion/src/tests.rs b/crates/ide-completion/src/tests.rs
index 1fe48b9e96f..05e6aaf09d9 100644
--- a/crates/ide-completion/src/tests.rs
+++ b/crates/ide-completion/src/tests.rs
@@ -23,7 +23,7 @@ mod type_pos;
 mod use_tree;
 mod visibility;
 
-use hir::{db::DefDatabase, PrefixKind};
+use hir::PrefixKind;
 use ide_db::{
     base_db::{fixture::ChangeFixture, FileLoader, FilePosition},
     imports::insert_use::{ImportGranularity, InsertUseConfig},
@@ -120,7 +120,7 @@ fn completion_list_with_config(
 pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
     let change_fixture = ChangeFixture::parse(ra_fixture);
     let mut database = RootDatabase::default();
-    database.set_enable_proc_attr_macros(true);
+    database.enable_proc_attr_macros();
     database.apply_change(change_fixture.change);
     let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
     let offset = range_or_offset.expect_offset();
diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs
index 64f22261d21..bd8b48b0362 100644
--- a/crates/ide-db/src/lib.rs
+++ b/crates/ide-db/src/lib.rs
@@ -140,11 +140,15 @@ impl RootDatabase {
         db.set_proc_macros_with_durability(Default::default(), Durability::HIGH);
         db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
         db.set_library_roots_with_durability(Default::default(), Durability::HIGH);
-        db.set_enable_proc_attr_macros(false);
+        db.set_expand_proc_attr_macros_with_durability(false, Durability::HIGH);
         db.update_parse_query_lru_capacity(lru_capacity);
         db
     }
 
+    pub fn enable_proc_attr_macros(&mut self) {
+        self.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
+    }
+
     pub fn update_parse_query_lru_capacity(&mut self, lru_capacity: Option<usize>) {
         let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP);
         base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
diff --git a/crates/ide/src/fixture.rs b/crates/ide/src/fixture.rs
index 2ea6f6a9ab1..79665b9eed5 100644
--- a/crates/ide/src/fixture.rs
+++ b/crates/ide/src/fixture.rs
@@ -1,5 +1,4 @@
 //! Utilities for creating `Analysis` instances for tests.
-use hir::db::DefDatabase;
 use ide_db::base_db::fixture::ChangeFixture;
 use test_utils::{extract_annotations, RangeOrOffset};
 
@@ -9,7 +8,7 @@ use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange};
 pub(crate) fn file(ra_fixture: &str) -> (Analysis, FileId) {
     let mut host = AnalysisHost::default();
     let change_fixture = ChangeFixture::parse(ra_fixture);
-    host.db.set_enable_proc_attr_macros(true);
+    host.db.enable_proc_attr_macros();
     host.db.apply_change(change_fixture.change);
     (host.analysis(), change_fixture.files[0])
 }
@@ -18,7 +17,7 @@ pub(crate) fn file(ra_fixture: &str) -> (Analysis, FileId) {
 pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) {
     let mut host = AnalysisHost::default();
     let change_fixture = ChangeFixture::parse(ra_fixture);
-    host.db.set_enable_proc_attr_macros(true);
+    host.db.enable_proc_attr_macros();
     host.db.apply_change(change_fixture.change);
     let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
     let offset = range_or_offset.expect_offset();
@@ -29,7 +28,7 @@ pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) {
 pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) {
     let mut host = AnalysisHost::default();
     let change_fixture = ChangeFixture::parse(ra_fixture);
-    host.db.set_enable_proc_attr_macros(true);
+    host.db.enable_proc_attr_macros();
     host.db.apply_change(change_fixture.change);
     let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
     let range = range_or_offset.expect_range();
@@ -40,7 +39,7 @@ pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) {
 pub(crate) fn range_or_position(ra_fixture: &str) -> (Analysis, FileId, RangeOrOffset) {
     let mut host = AnalysisHost::default();
     let change_fixture = ChangeFixture::parse(ra_fixture);
-    host.db.set_enable_proc_attr_macros(true);
+    host.db.enable_proc_attr_macros();
     host.db.apply_change(change_fixture.change);
     let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
     (host.analysis(), file_id, range_or_offset)
@@ -50,7 +49,7 @@ pub(crate) fn range_or_position(ra_fixture: &str) -> (Analysis, FileId, RangeOrO
 pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(FileRange, String)>) {
     let mut host = AnalysisHost::default();
     let change_fixture = ChangeFixture::parse(ra_fixture);
-    host.db.set_enable_proc_attr_macros(true);
+    host.db.enable_proc_attr_macros();
     host.db.apply_change(change_fixture.change);
     let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
     let offset = range_or_offset.expect_offset();
@@ -71,7 +70,7 @@ pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(Fil
 pub(crate) fn annotations_without_marker(ra_fixture: &str) -> (Analysis, Vec<(FileRange, String)>) {
     let mut host = AnalysisHost::default();
     let change_fixture = ChangeFixture::parse(ra_fixture);
-    host.db.set_enable_proc_attr_macros(true);
+    host.db.enable_proc_attr_macros();
     host.db.apply_change(change_fixture.change);
 
     let annotations = change_fixture
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index f644bdc7b18..85a410f7b47 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -4,7 +4,6 @@ use std::{convert::identity, path::Path, sync::Arc};
 
 use anyhow::Result;
 use crossbeam_channel::{unbounded, Receiver};
-use hir::db::DefDatabase;
 use ide::{AnalysisHost, Change};
 use ide_db::{
     base_db::{CrateGraph, ProcMacros},
@@ -143,7 +142,7 @@ fn load_crate_graph(
     let mut host = AnalysisHost::new(lru_cap);
     let mut analysis_change = Change::new();
 
-    host.raw_database_mut().set_enable_proc_attr_macros(true);
+    host.raw_database_mut().enable_proc_attr_macros();
 
     // wait until Vfs has loaded all roots
     for task in receiver {
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index b111813a7cd..ec90cb17f7c 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -19,8 +19,8 @@ use hir::db::DefDatabase;
 use ide::Change;
 use ide_db::{
     base_db::{
-        CrateGraph, Env, ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind,
-        ProcMacroLoadResult, ProcMacroPaths, ProcMacros, SourceRoot, VfsPath,
+        salsa::Durability, CrateGraph, Env, ProcMacro, ProcMacroExpander, ProcMacroExpansionError,
+        ProcMacroKind, ProcMacroLoadResult, ProcMacroPaths, ProcMacros, SourceRoot, VfsPath,
     },
     FxHashMap,
 };
@@ -88,12 +88,13 @@ impl GlobalState {
             self.reload_flycheck();
         }
 
-        if self.analysis_host.raw_database().enable_proc_attr_macros()
+        if self.analysis_host.raw_database().expand_proc_attr_macros()
             != self.config.expand_proc_attr_macros()
         {
-            self.analysis_host
-                .raw_database_mut()
-                .set_enable_proc_attr_macros(self.config.expand_proc_attr_macros());
+            self.analysis_host.raw_database_mut().set_expand_proc_attr_macros_with_durability(
+                self.config.expand_proc_attr_macros(),
+                Durability::HIGH,
+            );
         }
     }