diff options
author | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
commit | 12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch) | |
tree | 71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_lsp_server/src/project_model/cargo_workspace.rs | |
parent | 5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff) |
reformat the world
Diffstat (limited to 'crates/ra_lsp_server/src/project_model/cargo_workspace.rs')
-rw-r--r-- | crates/ra_lsp_server/src/project_model/cargo_workspace.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs index 8cf99d586..3b76389d2 100644 --- a/crates/ra_lsp_server/src/project_model/cargo_workspace.rs +++ b/crates/ra_lsp_server/src/project_model/cargo_workspace.rs | |||
@@ -118,14 +118,11 @@ impl Target { | |||
118 | impl CargoWorkspace { | 118 | impl CargoWorkspace { |
119 | pub fn from_cargo_metadata(cargo_toml: &Path) -> Result<CargoWorkspace> { | 119 | pub fn from_cargo_metadata(cargo_toml: &Path) -> Result<CargoWorkspace> { |
120 | let mut meta = MetadataCommand::new(); | 120 | let mut meta = MetadataCommand::new(); |
121 | meta.manifest_path(cargo_toml) | 121 | meta.manifest_path(cargo_toml).features(CargoOpt::AllFeatures); |
122 | .features(CargoOpt::AllFeatures); | ||
123 | if let Some(parent) = cargo_toml.parent() { | 122 | if let Some(parent) = cargo_toml.parent() { |
124 | meta.current_dir(parent); | 123 | meta.current_dir(parent); |
125 | } | 124 | } |
126 | let meta = meta | 125 | let meta = meta.exec().map_err(|e| format_err!("cargo metadata failed: {}", e))?; |
127 | .exec() | ||
128 | .map_err(|e| format_err!("cargo metadata failed: {}", e))?; | ||
129 | let mut pkg_by_id = FxHashMap::default(); | 126 | let mut pkg_by_id = FxHashMap::default(); |
130 | let mut packages = Arena::default(); | 127 | let mut packages = Arena::default(); |
131 | let mut targets = Arena::default(); | 128 | let mut targets = Arena::default(); |
@@ -157,10 +154,8 @@ impl CargoWorkspace { | |||
157 | for node in resolve.nodes { | 154 | for node in resolve.nodes { |
158 | let source = pkg_by_id[&node.id]; | 155 | let source = pkg_by_id[&node.id]; |
159 | for dep_node in node.deps { | 156 | for dep_node in node.deps { |
160 | let dep = PackageDependency { | 157 | let dep = |
161 | name: dep_node.name.into(), | 158 | PackageDependency { name: dep_node.name.into(), pkg: pkg_by_id[&dep_node.pkg] }; |
162 | pkg: pkg_by_id[&dep_node.pkg], | ||
163 | }; | ||
164 | packages[source].dependencies.push(dep); | 159 | packages[source].dependencies.push(dep); |
165 | } | 160 | } |
166 | } | 161 | } |
@@ -171,8 +166,6 @@ impl CargoWorkspace { | |||
171 | self.packages.iter().map(|(id, _pkg)| id) | 166 | self.packages.iter().map(|(id, _pkg)| id) |
172 | } | 167 | } |
173 | pub fn target_by_root(&self, root: &Path) -> Option<Target> { | 168 | pub fn target_by_root(&self, root: &Path) -> Option<Target> { |
174 | self.packages() | 169 | self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() |
175 | .filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)) | ||
176 | .next() | ||
177 | } | 170 | } |
178 | } | 171 | } |