From 5db663d61fb8b006e3b84ef3bcc9cddbe94e5f49 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 11:45:10 -0400 Subject: Clippy lint: single-character string constant --- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index c25b63852..49bd7895a 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -160,8 +160,8 @@ pub fn handle_workspace_symbol( params: req::WorkspaceSymbolParams, token: JobToken, ) -> Result>> { - let all_symbols = params.query.contains("#"); - let libs = params.query.contains("*"); + let all_symbols = params.query.contains('#'); + let libs = params.query.contains('*'); let query = { let query: String = params .query -- cgit v1.2.3 From d493a4476c2059924d032fbf01dda091601f9667 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 11:51:58 -0400 Subject: clippy: Use if lets and remove redundant returns --- crates/ra_lsp_server/src/server_world.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/server_world.rs b/crates/ra_lsp_server/src/server_world.rs index 35ff65ea1..69b2a1cd1 100644 --- a/crates/ra_lsp_server/src/server_world.rs +++ b/crates/ra_lsp_server/src/server_world.rs @@ -73,9 +73,7 @@ impl ServerWorldState { events .into_iter() .map(|event| { - let text = match event.kind { - FileEventKind::Add(text) => text, - }; + let FileEventKind::Add(text) = event.kind; (event.path, text) }) .map(|(path, text)| (pm.get_or_insert(path, Root::Lib), text)) -- cgit v1.2.3 From 2ae9dfa812ccf18867373f77a106161378a6d91d Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 13:31:16 -0400 Subject: clippy: Fix new_ret_no_self --- crates/ra_lsp_server/src/main_loop/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 a11baf4aa..2623ab84e 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -355,7 +355,7 @@ impl<'a> PoolDispatcher<'a> { }; match req.cast::() { Ok((id, params)) => { - let (handle, token) = JobHandle::new(); + let (handle, token) = JobHandle::new_pair(); let world = self.world.snapshot(); let sender = self.sender.clone(); self.pool.spawn(move || { -- cgit v1.2.3 From fc8024de51261d252b1ad88566db6e246d14ee16 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 16 Oct 2018 14:08:52 -0400 Subject: clippy: type_complexity --- crates/ra_lsp_server/src/thread_watcher.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/thread_watcher.rs b/crates/ra_lsp_server/src/thread_watcher.rs index 67952eb74..6cc586456 100644 --- a/crates/ra_lsp_server/src/thread_watcher.rs +++ b/crates/ra_lsp_server/src/thread_watcher.rs @@ -16,8 +16,7 @@ impl Worker { I: Send + 'static, O: Send + 'static, { - let ((inp, out), inp_r, out_s) = worker_chan(buf); - let worker = Worker { inp, out }; + let (worker, inp_r, out_s) = worker_chan(buf); let watcher = ThreadWatcher::spawn(name, move || f(inp_r, out_s)); (worker, watcher) } @@ -66,11 +65,14 @@ impl ThreadWatcher { /// Sets up worker channels in a deadlock-avoind way. /// If one sets both input and output buffers to a fixed size, /// a worker might get stuck. -fn worker_chan(buf: usize) -> ((Sender, Receiver), Receiver, Sender) { +fn worker_chan(buf: usize) -> (Worker, Receiver, Sender) { let (input_sender, input_receiver) = bounded::(buf); let (output_sender, output_receiver) = unbounded::(); ( - (input_sender, output_receiver), + Worker { + inp: input_sender, + out: output_receiver, + }, input_receiver, output_sender, ) -- cgit v1.2.3 From a5da770ec60a73abcc5350f25146be973540063f Mon Sep 17 00:00:00 2001 From: Alan Du Date: Wed, 17 Oct 2018 19:25:37 -0400 Subject: Fix function calls --- crates/ra_lsp_server/src/main.rs | 2 +- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 ++-- crates/ra_lsp_server/src/project_model.rs | 1 - crates/ra_lsp_server/src/vfs.rs | 1 - 4 files changed, 3 insertions(+), 5 deletions(-) (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 9f62347f1..c07eb0140 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -18,7 +18,7 @@ fn main() -> Result<()> { .directory("log") .start()?; info!("lifecycle: server started"); - match ::std::panic::catch_unwind(|| main_inner()) { + match ::std::panic::catch_unwind(main_inner) { Ok(res) => { info!("lifecycle: terminating process with {:?}", res); res diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 49bd7895a..3e58e6f54 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -289,8 +289,8 @@ pub fn handle_runnables( .filter_map(|ws| { let tgt = ws.target_by_root(path)?; Some(( - tgt.package(ws).name(ws).clone(), - tgt.name(ws).clone(), + tgt.package(ws).name(ws), + tgt.name(ws), tgt.kind(ws), )) }) diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index d170ceb73..cedb67bae 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -173,7 +173,6 @@ pub fn workspace_loader() -> (Worker>, ThreadWat 1, |input_receiver, output_sender| { input_receiver - .into_iter() .map(|path| CargoWorkspace::from_cargo_metadata(path.as_path())) .for_each(|it| output_sender.send(it)) }, diff --git a/crates/ra_lsp_server/src/vfs.rs b/crates/ra_lsp_server/src/vfs.rs index 417a3c19a..6e317d854 100644 --- a/crates/ra_lsp_server/src/vfs.rs +++ b/crates/ra_lsp_server/src/vfs.rs @@ -24,7 +24,6 @@ pub fn roots_loader() -> (Worker)>, ThreadWatc 128, |input_receiver, output_sender| { input_receiver - .into_iter() .map(|path| { debug!("loading {} ...", path.as_path().display()); let events = load_root(path.as_path()); -- cgit v1.2.3 From 6dd3fa6a947a4442e46ac042ff955a7f17bd6a0f Mon Sep 17 00:00:00 2001 From: Alan Du Date: Wed, 17 Oct 2018 19:27:49 -0400 Subject: clippy: cast_lossless --- crates/ra_lsp_server/src/conv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 8325e8c1e..bc0cf7c68 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs @@ -65,7 +65,7 @@ impl ConvWith for TextUnit { fn conv_with(self, line_index: &LineIndex) -> Position { let line_col = line_index.line_col(self); // TODO: UTF-16 - Position::new(line_col.line as u64, u32::from(line_col.col) as u64) + Position::new(u64::from(line_col.line), u64::from(u32::from(line_col.col))) } } @@ -192,7 +192,7 @@ impl TryConvWith for SourceChange { .map(|it| it.edits.as_slice()) .unwrap_or(&[]); let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits); - let position = Position::new(line_col.line as u64, u32::from(line_col.col) as u64); + let position = Position::new(u64::from(line_col.line), u64::from(u32::from(line_col.col))); Some(TextDocumentPositionParams { text_document: TextDocumentIdentifier::new(pos.file_id.try_conv_with(world)?), position, -- cgit v1.2.3 From 0857c22f263ff18418f939b57a7a2ab3f8aac2c1 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Sat, 20 Oct 2018 12:29:25 -0400 Subject: Revert "clippy: Fix new_ret_no_self" This reverts commit 2ae9dfa812ccf18867373f77a106161378a6d91d. --- crates/ra_lsp_server/src/main_loop/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 2623ab84e..a11baf4aa 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -355,7 +355,7 @@ impl<'a> PoolDispatcher<'a> { }; match req.cast::() { Ok((id, params)) => { - let (handle, token) = JobHandle::new_pair(); + let (handle, token) = JobHandle::new(); let world = self.world.snapshot(); let sender = self.sender.clone(); self.pool.spawn(move || { -- cgit v1.2.3