Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/proc_macro.rs')
-rw-r--r--crates/hir-expand/src/proc_macro.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/hir-expand/src/proc_macro.rs b/crates/hir-expand/src/proc_macro.rs
index eb0af7c28c..d758e9302c 100644
--- a/crates/hir-expand/src/proc_macro.rs
+++ b/crates/hir-expand/src/proc_macro.rs
@@ -7,18 +7,16 @@ use crate::{db::ExpandDatabase, tt, ExpandError, ExpandResult};
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct ProcMacroExpander {
- krate: CrateId,
proc_macro_id: Option<ProcMacroId>,
}
impl ProcMacroExpander {
- pub fn new(krate: CrateId, proc_macro_id: ProcMacroId) -> Self {
- Self { krate, proc_macro_id: Some(proc_macro_id) }
+ pub fn new(proc_macro_id: ProcMacroId) -> Self {
+ Self { proc_macro_id: Some(proc_macro_id) }
}
- pub fn dummy(krate: CrateId) -> Self {
- // FIXME: Should store the name for better errors
- Self { krate, proc_macro_id: None }
+ pub fn dummy() -> Self {
+ Self { proc_macro_id: None }
}
pub fn is_dummy(&self) -> bool {
@@ -28,6 +26,7 @@ impl ProcMacroExpander {
pub fn expand(
self,
db: &dyn ExpandDatabase,
+ def_crate: CrateId,
calling_crate: CrateId,
tt: &tt::Subtree,
attr_arg: Option<&tt::Subtree>,
@@ -35,7 +34,7 @@ impl ProcMacroExpander {
match self.proc_macro_id {
Some(id) => {
let krate_graph = db.crate_graph();
- let proc_macros = match &krate_graph[self.krate].proc_macro {
+ let proc_macros = match &krate_graph[def_crate].proc_macro {
Ok(proc_macros) => proc_macros,
Err(_) => {
never!("Non-dummy expander even though there are no proc macros");
@@ -84,7 +83,7 @@ impl ProcMacroExpander {
}
None => ExpandResult::with_err(
tt::Subtree::empty(),
- ExpandError::UnresolvedProcMacro(self.krate),
+ ExpandError::UnresolvedProcMacro(def_crate),
),
}
}