summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs')
-rw-r--r--src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs b/src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs
index 3f4d2540c..d758e9302 100644
--- a/src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs
+++ b/src/tools/rust-analyzer/crates/hir-expand/src/proc_macro.rs
@@ -3,22 +3,20 @@
use base_db::{CrateId, ProcMacroExpansionError, ProcMacroId, ProcMacroKind};
use stdx::never;
-use crate::{db::AstDatabase, tt, ExpandError, ExpandResult};
+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 {
@@ -27,7 +25,8 @@ impl ProcMacroExpander {
pub fn expand(
self,
- db: &dyn AstDatabase,
+ 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),
),
}
}