Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/base-db/src/input.rs')
-rw-r--r--crates/base-db/src/input.rs39
1 files changed, 24 insertions, 15 deletions
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index e4f78321e2..c2472363aa 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -13,9 +13,10 @@ use la_arena::{Arena, Idx};
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::SmolStr;
use triomphe::Arc;
-use tt::token_id::Subtree;
use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
+use crate::span::SpanData;
+
// Map from crate id to the name of the crate and path of the proc-macro. If the value is `None`,
// then the crate for the proc-macro hasn't been build yet as the build data is missing.
pub type ProcMacroPaths = FxHashMap<CrateId, Result<(Option<String>, AbsPathBuf), String>>;
@@ -242,6 +243,9 @@ impl CrateDisplayName {
}
}
+// FIXME: These should not be defined in here? Why does base db know about proc-macros
+// ProcMacroKind is used in [`fixture`], but that module probably shouldn't be in this crate either.
+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ProcMacroId(pub u32);
@@ -255,10 +259,13 @@ pub enum ProcMacroKind {
pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe {
fn expand(
&self,
- subtree: &Subtree,
- attrs: Option<&Subtree>,
+ subtree: &tt::Subtree<SpanData>,
+ attrs: Option<&tt::Subtree<SpanData>>,
env: &Env,
- ) -> Result<Subtree, ProcMacroExpansionError>;
+ def_site: SpanData,
+ call_site: SpanData,
+ mixed_site: SpanData,
+ ) -> Result<tt::Subtree<SpanData>, ProcMacroExpansionError>;
}
#[derive(Debug)]
@@ -323,7 +330,9 @@ pub struct CrateData {
pub dependencies: Vec<Dependency>,
pub origin: CrateOrigin,
pub is_proc_macro: bool,
- // FIXME: These things should not be per crate! These are more per workspace crate graph level things
+ // FIXME: These things should not be per crate! These are more per workspace crate graph level
+ // things. This info does need to be somewhat present though as to prevent deduplication from
+ // happening across different workspaces with different layouts.
pub target_layout: TargetLayoutLoadResult,
pub channel: Option<ReleaseChannel>,
}
@@ -871,7 +880,7 @@ mod tests {
fn detect_cyclic_dependency_indirect() {
let mut graph = CrateGraph::default();
let crate1 = graph.add_crate_root(
- FileId(1u32),
+ FileId::from_raw(1u32),
Edition2018,
None,
None,
@@ -884,7 +893,7 @@ mod tests {
None,
);
let crate2 = graph.add_crate_root(
- FileId(2u32),
+ FileId::from_raw(2u32),
Edition2018,
None,
None,
@@ -897,7 +906,7 @@ mod tests {
None,
);
let crate3 = graph.add_crate_root(
- FileId(3u32),
+ FileId::from_raw(3u32),
Edition2018,
None,
None,
@@ -933,7 +942,7 @@ mod tests {
fn detect_cyclic_dependency_direct() {
let mut graph = CrateGraph::default();
let crate1 = graph.add_crate_root(
- FileId(1u32),
+ FileId::from_raw(1u32),
Edition2018,
None,
None,
@@ -946,7 +955,7 @@ mod tests {
None,
);
let crate2 = graph.add_crate_root(
- FileId(2u32),
+ FileId::from_raw(2u32),
Edition2018,
None,
None,
@@ -976,7 +985,7 @@ mod tests {
fn it_works() {
let mut graph = CrateGraph::default();
let crate1 = graph.add_crate_root(
- FileId(1u32),
+ FileId::from_raw(1u32),
Edition2018,
None,
None,
@@ -989,7 +998,7 @@ mod tests {
None,
);
let crate2 = graph.add_crate_root(
- FileId(2u32),
+ FileId::from_raw(2u32),
Edition2018,
None,
None,
@@ -1002,7 +1011,7 @@ mod tests {
None,
);
let crate3 = graph.add_crate_root(
- FileId(3u32),
+ FileId::from_raw(3u32),
Edition2018,
None,
None,
@@ -1032,7 +1041,7 @@ mod tests {
fn dashes_are_normalized() {
let mut graph = CrateGraph::default();
let crate1 = graph.add_crate_root(
- FileId(1u32),
+ FileId::from_raw(1u32),
Edition2018,
None,
None,
@@ -1045,7 +1054,7 @@ mod tests {
None,
);
let crate2 = graph.add_crate_root(
- FileId(2u32),
+ FileId::from_raw(2u32),
Edition2018,
None,
None,