Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e244942

Browse files
committed
internal: Set Durability to HIGH for enable_proc_attr_macros input
1 parent 5390949 commit e244942

File tree

11 files changed

+33
-28
lines changed

11 files changed

+33
-28
lines changed

crates/hir-def/src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl<'a> AssocItemCollector<'a> {
590590
) {
591591
self.attr_calls.push((ast_id, call_id));
592592
// If proc attribute macro expansion is disabled, skip expanding it here
593-
if !self.db.enable_proc_attr_macros() {
593+
if !self.db.expand_proc_attr_macros() {
594594
continue 'attrs;
595595
}
596596
let loc = self.db.lookup_intern_macro_call(call_id);

crates/hir-def/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub trait InternDatabase: SourceDatabase {
6666
#[salsa::query_group(DefDatabaseStorage)]
6767
pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDatabase> {
6868
#[salsa::input]
69-
fn enable_proc_attr_macros(&self) -> bool;
69+
fn expand_proc_attr_macros(&self) -> bool;
7070

7171
#[salsa::invoke(ItemTree::file_item_tree_query)]
7272
fn file_item_tree(&self, file_id: HirFileId) -> Arc<ItemTree>;

crates/hir-def/src/nameres/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ impl DefCollector<'_> {
12821282
let loc: MacroCallLoc = self.db.lookup_intern_macro_call(call_id);
12831283

12841284
// If proc attribute macro expansion is disabled, skip expanding it here
1285-
if !self.db.enable_proc_attr_macros() {
1285+
if !self.db.expand_proc_attr_macros() {
12861286
self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro(
12871287
directive.module_id,
12881288
loc.kind,

crates/hir-def/src/test_db.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ use std::{
66
};
77

88
use base_db::{
9-
salsa, AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, FilePosition,
10-
SourceDatabase, Upcast,
9+
salsa::{self, Durability},
10+
AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, FilePosition, SourceDatabase,
11+
Upcast,
1112
};
1213
use hir_expand::{db::ExpandDatabase, InFile};
1314
use stdx::hash::NoHashHashSet;
@@ -35,7 +36,7 @@ pub(crate) struct TestDB {
3536
impl Default for TestDB {
3637
fn default() -> Self {
3738
let mut this = Self { storage: Default::default(), events: Default::default() };
38-
this.set_enable_proc_attr_macros(true);
39+
this.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
3940
this
4041
}
4142
}

crates/hir-ty/src/test_db.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use std::{
66
};
77

88
use base_db::{
9-
salsa, AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
9+
salsa::{self, Durability},
10+
AnchoredPath, CrateId, FileId, FileLoader, FileLoaderDelegate, SourceDatabase, Upcast,
1011
};
1112
use hir_def::{db::DefDatabase, ModuleId};
1213
use hir_expand::db::ExpandDatabase;
@@ -30,7 +31,7 @@ pub(crate) struct TestDB {
3031
impl Default for TestDB {
3132
fn default() -> Self {
3233
let mut this = Self { storage: Default::default(), events: Default::default() };
33-
this.set_enable_proc_attr_macros(true);
34+
this.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
3435
this
3536
}
3637
}

crates/ide-assists/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod generated;
33
mod sourcegen;
44

55
use expect_test::expect;
6-
use hir::{db::DefDatabase, Semantics};
6+
use hir::Semantics;
77
use ide_db::{
88
base_db::{fixture::WithFixture, FileId, FileRange, SourceDatabaseExt},
99
imports::insert_use::{ImportGranularity, InsertUseConfig},
@@ -161,7 +161,7 @@ fn check_with_config(
161161
assist_label: Option<&str>,
162162
) {
163163
let (mut db, file_with_caret_id, range_or_offset) = RootDatabase::with_range_or_offset(before);
164-
db.set_enable_proc_attr_macros(true);
164+
db.enable_proc_attr_macros();
165165
let text_without_caret = db.file_text(file_with_caret_id).to_string();
166166

167167
let frange = FileRange { file_id: file_with_caret_id, range: range_or_offset.into() };

crates/ide-completion/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod type_pos;
2323
mod use_tree;
2424
mod visibility;
2525

26-
use hir::{db::DefDatabase, PrefixKind};
26+
use hir::PrefixKind;
2727
use ide_db::{
2828
base_db::{fixture::ChangeFixture, FileLoader, FilePosition},
2929
imports::insert_use::{ImportGranularity, InsertUseConfig},
@@ -120,7 +120,7 @@ fn completion_list_with_config(
120120
pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
121121
let change_fixture = ChangeFixture::parse(ra_fixture);
122122
let mut database = RootDatabase::default();
123-
database.set_enable_proc_attr_macros(true);
123+
database.enable_proc_attr_macros();
124124
database.apply_change(change_fixture.change);
125125
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
126126
let offset = range_or_offset.expect_offset();

crates/ide-db/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,15 @@ impl RootDatabase {
140140
db.set_proc_macros_with_durability(Default::default(), Durability::HIGH);
141141
db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
142142
db.set_library_roots_with_durability(Default::default(), Durability::HIGH);
143-
db.set_enable_proc_attr_macros(false);
143+
db.set_expand_proc_attr_macros_with_durability(false, Durability::HIGH);
144144
db.update_parse_query_lru_capacity(lru_capacity);
145145
db
146146
}
147147

148+
pub fn enable_proc_attr_macros(&mut self) {
149+
self.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
150+
}
151+
148152
pub fn update_parse_query_lru_capacity(&mut self, lru_capacity: Option<usize>) {
149153
let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP);
150154
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);

crates/ide/src/fixture.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Utilities for creating `Analysis` instances for tests.
2-
use hir::db::DefDatabase;
32
use ide_db::base_db::fixture::ChangeFixture;
43
use test_utils::{extract_annotations, RangeOrOffset};
54

@@ -9,7 +8,7 @@ use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange};
98
pub(crate) fn file(ra_fixture: &str) -> (Analysis, FileId) {
109
let mut host = AnalysisHost::default();
1110
let change_fixture = ChangeFixture::parse(ra_fixture);
12-
host.db.set_enable_proc_attr_macros(true);
11+
host.db.enable_proc_attr_macros();
1312
host.db.apply_change(change_fixture.change);
1413
(host.analysis(), change_fixture.files[0])
1514
}
@@ -18,7 +17,7 @@ pub(crate) fn file(ra_fixture: &str) -> (Analysis, FileId) {
1817
pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) {
1918
let mut host = AnalysisHost::default();
2019
let change_fixture = ChangeFixture::parse(ra_fixture);
21-
host.db.set_enable_proc_attr_macros(true);
20+
host.db.enable_proc_attr_macros();
2221
host.db.apply_change(change_fixture.change);
2322
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
2423
let offset = range_or_offset.expect_offset();
@@ -29,7 +28,7 @@ pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) {
2928
pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) {
3029
let mut host = AnalysisHost::default();
3130
let change_fixture = ChangeFixture::parse(ra_fixture);
32-
host.db.set_enable_proc_attr_macros(true);
31+
host.db.enable_proc_attr_macros();
3332
host.db.apply_change(change_fixture.change);
3433
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
3534
let range = range_or_offset.expect_range();
@@ -40,7 +39,7 @@ pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) {
4039
pub(crate) fn range_or_position(ra_fixture: &str) -> (Analysis, FileId, RangeOrOffset) {
4140
let mut host = AnalysisHost::default();
4241
let change_fixture = ChangeFixture::parse(ra_fixture);
43-
host.db.set_enable_proc_attr_macros(true);
42+
host.db.enable_proc_attr_macros();
4443
host.db.apply_change(change_fixture.change);
4544
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
4645
(host.analysis(), file_id, range_or_offset)
@@ -50,7 +49,7 @@ pub(crate) fn range_or_position(ra_fixture: &str) -> (Analysis, FileId, RangeOrO
5049
pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(FileRange, String)>) {
5150
let mut host = AnalysisHost::default();
5251
let change_fixture = ChangeFixture::parse(ra_fixture);
53-
host.db.set_enable_proc_attr_macros(true);
52+
host.db.enable_proc_attr_macros();
5453
host.db.apply_change(change_fixture.change);
5554
let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker ($0)");
5655
let offset = range_or_offset.expect_offset();
@@ -71,7 +70,7 @@ pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(Fil
7170
pub(crate) fn annotations_without_marker(ra_fixture: &str) -> (Analysis, Vec<(FileRange, String)>) {
7271
let mut host = AnalysisHost::default();
7372
let change_fixture = ChangeFixture::parse(ra_fixture);
74-
host.db.set_enable_proc_attr_macros(true);
73+
host.db.enable_proc_attr_macros();
7574
host.db.apply_change(change_fixture.change);
7675

7776
let annotations = change_fixture

crates/rust-analyzer/src/cli/load_cargo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{convert::identity, path::Path, sync::Arc};
44

55
use anyhow::Result;
66
use crossbeam_channel::{unbounded, Receiver};
7-
use hir::db::DefDatabase;
87
use ide::{AnalysisHost, Change};
98
use ide_db::{
109
base_db::{CrateGraph, ProcMacros},
@@ -143,7 +142,7 @@ fn load_crate_graph(
143142
let mut host = AnalysisHost::new(lru_cap);
144143
let mut analysis_change = Change::new();
145144

146-
host.raw_database_mut().set_enable_proc_attr_macros(true);
145+
host.raw_database_mut().enable_proc_attr_macros();
147146

148147
// wait until Vfs has loaded all roots
149148
for task in receiver {

crates/rust-analyzer/src/reload.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use hir::db::DefDatabase;
1919
use ide::Change;
2020
use ide_db::{
2121
base_db::{
22-
CrateGraph, Env, ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind,
23-
ProcMacroLoadResult, ProcMacroPaths, ProcMacros, SourceRoot, VfsPath,
22+
salsa::Durability, CrateGraph, Env, ProcMacro, ProcMacroExpander, ProcMacroExpansionError,
23+
ProcMacroKind, ProcMacroLoadResult, ProcMacroPaths, ProcMacros, SourceRoot, VfsPath,
2424
},
2525
FxHashMap,
2626
};
@@ -88,12 +88,13 @@ impl GlobalState {
8888
self.reload_flycheck();
8989
}
9090

91-
if self.analysis_host.raw_database().enable_proc_attr_macros()
91+
if self.analysis_host.raw_database().expand_proc_attr_macros()
9292
!= self.config.expand_proc_attr_macros()
9393
{
94-
self.analysis_host
95-
.raw_database_mut()
96-
.set_enable_proc_attr_macros(self.config.expand_proc_attr_macros());
94+
self.analysis_host.raw_database_mut().set_expand_proc_attr_macros_with_durability(
95+
self.config.expand_proc_attr_macros(),
96+
Durability::HIGH,
97+
);
9798
}
9899
}
99100

0 commit comments

Comments
 (0)