Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/project-model/src/workspace.rs')
-rw-r--r--crates/project-model/src/workspace.rs32
1 files changed, 29 insertions, 3 deletions
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index a345c6bcce..465a1ad0ec 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -63,6 +63,8 @@ pub struct ProjectWorkspace {
pub target_layout: TargetLayoutLoadResult,
/// A set of cfg overrides for this workspace.
pub cfg_overrides: CfgOverrides,
+ /// Additional includes to add for the VFS.
+ pub extra_includes: Vec<AbsPathBuf>,
}
#[derive(Clone)]
@@ -104,7 +106,15 @@ pub enum ProjectWorkspaceKind {
impl fmt::Debug for ProjectWorkspace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Make sure this isn't too verbose.
- let Self { kind, sysroot, rustc_cfg, toolchain, target_layout, cfg_overrides } = self;
+ let Self {
+ kind,
+ sysroot,
+ rustc_cfg,
+ toolchain,
+ target_layout,
+ cfg_overrides,
+ extra_includes,
+ } = self;
match kind {
ProjectWorkspaceKind::Cargo { cargo, error: _, build_scripts, rustc, set_test } => f
.debug_struct("Cargo")
@@ -117,6 +127,7 @@ impl fmt::Debug for ProjectWorkspace {
)
.field("n_rustc_cfg", &rustc_cfg.len())
.field("n_cfg_overrides", &cfg_overrides.len())
+ .field("n_extra_includes", &extra_includes.len())
.field("toolchain", &toolchain)
.field("data_layout", &target_layout)
.field("set_test", set_test)
@@ -130,7 +141,8 @@ impl fmt::Debug for ProjectWorkspace {
.field("n_rustc_cfg", &rustc_cfg.len())
.field("toolchain", &toolchain)
.field("data_layout", &target_layout)
- .field("n_cfg_overrides", &cfg_overrides.len());
+ .field("n_cfg_overrides", &cfg_overrides.len())
+ .field("n_extra_includes", &extra_includes.len());
debug_struct.finish()
}
@@ -144,6 +156,7 @@ impl fmt::Debug for ProjectWorkspace {
.field("toolchain", &toolchain)
.field("data_layout", &target_layout)
.field("n_cfg_overrides", &cfg_overrides.len())
+ .field("n_extra_includes", &extra_includes.len())
.field("set_test", set_test)
.finish(),
}
@@ -320,6 +333,7 @@ impl ProjectWorkspace {
cfg_overrides,
toolchain,
target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())),
+ extra_includes: config.extra_includes.clone(),
})
}
@@ -340,6 +354,7 @@ impl ProjectWorkspace {
toolchain,
target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())),
cfg_overrides: config.cfg_overrides.clone(),
+ extra_includes: config.extra_includes.clone(),
}
}
@@ -399,6 +414,7 @@ impl ProjectWorkspace {
toolchain,
target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())),
cfg_overrides: config.cfg_overrides.clone(),
+ extra_includes: config.extra_includes.clone(),
})
}
@@ -565,7 +581,13 @@ impl ProjectWorkspace {
PackageRoot {
is_local: krate.is_workspace_member,
- include: krate.include.iter().cloned().chain(build_file).collect(),
+ include: krate
+ .include
+ .iter()
+ .cloned()
+ .chain(build_file)
+ .chain(self.extra_includes.iter().cloned())
+ .collect(),
exclude: krate.exclude.clone(),
}
})
@@ -603,6 +625,8 @@ impl ProjectWorkspace {
let mut exclude = vec![pkg_root.join(".git")];
if is_local {
+ include.extend(self.extra_includes.iter().cloned());
+
exclude.push(pkg_root.join("target"));
} else {
exclude.push(pkg_root.join("tests"));
@@ -661,6 +685,8 @@ impl ProjectWorkspace {
let mut exclude = vec![pkg_root.join(".git")];
if is_local {
+ include.extend(self.extra_includes.iter().cloned());
+
exclude.push(pkg_root.join("target"));
} else {
exclude.push(pkg_root.join("tests"));