mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Split out proc-macros from the CrateGraph
This commit is contained in:
parent
71b23360e7
commit
d154ea88f9
12 changed files with 141 additions and 176 deletions
|
@ -33,10 +33,10 @@ impl ProcMacroExpander {
|
|||
) -> ExpandResult<tt::Subtree> {
|
||||
match self.proc_macro_id {
|
||||
Some(id) => {
|
||||
let krate_graph = db.crate_graph();
|
||||
let proc_macros = match &krate_graph[def_crate].proc_macro {
|
||||
Ok(proc_macros) => proc_macros,
|
||||
Err(_) => {
|
||||
let proc_macros = db.proc_macros();
|
||||
let proc_macros = match proc_macros.get(&def_crate) {
|
||||
Some(Ok(proc_macros)) => proc_macros,
|
||||
Some(Err(_)) | None => {
|
||||
never!("Non-dummy expander even though there are no proc macros");
|
||||
return ExpandResult::with_err(
|
||||
tt::Subtree::empty(),
|
||||
|
@ -59,6 +59,7 @@ impl ProcMacroExpander {
|
|||
}
|
||||
};
|
||||
|
||||
let krate_graph = db.crate_graph();
|
||||
// Proc macros have access to the environment variables of the invoking crate.
|
||||
let env = &krate_graph[calling_crate].env;
|
||||
match proc_macro.expander.expand(tt, attr_arg, env) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue