diff options
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 12 | ||||
-rw-r--r-- | crates/ra_project_model/src/sysroot.rs | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 55b94b911..676dc4941 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -57,6 +57,10 @@ impl PackageRoot { | |||
57 | 57 | ||
58 | impl ProjectWorkspace { | 58 | impl ProjectWorkspace { |
59 | pub fn discover(path: &Path) -> Result<ProjectWorkspace> { | 59 | pub fn discover(path: &Path) -> Result<ProjectWorkspace> { |
60 | ProjectWorkspace::discover_with_sysroot(path, true) | ||
61 | } | ||
62 | |||
63 | pub fn discover_with_sysroot(path: &Path, with_sysroot: bool) -> Result<ProjectWorkspace> { | ||
60 | match find_rust_project_json(path) { | 64 | match find_rust_project_json(path) { |
61 | Some(json_path) => { | 65 | Some(json_path) => { |
62 | let file = File::open(json_path)?; | 66 | let file = File::open(json_path)?; |
@@ -65,10 +69,10 @@ impl ProjectWorkspace { | |||
65 | } | 69 | } |
66 | None => { | 70 | None => { |
67 | let cargo_toml = find_cargo_toml(path)?; | 71 | let cargo_toml = find_cargo_toml(path)?; |
68 | Ok(ProjectWorkspace::Cargo { | 72 | let cargo = CargoWorkspace::from_cargo_metadata(&cargo_toml)?; |
69 | cargo: CargoWorkspace::from_cargo_metadata(&cargo_toml)?, | 73 | let sysroot = |
70 | sysroot: Sysroot::discover(&cargo_toml)?, | 74 | if with_sysroot { Sysroot::discover(&cargo_toml)? } else { Sysroot::default() }; |
71 | }) | 75 | Ok(ProjectWorkspace::Cargo { cargo, sysroot }) |
72 | } | 76 | } |
73 | } | 77 | } |
74 | } | 78 | } |
diff --git a/crates/ra_project_model/src/sysroot.rs b/crates/ra_project_model/src/sysroot.rs index 3f34d51cc..2a7927f7e 100644 --- a/crates/ra_project_model/src/sysroot.rs +++ b/crates/ra_project_model/src/sysroot.rs | |||
@@ -7,7 +7,7 @@ use ra_arena::{impl_arena_id, Arena, RawId}; | |||
7 | 7 | ||
8 | use crate::Result; | 8 | use crate::Result; |
9 | 9 | ||
10 | #[derive(Debug, Clone)] | 10 | #[derive(Default, Debug, Clone)] |
11 | pub struct Sysroot { | 11 | pub struct Sysroot { |
12 | crates: Arena<SysrootCrate, SysrootCrateData>, | 12 | crates: Arena<SysrootCrate, SysrootCrateData>, |
13 | } | 13 | } |