mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-29 19:47:38 +00:00
Merge #4832
4832: Reduce OUT_DIR special casing r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
9251f181de
@ -47,17 +47,21 @@ pub struct PackageRoot {
|
|||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
/// Is a member of the current workspace
|
/// Is a member of the current workspace
|
||||||
is_member: bool,
|
is_member: bool,
|
||||||
|
out_dir: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
impl PackageRoot {
|
impl PackageRoot {
|
||||||
pub fn new_member(path: PathBuf) -> PackageRoot {
|
pub fn new_member(path: PathBuf) -> PackageRoot {
|
||||||
Self { path, is_member: true }
|
Self { path, is_member: true, out_dir: None }
|
||||||
}
|
}
|
||||||
pub fn new_non_member(path: PathBuf) -> PackageRoot {
|
pub fn new_non_member(path: PathBuf) -> PackageRoot {
|
||||||
Self { path, is_member: false }
|
Self { path, is_member: false, out_dir: None }
|
||||||
}
|
}
|
||||||
pub fn path(&self) -> &Path {
|
pub fn path(&self) -> &Path {
|
||||||
&self.path
|
&self.path
|
||||||
}
|
}
|
||||||
|
pub fn out_dir(&self) -> Option<&Path> {
|
||||||
|
self.out_dir.as_deref()
|
||||||
|
}
|
||||||
pub fn is_member(&self) -> bool {
|
pub fn is_member(&self) -> bool {
|
||||||
self.is_member
|
self.is_member
|
||||||
}
|
}
|
||||||
@ -204,6 +208,7 @@ impl ProjectWorkspace {
|
|||||||
.map(|pkg| PackageRoot {
|
.map(|pkg| PackageRoot {
|
||||||
path: cargo[pkg].root().to_path_buf(),
|
path: cargo[pkg].root().to_path_buf(),
|
||||||
is_member: cargo[pkg].is_member,
|
is_member: cargo[pkg].is_member,
|
||||||
|
out_dir: cargo[pkg].out_dir.clone(),
|
||||||
})
|
})
|
||||||
.chain(sysroot.crates().map(|krate| {
|
.chain(sysroot.crates().map(|krate| {
|
||||||
PackageRoot::new_non_member(sysroot[krate].root_dir().to_path_buf())
|
PackageRoot::new_non_member(sysroot[krate].root_dir().to_path_buf())
|
||||||
@ -212,17 +217,6 @@ impl ProjectWorkspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn out_dirs(&self) -> Vec<PathBuf> {
|
|
||||||
match self {
|
|
||||||
ProjectWorkspace::Json { project } => {
|
|
||||||
project.crates.iter().filter_map(|krate| krate.out_dir.as_ref()).cloned().collect()
|
|
||||||
}
|
|
||||||
ProjectWorkspace::Cargo { cargo, sysroot: _ } => {
|
|
||||||
cargo.packages().filter_map(|pkg| cargo[pkg].out_dir.as_ref()).cloned().collect()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn proc_macro_dylib_paths(&self) -> Vec<PathBuf> {
|
pub fn proc_macro_dylib_paths(&self) -> Vec<PathBuf> {
|
||||||
match self {
|
match self {
|
||||||
ProjectWorkspace::Json { project } => project
|
ProjectWorkspace::Json { project } => project
|
||||||
|
@ -36,28 +36,28 @@ pub fn load_cargo(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut extern_dirs = FxHashSet::default();
|
let mut extern_dirs = FxHashSet::default();
|
||||||
extern_dirs.extend(ws.out_dirs());
|
|
||||||
|
|
||||||
let mut project_roots = ws.to_roots();
|
|
||||||
project_roots.extend(extern_dirs.iter().cloned().map(PackageRoot::new_non_member));
|
|
||||||
|
|
||||||
let (sender, receiver) = unbounded();
|
let (sender, receiver) = unbounded();
|
||||||
let sender = Box::new(move |t| sender.send(t).unwrap());
|
let sender = Box::new(move |t| sender.send(t).unwrap());
|
||||||
let (mut vfs, roots) = Vfs::new(
|
|
||||||
project_roots
|
let mut roots = Vec::new();
|
||||||
.iter()
|
let project_roots = ws.to_roots();
|
||||||
.map(|pkg_root| {
|
for root in &project_roots {
|
||||||
RootEntry::new(
|
roots.push(RootEntry::new(
|
||||||
pkg_root.path().to_owned(),
|
root.path().to_owned(),
|
||||||
RustPackageFilterBuilder::default()
|
RustPackageFilterBuilder::default().set_member(root.is_member()).into_vfs_filter(),
|
||||||
.set_member(pkg_root.is_member())
|
));
|
||||||
.into_vfs_filter(),
|
|
||||||
)
|
if let Some(out_dir) = root.out_dir() {
|
||||||
})
|
extern_dirs.insert(out_dir.to_path_buf());
|
||||||
.collect(),
|
roots.push(RootEntry::new(
|
||||||
sender,
|
out_dir.to_owned(),
|
||||||
Watch(false),
|
RustPackageFilterBuilder::default().set_member(root.is_member()).into_vfs_filter(),
|
||||||
);
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let (mut vfs, roots) = Vfs::new(roots, sender, Watch(false));
|
||||||
|
|
||||||
let source_roots = roots
|
let source_roots = roots
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -89,8 +89,7 @@ impl GlobalState {
|
|||||||
) -> GlobalState {
|
) -> GlobalState {
|
||||||
let mut change = AnalysisChange::new();
|
let mut change = AnalysisChange::new();
|
||||||
|
|
||||||
let extern_dirs: FxHashSet<_> =
|
let mut extern_dirs: FxHashSet<PathBuf> = FxHashSet::default();
|
||||||
workspaces.iter().flat_map(ProjectWorkspace::out_dirs).collect();
|
|
||||||
|
|
||||||
let mut local_roots = Vec::new();
|
let mut local_roots = Vec::new();
|
||||||
let roots: Vec<_> = {
|
let roots: Vec<_> = {
|
||||||
@ -100,22 +99,22 @@ impl GlobalState {
|
|||||||
.exclude(exclude_globs.iter().cloned())
|
.exclude(exclude_globs.iter().cloned())
|
||||||
.into_vfs_filter()
|
.into_vfs_filter()
|
||||||
};
|
};
|
||||||
workspaces
|
let mut roots = Vec::new();
|
||||||
.iter()
|
for root in workspaces.iter().flat_map(ProjectWorkspace::to_roots) {
|
||||||
.flat_map(ProjectWorkspace::to_roots)
|
let path = root.path().to_owned();
|
||||||
.map(|pkg_root| {
|
if root.is_member() {
|
||||||
let path = pkg_root.path().to_owned();
|
|
||||||
if pkg_root.is_member() {
|
|
||||||
local_roots.push(path.clone());
|
local_roots.push(path.clone());
|
||||||
}
|
}
|
||||||
RootEntry::new(path, create_filter(pkg_root.is_member()))
|
roots.push(RootEntry::new(path, create_filter(root.is_member())));
|
||||||
})
|
if let Some(out_dir) = root.out_dir() {
|
||||||
.chain(
|
extern_dirs.insert(out_dir.to_path_buf());
|
||||||
extern_dirs
|
roots.push(RootEntry::new(
|
||||||
.iter()
|
out_dir.to_path_buf(),
|
||||||
.map(|path| RootEntry::new(path.to_owned(), create_filter(false))),
|
create_filter(root.is_member()),
|
||||||
)
|
))
|
||||||
.collect()
|
}
|
||||||
|
}
|
||||||
|
roots
|
||||||
};
|
};
|
||||||
|
|
||||||
let (task_sender, task_receiver) = unbounded();
|
let (task_sender, task_receiver) = unbounded();
|
||||||
|
Loading…
Reference in New Issue
Block a user