aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-10 11:09:06 +0100
committerGitHub <[email protected]>2020-06-10 11:09:06 +0100
commit9251f181de92c64b51e34980e591d2611b030140 (patch)
tree9b967facb387f495acab99fc8d9850db5073cdab /crates/ra_project_model/src/lib.rs
parent560b98bc505be6ff70876df661e4055e1b38a78c (diff)
parent27ebe5d33e08d92c1a032dc27f19094571bd19cd (diff)
Merge #4832
4832: Reduce OUT_DIR special casing r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_project_model/src/lib.rs')
-rw-r--r--crates/ra_project_model/src/lib.rs20
1 files changed, 7 insertions, 13 deletions
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 {
47 path: PathBuf, 47 path: PathBuf,
48 /// Is a member of the current workspace 48 /// Is a member of the current workspace
49 is_member: bool, 49 is_member: bool,
50 out_dir: Option<PathBuf>,
50} 51}
51impl PackageRoot { 52impl PackageRoot {
52 pub fn new_member(path: PathBuf) -> PackageRoot { 53 pub fn new_member(path: PathBuf) -> PackageRoot {
53 Self { path, is_member: true } 54 Self { path, is_member: true, out_dir: None }
54 } 55 }
55 pub fn new_non_member(path: PathBuf) -> PackageRoot { 56 pub fn new_non_member(path: PathBuf) -> PackageRoot {
56 Self { path, is_member: false } 57 Self { path, is_member: false, out_dir: None }
57 } 58 }
58 pub fn path(&self) -> &Path { 59 pub fn path(&self) -> &Path {
59 &self.path 60 &self.path
60 } 61 }
62 pub fn out_dir(&self) -> Option<&Path> {
63 self.out_dir.as_deref()
64 }
61 pub fn is_member(&self) -> bool { 65 pub fn is_member(&self) -> bool {
62 self.is_member 66 self.is_member
63 } 67 }
@@ -204,6 +208,7 @@ impl ProjectWorkspace {
204 .map(|pkg| PackageRoot { 208 .map(|pkg| PackageRoot {
205 path: cargo[pkg].root().to_path_buf(), 209 path: cargo[pkg].root().to_path_buf(),
206 is_member: cargo[pkg].is_member, 210 is_member: cargo[pkg].is_member,
211 out_dir: cargo[pkg].out_dir.clone(),
207 }) 212 })
208 .chain(sysroot.crates().map(|krate| { 213 .chain(sysroot.crates().map(|krate| {
209 PackageRoot::new_non_member(sysroot[krate].root_dir().to_path_buf()) 214 PackageRoot::new_non_member(sysroot[krate].root_dir().to_path_buf())
@@ -212,17 +217,6 @@ impl ProjectWorkspace {
212 } 217 }
213 } 218 }
214 219
215 pub fn out_dirs(&self) -> Vec<PathBuf> {
216 match self {
217 ProjectWorkspace::Json { project } => {
218 project.crates.iter().filter_map(|krate| krate.out_dir.as_ref()).cloned().collect()
219 }
220 ProjectWorkspace::Cargo { cargo, sysroot: _ } => {
221 cargo.packages().filter_map(|pkg| cargo[pkg].out_dir.as_ref()).cloned().collect()
222 }
223 }
224 }
225
226 pub fn proc_macro_dylib_paths(&self) -> Vec<PathBuf> { 220 pub fn proc_macro_dylib_paths(&self) -> Vec<PathBuf> {
227 match self { 221 match self {
228 ProjectWorkspace::Json { project } => project 222 ProjectWorkspace::Json { project } => project