From f29b0172fbcbc88160980c2e7359f92d7c0d885d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 4 Nov 2018 14:09:21 +0300 Subject: Use Default everywhere --- crates/ra_lsp_server/src/main_loop/mod.rs | 2 +- crates/ra_lsp_server/src/path_map.rs | 5 +---- crates/ra_lsp_server/src/server_world.rs | 10 +--------- 3 files changed, 3 insertions(+), 14 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index c568706bd..1eb147539 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -61,7 +61,7 @@ pub fn main_loop( let (ws_worker, ws_watcher) = workspace_loader(); info!("server initialized, serving requests"); - let mut state = ServerWorldState::new(); + let mut state = ServerWorldState::default(); let mut pending_requests = FxHashSet::default(); let mut subs = Subscriptions::new(); diff --git a/crates/ra_lsp_server/src/path_map.rs b/crates/ra_lsp_server/src/path_map.rs index dd09fa10a..87eabf9be 100644 --- a/crates/ra_lsp_server/src/path_map.rs +++ b/crates/ra_lsp_server/src/path_map.rs @@ -28,9 +28,6 @@ impl fmt::Debug for PathMap { } impl PathMap { - pub fn new() -> PathMap { - Default::default() - } pub fn get_or_insert(&mut self, path: PathBuf, root: Root) -> (bool, FileId) { let mut inserted = false; let file_id = self @@ -117,7 +114,7 @@ mod test { #[test] fn test_resolve() { - let mut m = PathMap::new(); + let mut m = PathMap::default(); let (_, id1) = m.get_or_insert(PathBuf::from("/foo"), Root::Workspace); let (_, id2) = m.get_or_insert(PathBuf::from("/foo/bar.rs"), Root::Workspace); assert_eq!(m.resolve(id1, &RelativePath::new("bar.rs")), Some(id2),) diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 3e76d2527..3e7670fcc 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs @@ -17,7 +17,7 @@ use crate::{ Result, }; -#[derive(Debug)] +#[derive(Debug, Default)] pub struct ServerWorldState { pub workspaces: Arc>, pub analysis_host: AnalysisHost, @@ -32,14 +32,6 @@ pub struct ServerWorld { } impl ServerWorldState { - pub fn new() -> ServerWorldState { - ServerWorldState { - workspaces: Arc::new(Vec::new()), - analysis_host: AnalysisHost::new(), - path_map: PathMap::new(), - mem_map: FxHashMap::default(), - } - } pub fn apply_fs_changes(&mut self, events: Vec) { let mut change = AnalysisChange::new(); let mut inserted = false; -- cgit v1.2.3