From 61f3a438d3a729a6be941bca1ff4c6a97a33f221 Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Mon, 15 Oct 2018 17:44:23 -0400 Subject: Cargo Format Run `cargo fmt` and ignore generated files --- crates/ra_lsp_server/src/project_model.rs | 32 ++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'crates/ra_lsp_server/src/project_model.rs') diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index c144d9596..d170ceb73 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -1,13 +1,12 @@ -use std::{ - path::{Path, PathBuf}, -}; -use rustc_hash::{FxHashMap, FxHashSet}; use cargo_metadata::{metadata_run, CargoOpt}; use ra_syntax::SmolStr; +use rustc_hash::{FxHashMap, FxHashSet}; + +use std::path::{Path, PathBuf}; use crate::{ + thread_watcher::{ThreadWatcher, Worker}, Result, - thread_watcher::{Worker, ThreadWatcher}, }; #[derive(Debug, Clone)] @@ -39,7 +38,12 @@ struct TargetData { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TargetKind { - Bin, Lib, Example, Test, Bench, Other, + Bin, + Lib, + Example, + Test, + Bench, + Other, } impl Package { @@ -49,7 +53,7 @@ impl Package { pub fn root(self, ws: &CargoWorkspace) -> &Path { ws.pkg(self).manifest.parent().unwrap() } - pub fn targets<'a>(self, ws: &'a CargoWorkspace) -> impl Iterator + 'a { + pub fn targets<'a>(self, ws: &'a CargoWorkspace) -> impl Iterator + 'a { ws.pkg(self).targets.iter().cloned() } pub fn is_member(self, ws: &CargoWorkspace) -> bool { @@ -78,13 +82,15 @@ impl CargoWorkspace { let meta = metadata_run( Some(cargo_toml.as_path()), true, - Some(CargoOpt::AllFeatures) - ).map_err(|e| format_err!("cargo metadata failed: {}", e))?; + Some(CargoOpt::AllFeatures), + ) + .map_err(|e| format_err!("cargo metadata failed: {}", e))?; let mut pkg_by_id = FxHashMap::default(); let mut packages = Vec::new(); let mut targets = Vec::new(); - let ws_members: FxHashSet = meta.workspace_members + let ws_members: FxHashSet = meta + .workspace_members .into_iter() .map(|it| it.raw) .collect(); @@ -114,7 +120,7 @@ impl CargoWorkspace { Ok(CargoWorkspace { packages, targets }) } - pub fn packages<'a>(&'a self) -> impl Iterator + 'a { + pub fn packages<'a>(&'a self) -> impl Iterator + 'a { (0..self.packages.len()).map(Package) } pub fn target_by_root(&self, root: &Path) -> Option { @@ -155,7 +161,7 @@ impl TargetKind { "example" => TargetKind::Example, _ if kind.contains("lib") => TargetKind::Lib, _ => continue, - } + }; } TargetKind::Other } @@ -170,6 +176,6 @@ pub fn workspace_loader() -> (Worker>, ThreadWat .into_iter() .map(|path| CargoWorkspace::from_cargo_metadata(path.as_path())) .for_each(|it| output_sender.send(it)) - } + }, ) } -- cgit v1.2.3