From 27ebe5d33e08d92c1a032dc27f19094571bd19cd Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 10 Jun 2020 12:08:35 +0200 Subject: Reduce OUT_DIR special casing --- crates/ra_project_model/src/lib.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'crates/ra_project_model') diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index c1f7e3ac5..cb0e27dce 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -47,17 +47,21 @@ pub struct PackageRoot { path: PathBuf, /// Is a member of the current workspace is_member: bool, + out_dir: Option, } impl 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 { - Self { path, is_member: false } + Self { path, is_member: false, out_dir: None } } pub fn path(&self) -> &Path { &self.path } + pub fn out_dir(&self) -> Option<&Path> { + self.out_dir.as_deref() + } pub fn is_member(&self) -> bool { self.is_member } @@ -204,6 +208,7 @@ impl ProjectWorkspace { .map(|pkg| PackageRoot { path: cargo[pkg].root().to_path_buf(), is_member: cargo[pkg].is_member, + out_dir: cargo[pkg].out_dir.clone(), }) .chain(sysroot.crates().map(|krate| { PackageRoot::new_non_member(sysroot[krate].root_dir().to_path_buf()) @@ -212,17 +217,6 @@ impl ProjectWorkspace { } } - pub fn out_dirs(&self) -> Vec { - 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 { match self { ProjectWorkspace::Json { project } => project -- cgit v1.2.3