Skip to content

Commit 1e1113c

Browse files
committed
Correctly set and mark the proc-macro spans
1 parent 7d762d1 commit 1e1113c

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

crates/hir-def/src/db.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
335335
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
336336
local_inner: false,
337337
allow_internal_unsafe: loc.allow_internal_unsafe,
338-
def_site: db
338+
span: db
339339
.span_map(loc.id.file_id())
340340
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
341341
}
@@ -350,7 +350,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
350350
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
351351
local_inner: loc.local_inner,
352352
allow_internal_unsafe: loc.allow_internal_unsafe,
353-
def_site: db
353+
span: db
354354
.span_map(loc.id.file_id())
355355
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
356356
}
@@ -369,7 +369,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
369369
),
370370
local_inner: false,
371371
allow_internal_unsafe: false,
372-
def_site: db
372+
span: db
373373
.span_map(loc.id.file_id())
374374
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
375375
}

crates/hir-expand/src/db.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ use crate::{
2323
builtin_attr_macro::pseudo_derive_attr_expansion,
2424
builtin_fn_macro::EagerExpander,
2525
fixup::{self, reverse_fixups, SyntaxFixupUndoInfo},
26-
hygiene::{apply_mark, SyntaxContextData, Transparency},
26+
hygiene::{
27+
apply_mark, span_with_call_site_ctxt, span_with_def_site_ctxt, span_with_mixed_site_ctxt,
28+
SyntaxContextData, Transparency,
29+
},
2730
proc_macro::ProcMacros,
2831
span_map::{RealSpanMap, SpanMap, SpanMapRef},
2932
tt, AstId, BuiltinAttrExpander, BuiltinDeriveExpander, BuiltinFnLikeExpander,
@@ -307,9 +310,9 @@ pub fn expand_speculative(
307310
loc.krate,
308311
&tt,
309312
attr_arg.as_ref(),
310-
loc.call_site,
311-
loc.call_site,
312-
loc.call_site,
313+
span_with_def_site_ctxt(db, loc.def.span, actual_macro_call),
314+
span_with_call_site_ctxt(db, loc.def.span, actual_macro_call),
315+
span_with_mixed_site_ctxt(db, loc.def.span, actual_macro_call),
313316
)
314317
}
315318
MacroDefKind::BuiltInAttr(BuiltinAttrExpander::Derive, _) => {
@@ -787,11 +790,9 @@ fn expand_proc_macro(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<A
787790
loc.krate,
788791
&macro_arg,
789792
attr_arg,
790-
// FIXME
791-
loc.call_site,
792-
loc.call_site,
793-
// FIXME
794-
loc.call_site,
793+
span_with_def_site_ctxt(db, loc.def.span, id),
794+
span_with_call_site_ctxt(db, loc.def.span, id),
795+
span_with_mixed_site_ctxt(db, loc.def.span, id),
795796
);
796797

797798
// Set a hard limit for the expanded tt

crates/hir-expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub struct MacroDefId {
179179
pub kind: MacroDefKind,
180180
pub local_inner: bool,
181181
pub allow_internal_unsafe: bool,
182-
pub def_site: Span,
182+
pub span: Span,
183183
}
184184

185185
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

0 commit comments

Comments
 (0)