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.rs29
1 files changed, 12 insertions, 17 deletions
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index 43388e915b..9580b76faa 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -6,14 +6,17 @@
//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
//! actual IO is done and lowered to input.
-use std::{fmt, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
+use std::{fmt, mem, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
use cfg::CfgOptions;
use rustc_hash::FxHashMap;
use stdx::hash::{NoHashHashMap, NoHashHashSet};
use syntax::SmolStr;
use tt::token_id::Subtree;
-use vfs::{file_set::FileSet, AnchoredPath, FileId, VfsPath};
+use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
+
+pub type ProcMacroPaths = FxHashMap<CrateId, Result<(Option<String>, AbsPathBuf), String>>;
+pub type ProcMacros = FxHashMap<CrateId, ProcMacroLoadResult>;
/// Files are grouped into source roots. A source root is a directory on the
/// file systems which is watched for changes. Typically it corresponds to a
@@ -269,7 +272,6 @@ pub struct CrateData {
pub target_layout: TargetLayoutLoadResult,
pub env: Env,
pub dependencies: Vec<Dependency>,
- pub proc_macro: ProcMacroLoadResult,
pub origin: CrateOrigin,
pub is_proc_macro: bool,
}
@@ -322,7 +324,6 @@ impl CrateGraph {
cfg_options: CfgOptions,
potential_cfg_options: CfgOptions,
env: Env,
- proc_macro: ProcMacroLoadResult,
is_proc_macro: bool,
origin: CrateOrigin,
target_layout: Result<Arc<str>, Arc<str>>,
@@ -335,7 +336,6 @@ impl CrateGraph {
cfg_options,
potential_cfg_options,
env,
- proc_macro,
dependencies: Vec::new(),
origin,
target_layout,
@@ -456,11 +456,11 @@ impl CrateGraph {
}
/// Extends this crate graph by adding a complete disjoint second crate
- /// graph.
+ /// graph and adjust the ids in the [`ProcMacroPaths`] accordingly.
///
/// The ids of the crates in the `other` graph are shifted by the return
/// amount.
- pub fn extend(&mut self, other: CrateGraph) -> u32 {
+ pub fn extend(&mut self, other: CrateGraph, proc_macros: &mut ProcMacroPaths) -> u32 {
let start = self.arena.len() as u32;
self.arena.extend(other.arena.into_iter().map(|(id, mut data)| {
let new_id = id.shift(start);
@@ -469,6 +469,11 @@ impl CrateGraph {
}
(new_id, data)
}));
+
+ *proc_macros = mem::take(proc_macros)
+ .into_iter()
+ .map(|(id, macros)| (id.shift(start), macros))
+ .collect();
start
}
@@ -645,7 +650,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -658,7 +662,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -671,7 +674,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -698,7 +700,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -711,7 +712,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -735,7 +735,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -748,7 +747,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -761,7 +759,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -785,7 +782,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),
@@ -798,7 +794,6 @@ mod tests {
CfgOptions::default(),
CfgOptions::default(),
Env::default(),
- Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
Err("".into()),