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.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/hir-expand/src/declarative.rs b/crates/hir-expand/src/declarative.rs
index 9a0b218e6d..66465ce600 100644
--- a/crates/hir-expand/src/declarative.rs
+++ b/crates/hir-expand/src/declarative.rs
@@ -2,7 +2,8 @@
use std::sync::OnceLock;
use base_db::{CrateId, VersionReq};
-use span::{MacroCallId, Span, SyntaxContextId};
+use span::{Edition, MacroCallId, Span, SyntaxContextId};
+use stdx::TupleExt;
use syntax::{ast, AstNode};
use triomphe::Arc;
@@ -30,7 +31,7 @@ impl DeclarativeMacroExpander {
tt: tt::Subtree,
call_id: MacroCallId,
span: Span,
- ) -> ExpandResult<tt::Subtree> {
+ ) -> ExpandResult<(tt::Subtree, Option<u32>)> {
let loc = db.lookup_intern_macro_call(call_id);
let toolchain = db.toolchain(loc.def.krate);
let new_meta_vars = toolchain.as_ref().map_or(false, |version| {
@@ -46,7 +47,7 @@ impl DeclarativeMacroExpander {
});
match self.mac.err() {
Some(_) => ExpandResult::new(
- tt::Subtree::empty(tt::DelimSpan { open: span, close: span }),
+ (tt::Subtree::empty(tt::DelimSpan { open: span, close: span }), None),
ExpandError::MacroDefinition,
),
None => self
@@ -56,6 +57,7 @@ impl DeclarativeMacroExpander {
|s| s.ctx = apply_mark(db, s.ctx, call_id, self.transparency),
new_meta_vars,
span,
+ loc.def.edition,
)
.map_err(Into::into),
}
@@ -67,6 +69,7 @@ impl DeclarativeMacroExpander {
tt: tt::Subtree,
krate: CrateId,
call_site: Span,
+ def_site_edition: Edition,
) -> ExpandResult<tt::Subtree> {
let toolchain = db.toolchain(krate);
let new_meta_vars = toolchain.as_ref().map_or(false, |version| {
@@ -85,7 +88,11 @@ impl DeclarativeMacroExpander {
tt::Subtree::empty(tt::DelimSpan { open: call_site, close: call_site }),
ExpandError::MacroDefinition,
),
- None => self.mac.expand(&tt, |_| (), new_meta_vars, call_site).map_err(Into::into),
+ None => self
+ .mac
+ .expand(&tt, |_| (), new_meta_vars, call_site, def_site_edition)
+ .map(TupleExt::head)
+ .map_err(Into::into),
}
}