Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/declarative.rs')
-rw-r--r--crates/hir-expand/src/declarative.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/hir-expand/src/declarative.rs b/crates/hir-expand/src/declarative.rs
index 4b2c6e7351..99db0dbcb9 100644
--- a/crates/hir-expand/src/declarative.rs
+++ b/crates/hir-expand/src/declarative.rs
@@ -10,7 +10,6 @@ use syntax::{
ast::{self, HasAttrs},
};
use syntax_bridge::DocCommentDesugarMode;
-use triomphe::Arc;
use crate::{
AstId, ExpandError, ExpandErrorKind, ExpandResult, HirFileId, Lookup, MacroCallId,
@@ -37,7 +36,7 @@ impl DeclarativeMacroExpander {
call_id: MacroCallId,
span: Span,
) -> ExpandResult<(tt::TopSubtree, Option<u32>)> {
- let loc = db.lookup_intern_macro_call(call_id);
+ let loc = call_id.loc(db);
match self.mac.err() {
Some(_) => ExpandResult::new(
(tt::TopSubtree::empty(tt::DelimSpan { open: span, close: span }), None),
@@ -78,12 +77,16 @@ impl DeclarativeMacroExpander {
.map_err(Into::into),
}
}
+}
+#[salsa::tracked]
+impl DeclarativeMacroExpander {
+ #[salsa::tracked(returns(ref))]
pub(crate) fn expander(
db: &dyn ExpandDatabase,
def_crate: Crate,
id: AstId<ast::Macro>,
- ) -> Arc<DeclarativeMacroExpander> {
+ ) -> DeclarativeMacroExpander {
let (root, map) = crate::db::parse_with_map(db, id.file_id);
let root = root.syntax_node();
@@ -117,8 +120,7 @@ impl DeclarativeMacroExpander {
def_crate.data(db).edition
} else {
// UNWRAP-SAFETY: Only the root context has no outer expansion
- let krate =
- db.lookup_intern_macro_call(ctx.outer_expn(db).unwrap().into()).def.krate;
+ let krate = crate::MacroCallId::from(ctx.outer_expn(db).unwrap()).loc(db).def.krate;
krate.data(db).edition
}
};
@@ -128,7 +130,7 @@ impl DeclarativeMacroExpander {
Some(arg) => {
let tt = syntax_bridge::syntax_node_to_token_tree(
arg.syntax(),
- map.as_ref(),
+ map,
map.span_for_range(
macro_rules.macro_rules_token().unwrap().text_range(),
),
@@ -152,14 +154,14 @@ impl DeclarativeMacroExpander {
let args = macro_def.args().map(|args| {
syntax_bridge::syntax_node_to_token_tree(
args.syntax(),
- map.as_ref(),
+ map,
span,
DocCommentDesugarMode::Mbe,
)
});
let body = syntax_bridge::syntax_node_to_token_tree(
body.syntax(),
- map.as_ref(),
+ map,
span,
DocCommentDesugarMode::Mbe,
);
@@ -177,6 +179,6 @@ impl DeclarativeMacroExpander {
HirFileId::MacroFile(macro_file) => macro_file.lookup(db).ctxt,
HirFileId::FileId(file) => SyntaxContext::root(file.edition(db)),
});
- Arc::new(DeclarativeMacroExpander { mac, transparency, edition })
+ DeclarativeMacroExpander { mac, transparency, edition }
}
}