Split out proc-macros from the CrateGraph

This commit is contained in:
Lukas Wirth 2023-03-25 16:42:52 +01:00
parent 71b23360e7
commit d154ea88f9
12 changed files with 141 additions and 176 deletions

View file

@ -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) {