From 12e3b4c70b5ef23b2fdfc197296d483680e125f9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 Feb 2019 14:49:43 +0300 Subject: reformat the world --- .../ra_lsp_server/src/project_model/cargo_workspace.rs | 17 +++++------------ crates/ra_lsp_server/src/project_model/sysroot.rs | 9 ++------- 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'crates/ra_lsp_server/src/project_model') 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 { impl CargoWorkspace { pub fn from_cargo_metadata(cargo_toml: &Path) -> Result { let mut meta = MetadataCommand::new(); - meta.manifest_path(cargo_toml) - .features(CargoOpt::AllFeatures); + meta.manifest_path(cargo_toml).features(CargoOpt::AllFeatures); if let Some(parent) = cargo_toml.parent() { meta.current_dir(parent); } - let meta = meta - .exec() - .map_err(|e| format_err!("cargo metadata failed: {}", e))?; + let meta = meta.exec().map_err(|e| format_err!("cargo metadata failed: {}", e))?; let mut pkg_by_id = FxHashMap::default(); let mut packages = Arena::default(); let mut targets = Arena::default(); @@ -157,10 +154,8 @@ impl CargoWorkspace { for node in resolve.nodes { let source = pkg_by_id[&node.id]; for dep_node in node.deps { - let dep = PackageDependency { - name: dep_node.name.into(), - pkg: pkg_by_id[&dep_node.pkg], - }; + let dep = + PackageDependency { name: dep_node.name.into(), pkg: pkg_by_id[&dep_node.pkg] }; packages[source].dependencies.push(dep); } } @@ -171,8 +166,6 @@ impl CargoWorkspace { self.packages.iter().map(|(id, _pkg)| id) } pub fn target_by_root(&self, root: &Path) -> Option { - self.packages() - .filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)) - .next() + self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() } } diff --git a/crates/ra_lsp_server/src/project_model/sysroot.rs b/crates/ra_lsp_server/src/project_model/sysroot.rs index fb4685671..49210ac7a 100644 --- a/crates/ra_lsp_server/src/project_model/sysroot.rs +++ b/crates/ra_lsp_server/src/project_model/sysroot.rs @@ -53,9 +53,7 @@ impl Sysroot { ); } - let mut sysroot = Sysroot { - crates: Arena::default(), - }; + let mut sysroot = Sysroot { crates: Arena::default() }; for name in SYSROOT_CRATES.trim().lines() { let root = src.join(format!("lib{}", name)).join("lib.rs"); if root.exists() { @@ -77,10 +75,7 @@ impl Sysroot { } fn by_name(&self, name: &str) -> Option { - self.crates - .iter() - .find(|(_id, data)| data.name == name) - .map(|(id, _data)| id) + self.crates.iter().find(|(_id, data)| data.name == name).map(|(id, _data)| id) } } -- cgit v1.2.3