From ecd420636efe54657ae742ce960ce061740ef108 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Mon, 3 Jun 2019 10:01:10 -0400 Subject: Fix clippy::single_match --- crates/ra_lsp_server/tests/heavy_tests/support.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index f952a03a3..955d283dd 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -141,15 +141,14 @@ impl Server { R::Params: Serialize, { let actual = self.send_request::(params); - match find_mismatch(&expected_resp, &actual) { - Some((expected_part, actual_part)) => panic!( + if let Some((expected_part, actual_part)) = find_mismatch(&expected_resp, &actual) { + panic!( "JSON mismatch\nExpected:\n{}\nWas:\n{}\nExpected part:\n{}\nActual part:\n{}\n", to_string_pretty(&expected_resp).unwrap(), to_string_pretty(&actual).unwrap(), to_string_pretty(expected_part).unwrap(), to_string_pretty(actual_part).unwrap(), - ), - None => {} + ); } } -- cgit v1.2.3 From 6095e3fe19da289580ba6feb46b643ff52276568 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 4 Jun 2019 02:06:19 -0400 Subject: Fix clippy::unnecessary_mut_passed --- crates/ra_lsp_server/tests/heavy_tests/support.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 955d283dd..22a5a610d 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -95,13 +95,8 @@ impl Server { "test server", 128, move |mut msg_receiver, mut msg_sender| { - main_loop( - roots, - InitializationOptions::default(), - &mut msg_receiver, - &mut msg_sender, - ) - .unwrap() + main_loop(roots, InitializationOptions::default(), &msg_receiver, &msg_sender) + .unwrap() }, ); let res = Server { req_id: Cell::new(1), dir, messages: Default::default(), worker }; -- cgit v1.2.3 From 7bcd8d6290f63a725a62cc7da0269c08c1b6c99b Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 4 Jun 2019 02:17:44 -0400 Subject: Fix clippy::unused_mut --- crates/ra_lsp_server/tests/heavy_tests/support.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 22a5a610d..75912afdd 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -94,7 +94,7 @@ impl Server { let worker = Worker::::spawn( "test server", 128, - move |mut msg_receiver, mut msg_sender| { + move |msg_receiver, msg_sender| { main_loop(roots, InitializationOptions::default(), &msg_receiver, &msg_sender) .unwrap() }, -- cgit v1.2.3 From 40424d4222d4630bc53294d10f1718f2d3d300de Mon Sep 17 00:00:00 2001 From: Alan Du Date: Mon, 3 Jun 2019 10:21:08 -0400 Subject: Fix clippy::identity_conversion --- crates/ra_lsp_server/src/cargo_target_spec.rs | 2 +- crates/ra_lsp_server/src/main_loop.rs | 4 ++-- crates/ra_lsp_server/src/world.rs | 29 +++++++++++---------------- 3 files changed, 15 insertions(+), 20 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/cargo_target_spec.rs b/crates/ra_lsp_server/src/cargo_target_spec.rs index 742361155..082ac8609 100644 --- a/crates/ra_lsp_server/src/cargo_target_spec.rs +++ b/crates/ra_lsp_server/src/cargo_target_spec.rs @@ -64,7 +64,7 @@ impl CargoTargetSpec { None => return Ok(None), }; let file_id = world.analysis().crate_root(crate_id)?; - let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0.into())); + let path = world.vfs.read().file2path(ra_vfs::VfsFile(file_id.0)); let res = world.workspaces.iter().find_map(|ws| match ws { project_model::ProjectWorkspace::Cargo { cargo, .. } => { let tgt = cargo.target_by_root(&path)?; diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 6080a3a4e..090fb9b1b 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -384,7 +384,7 @@ fn on_notification( if let Some(file_id) = state.vfs.write().add_file_overlay(&path, params.text_document.text) { - subs.add_sub(FileId(file_id.0.into())); + subs.add_sub(FileId(file_id.0)); } return Ok(()); } @@ -406,7 +406,7 @@ fn on_notification( let uri = params.text_document.uri; let path = uri.to_file_path().map_err(|()| format_err!("invalid uri: {}", uri))?; if let Some(file_id) = state.vfs.write().remove_file_overlay(path.as_path()) { - subs.remove_sub(FileId(file_id.0.into())); + subs.remove_sub(FileId(file_id.0)); } let params = req::PublishDiagnosticsParams { uri, diagnostics: Vec::new() }; let not = RawNotification::new::(¶ms); diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index e0d2f6306..cd8df4fdb 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -60,14 +60,14 @@ impl WorldState { for r in vfs_roots { let vfs_root_path = vfs.root2path(r); let is_local = folder_roots.iter().any(|it| vfs_root_path.starts_with(it)); - change.add_root(SourceRootId(r.0.into()), is_local); + change.add_root(SourceRootId(r.0), is_local); } // Create crate graph from all the workspaces let mut crate_graph = CrateGraph::default(); let mut load = |path: &std::path::Path| { let vfs_file = vfs.load(path); - vfs_file.map(|f| FileId(f.0.into())) + vfs_file.map(|f| FileId(f.0)) }; for ws in workspaces.iter() { crate_graph.extend(ws.to_crate_graph(&mut load)); @@ -105,29 +105,24 @@ impl WorldState { if is_local { self.roots_to_scan -= 1; for (file, path, text) in files { - change.add_file( - SourceRootId(root.0.into()), - FileId(file.0.into()), - path, - text, - ); + change.add_file(SourceRootId(root.0), FileId(file.0), path, text); } } else { let files = files .into_iter() - .map(|(vfsfile, path, text)| (FileId(vfsfile.0.into()), path, text)) + .map(|(vfsfile, path, text)| (FileId(vfsfile.0), path, text)) .collect(); - libs.push((SourceRootId(root.0.into()), files)); + libs.push((SourceRootId(root.0), files)); } } VfsChange::AddFile { root, file, path, text } => { - change.add_file(SourceRootId(root.0.into()), FileId(file.0.into()), path, text); + change.add_file(SourceRootId(root.0), FileId(file.0), path, text); } VfsChange::RemoveFile { root, file, path } => { - change.remove_file(SourceRootId(root.0.into()), FileId(file.0.into()), path) + change.remove_file(SourceRootId(root.0), FileId(file.0), path) } VfsChange::ChangeFile { file, text } => { - change.change_file(FileId(file.0.into()), text); + change.change_file(FileId(file.0), text); } } } @@ -178,18 +173,18 @@ impl WorldSnapshot { message: "Rust file outside current workspace is not supported yet.".to_string(), }) })?; - Ok(FileId(file.0.into())) + Ok(FileId(file.0)) } pub fn file_id_to_uri(&self, id: FileId) -> Result { - let path = self.vfs.read().file2path(VfsFile(id.0.into())); + let path = self.vfs.read().file2path(VfsFile(id.0)); let url = Url::from_file_path(&path) .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; Ok(url) } pub fn path_to_uri(&self, root: SourceRootId, path: &RelativePathBuf) -> Result { - let base = self.vfs.read().root2path(VfsRoot(root.0.into())); + let base = self.vfs.read().root2path(VfsRoot(root.0)); let path = path.to_path(base); let url = Url::from_file_path(&path) .map_err(|_| format_err!("can't convert path to url: {}", path.display()))?; @@ -212,7 +207,7 @@ impl WorldSnapshot { } pub fn workspace_root_for(&self, file_id: FileId) -> Option<&Path> { - let path = self.vfs.read().file2path(VfsFile(file_id.0.into())); + let path = self.vfs.read().file2path(VfsFile(file_id.0)); self.workspaces.iter().find_map(|ws| ws.workspace_root_for(&path)) } } -- cgit v1.2.3 From b28ca32db22d5e2ed34db556c6fd50a5fc2d679c Mon Sep 17 00:00:00 2001 From: Alan Du Date: Mon, 3 Jun 2019 10:27:51 -0400 Subject: Fix clippy::or_fun_call --- crates/ra_lsp_server/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index b0b70df5c..a0df32dde 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -49,7 +49,7 @@ fn main_inner() -> Result<()> { let opts = params .initialization_options .and_then(|v| InitializationOptions::deserialize(v).ok()) - .unwrap_or(InitializationOptions::default()); + .unwrap_or_default(); ra_lsp_server::main_loop(workspace_roots, opts, r, s) })?; -- cgit v1.2.3