mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
commit
5945ef9946
2 changed files with 11 additions and 16 deletions
|
@ -173,7 +173,7 @@ fn make_hygiene_info(
|
||||||
db: &dyn ExpandDatabase,
|
db: &dyn ExpandDatabase,
|
||||||
macro_file: MacroFile,
|
macro_file: MacroFile,
|
||||||
loc: &MacroCallLoc,
|
loc: &MacroCallLoc,
|
||||||
) -> Option<HygieneInfo> {
|
) -> HygieneInfo {
|
||||||
let def = loc.def.ast_id().left().and_then(|id| {
|
let def = loc.def.ast_id().left().and_then(|id| {
|
||||||
let def_tt = match id.to_node(db) {
|
let def_tt = match id.to_node(db) {
|
||||||
ast::Macro::MacroRules(mac) => mac.token_tree()?,
|
ast::Macro::MacroRules(mac) => mac.token_tree()?,
|
||||||
|
@ -204,7 +204,7 @@ fn make_hygiene_info(
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(HygieneInfo {
|
HygieneInfo {
|
||||||
file: macro_file,
|
file: macro_file,
|
||||||
attr_input_or_mac_def_start: attr_input_or_mac_def
|
attr_input_or_mac_def_start: attr_input_or_mac_def
|
||||||
.map(|it| it.map(|tt| tt.syntax().text_range().start())),
|
.map(|it| it.map(|tt| tt.syntax().text_range().start())),
|
||||||
|
@ -212,7 +212,7 @@ fn make_hygiene_info(
|
||||||
macro_arg,
|
macro_arg,
|
||||||
macro_def,
|
macro_def,
|
||||||
exp_map,
|
exp_map,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HygieneFrame {
|
impl HygieneFrame {
|
||||||
|
@ -221,8 +221,7 @@ impl HygieneFrame {
|
||||||
None => (None, None, false),
|
None => (None, None, false),
|
||||||
Some(macro_file) => {
|
Some(macro_file) => {
|
||||||
let loc = db.lookup_intern_macro_call(macro_file.macro_call_id);
|
let loc = db.lookup_intern_macro_call(macro_file.macro_call_id);
|
||||||
let info =
|
let info = Some((make_hygiene_info(db, macro_file, &loc), loc.kind.file_id()));
|
||||||
make_hygiene_info(db, macro_file, &loc).map(|info| (loc.kind.file_id(), info));
|
|
||||||
match loc.def.kind {
|
match loc.def.kind {
|
||||||
MacroDefKind::Declarative(_) => {
|
MacroDefKind::Declarative(_) => {
|
||||||
(info, Some(loc.def.krate), loc.def.local_inner)
|
(info, Some(loc.def.krate), loc.def.local_inner)
|
||||||
|
@ -236,17 +235,14 @@ impl HygieneFrame {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let (calling_file, info) = match info {
|
let Some((info, calling_file)) = info else {
|
||||||
None => {
|
return HygieneFrame {
|
||||||
return HygieneFrame {
|
expansion: None,
|
||||||
expansion: None,
|
local_inner,
|
||||||
local_inner,
|
krate,
|
||||||
krate,
|
call_site: None,
|
||||||
call_site: None,
|
def_site: None,
|
||||||
def_site: None,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
Some(it) => it,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let def_site = info.attr_input_or_mac_def_start.map(|it| db.hygiene_frame(it.file_id));
|
let def_site = info.attr_input_or_mac_def_start.map(|it| db.hygiene_frame(it.file_id));
|
||||||
|
|
|
@ -28,7 +28,6 @@ use crate::{
|
||||||
tt_iter::TtIter,
|
tt_iter::TtIter,
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: we probably should re-think `token_tree_to_syntax_node` interfaces
|
|
||||||
pub use self::tt::{Delimiter, DelimiterKind, Punct};
|
pub use self::tt::{Delimiter, DelimiterKind, Punct};
|
||||||
pub use ::parser::TopEntryPoint;
|
pub use ::parser::TopEntryPoint;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue