mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
Correctly set and mark the proc-macro spans
This commit is contained in:
parent
7d762d18ed
commit
1e1113cf5f
3 changed files with 14 additions and 13 deletions
|
@ -335,7 +335,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||||
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
||||||
local_inner: false,
|
local_inner: false,
|
||||||
allow_internal_unsafe: loc.allow_internal_unsafe,
|
allow_internal_unsafe: loc.allow_internal_unsafe,
|
||||||
def_site: db
|
span: db
|
||||||
.span_map(loc.id.file_id())
|
.span_map(loc.id.file_id())
|
||||||
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||||
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
kind: kind(loc.expander, loc.id.file_id(), makro.ast_id.upcast()),
|
||||||
local_inner: loc.local_inner,
|
local_inner: loc.local_inner,
|
||||||
allow_internal_unsafe: loc.allow_internal_unsafe,
|
allow_internal_unsafe: loc.allow_internal_unsafe,
|
||||||
def_site: db
|
span: db
|
||||||
.span_map(loc.id.file_id())
|
.span_map(loc.id.file_id())
|
||||||
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ fn macro_def(db: &dyn DefDatabase, id: MacroId) -> MacroDefId {
|
||||||
),
|
),
|
||||||
local_inner: false,
|
local_inner: false,
|
||||||
allow_internal_unsafe: false,
|
allow_internal_unsafe: false,
|
||||||
def_site: db
|
span: db
|
||||||
.span_map(loc.id.file_id())
|
.span_map(loc.id.file_id())
|
||||||
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
.span_for_range(db.ast_id_map(loc.id.file_id()).get(makro.ast_id).text_range()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@ use crate::{
|
||||||
builtin_attr_macro::pseudo_derive_attr_expansion,
|
builtin_attr_macro::pseudo_derive_attr_expansion,
|
||||||
builtin_fn_macro::EagerExpander,
|
builtin_fn_macro::EagerExpander,
|
||||||
fixup::{self, reverse_fixups, SyntaxFixupUndoInfo},
|
fixup::{self, reverse_fixups, SyntaxFixupUndoInfo},
|
||||||
hygiene::{apply_mark, SyntaxContextData, Transparency},
|
hygiene::{
|
||||||
|
apply_mark, span_with_call_site_ctxt, span_with_def_site_ctxt, span_with_mixed_site_ctxt,
|
||||||
|
SyntaxContextData, Transparency,
|
||||||
|
},
|
||||||
proc_macro::ProcMacros,
|
proc_macro::ProcMacros,
|
||||||
span_map::{RealSpanMap, SpanMap, SpanMapRef},
|
span_map::{RealSpanMap, SpanMap, SpanMapRef},
|
||||||
tt, AstId, BuiltinAttrExpander, BuiltinDeriveExpander, BuiltinFnLikeExpander,
|
tt, AstId, BuiltinAttrExpander, BuiltinDeriveExpander, BuiltinFnLikeExpander,
|
||||||
|
@ -307,9 +310,9 @@ pub fn expand_speculative(
|
||||||
loc.krate,
|
loc.krate,
|
||||||
&tt,
|
&tt,
|
||||||
attr_arg.as_ref(),
|
attr_arg.as_ref(),
|
||||||
loc.call_site,
|
span_with_def_site_ctxt(db, loc.def.span, actual_macro_call),
|
||||||
loc.call_site,
|
span_with_call_site_ctxt(db, loc.def.span, actual_macro_call),
|
||||||
loc.call_site,
|
span_with_mixed_site_ctxt(db, loc.def.span, actual_macro_call),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
MacroDefKind::BuiltInAttr(BuiltinAttrExpander::Derive, _) => {
|
MacroDefKind::BuiltInAttr(BuiltinAttrExpander::Derive, _) => {
|
||||||
|
@ -787,11 +790,9 @@ fn expand_proc_macro(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<A
|
||||||
loc.krate,
|
loc.krate,
|
||||||
¯o_arg,
|
¯o_arg,
|
||||||
attr_arg,
|
attr_arg,
|
||||||
// FIXME
|
span_with_def_site_ctxt(db, loc.def.span, id),
|
||||||
loc.call_site,
|
span_with_call_site_ctxt(db, loc.def.span, id),
|
||||||
loc.call_site,
|
span_with_mixed_site_ctxt(db, loc.def.span, id),
|
||||||
// FIXME
|
|
||||||
loc.call_site,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set a hard limit for the expanded tt
|
// Set a hard limit for the expanded tt
|
||||||
|
|
|
@ -179,7 +179,7 @@ pub struct MacroDefId {
|
||||||
pub kind: MacroDefKind,
|
pub kind: MacroDefKind,
|
||||||
pub local_inner: bool,
|
pub local_inner: bool,
|
||||||
pub allow_internal_unsafe: bool,
|
pub allow_internal_unsafe: bool,
|
||||||
pub def_site: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
|
Loading…
Reference in a new issue