mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
fix: Fix sourceroot construction for virtual manifests
This commit is contained in:
parent
b707b5a117
commit
ab46e97188
7 changed files with 75 additions and 75 deletions
|
@ -11,8 +11,9 @@ use base_db::{
|
|||
};
|
||||
use cfg::{CfgAtom, CfgDiff, CfgOptions};
|
||||
use intern::{sym, Symbol};
|
||||
use itertools::Itertools;
|
||||
use paths::{AbsPath, AbsPathBuf};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustc_hash::FxHashMap;
|
||||
use semver::Version;
|
||||
use span::{Edition, FileId};
|
||||
use toolchain::Tool;
|
||||
|
@ -41,7 +42,9 @@ pub type FileLoader<'a> = &'a mut dyn for<'b> FnMut(&'b AbsPath) -> Option<FileI
|
|||
pub struct PackageRoot {
|
||||
/// Is from the local filesystem and may be edited
|
||||
pub is_local: bool,
|
||||
/// Directories to include
|
||||
pub include: Vec<AbsPathBuf>,
|
||||
/// Directories to exclude
|
||||
pub exclude: Vec<AbsPathBuf>,
|
||||
}
|
||||
|
||||
|
@ -553,17 +556,6 @@ impl ProjectWorkspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn buildfiles(&self) -> Vec<AbsPathBuf> {
|
||||
match &self.kind {
|
||||
ProjectWorkspaceKind::Json(project) => project
|
||||
.crates()
|
||||
.filter_map(|(_, krate)| krate.build.as_ref().map(|build| build.build_file.clone()))
|
||||
.map(|build_file| self.workspace_root().join(build_file))
|
||||
.collect(),
|
||||
_ => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_sysroot_proc_macro_srv(&self) -> anyhow::Result<AbsPathBuf> {
|
||||
self.sysroot.discover_proc_macro_srv()
|
||||
}
|
||||
|
@ -608,15 +600,25 @@ impl ProjectWorkspace {
|
|||
match &self.kind {
|
||||
ProjectWorkspaceKind::Json(project) => project
|
||||
.crates()
|
||||
.map(|(_, krate)| PackageRoot {
|
||||
is_local: krate.is_workspace_member,
|
||||
include: krate.include.clone(),
|
||||
exclude: krate.exclude.clone(),
|
||||
.map(|(_, krate)| {
|
||||
let build_files = project
|
||||
.crates()
|
||||
.filter_map(|(_, krate)| {
|
||||
krate.build.as_ref().map(|build| build.build_file.clone())
|
||||
})
|
||||
// FIXME: PackageRoots dont allow specifying files, only directories
|
||||
.filter_map(|build_file| {
|
||||
self.workspace_root().join(build_file).parent().map(ToOwned::to_owned)
|
||||
});
|
||||
PackageRoot {
|
||||
is_local: krate.is_workspace_member,
|
||||
include: krate.include.iter().cloned().chain(build_files).collect(),
|
||||
exclude: krate.exclude.clone(),
|
||||
}
|
||||
})
|
||||
.collect::<FxHashSet<_>>()
|
||||
.into_iter()
|
||||
.chain(mk_sysroot())
|
||||
.collect::<Vec<_>>(),
|
||||
.unique()
|
||||
.collect(),
|
||||
ProjectWorkspaceKind::Cargo {
|
||||
cargo,
|
||||
rustc,
|
||||
|
@ -671,6 +673,11 @@ impl ProjectWorkspace {
|
|||
exclude: Vec::new(),
|
||||
})
|
||||
}))
|
||||
.chain(cargo.is_virtual_workspace().then(|| PackageRoot {
|
||||
is_local: true,
|
||||
include: vec![cargo.workspace_root().to_path_buf()],
|
||||
exclude: Vec::new(),
|
||||
}))
|
||||
.collect()
|
||||
}
|
||||
ProjectWorkspaceKind::DetachedFile { file, cargo: cargo_script, .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue