Unnamed repository; edit this file 'description' to name the repository.
internal: move `ExpandDatabase::syntax_context` out of the query group
Ada Alakbarova 3 weeks ago
parent a775481 · commit 23b348f
-rw-r--r--crates/hir-def/src/nameres/collector.rs2
-rw-r--r--crates/hir-expand/src/db.rs15
-rw-r--r--crates/hir-expand/src/lib.rs10
3 files changed, 12 insertions, 15 deletions
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index a916cda730..95ebae2260 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -81,7 +81,7 @@ pub(super) fn collect_defs(
let proc_macros = if krate.is_proc_macro {
db.proc_macros_for_crate(def_map.krate)
.and_then(|proc_macros| {
- proc_macros.list(db.syntax_context(tree_id.file_id(), krate.edition))
+ proc_macros.list(tree_id.file_id().syntax_context(db, krate.edition))
})
.unwrap_or_default()
} else {
diff --git a/crates/hir-expand/src/db.rs b/crates/hir-expand/src/db.rs
index 33672d10fa..8b4b86c5e1 100644
--- a/crates/hir-expand/src/db.rs
+++ b/crates/hir-expand/src/db.rs
@@ -2,7 +2,7 @@
use base_db::{Crate, SourceDatabase};
use mbe::MatchedArmIndex;
-use span::{AstIdMap, Edition, Span, SyntaxContext};
+use span::{AstIdMap, Span};
use std::borrow::Cow;
use syntax::{AstNode, Parse, SyntaxError, SyntaxNode, SyntaxToken, T, ast};
use syntax_bridge::{DocCommentDesugarMode, syntax_node_to_token_tree};
@@ -136,19 +136,6 @@ pub trait ExpandDatabase: SourceDatabase {
&self,
macro_call: MacroCallId,
) -> Option<ExpandResult<Arc<[SyntaxError]>>>;
-
- #[salsa::transparent]
- fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
-}
-
-fn syntax_context(db: &dyn ExpandDatabase, file: HirFileId, edition: Edition) -> SyntaxContext {
- match file {
- HirFileId::FileId(_) => SyntaxContext::root(edition),
- HirFileId::MacroFile(m) => {
- let kind = &m.loc(db).kind;
- db.macro_arg_considering_derives(m, kind).2.ctx
- }
- }
}
fn resolve_span(db: &dyn ExpandDatabase, Span { range, anchor, ctx: _ }: Span) -> FileRange {
diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs
index 9c5714be2d..3386e2257a 100644
--- a/crates/hir-expand/src/lib.rs
+++ b/crates/hir-expand/src/lib.rs
@@ -1128,6 +1128,16 @@ impl HirFileId {
HirFileId::MacroFile(_) => None,
}
}
+
+ pub fn syntax_context(self, db: &dyn ExpandDatabase, edition: Edition) -> SyntaxContext {
+ match self {
+ HirFileId::FileId(_) => SyntaxContext::root(edition),
+ HirFileId::MacroFile(m) => {
+ let kind = &m.loc(db).kind;
+ db.macro_arg_considering_derives(m, kind).2.ctx
+ }
+ }
+ }
}
impl PartialEq<EditionedFileId> for HirFileId {