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 ++++++---- crates/ra_syntax/src/reparsing.rs | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'crates') 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, ) diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs index a0014e016..377152de4 100644 --- a/crates/ra_syntax/src/reparsing.rs +++ b/crates/ra_syntax/src/reparsing.rs @@ -98,17 +98,18 @@ fn is_contextual_kw(text: &str) -> bool { } } -fn find_reparsable_node<'node>( - node: SyntaxNodeRef<'node>, +type ParseFn = fn(&mut Parser); +fn find_reparsable_node( + node: SyntaxNodeRef<'_>, range: TextRange, -) -> Option<(SyntaxNodeRef<'node>, fn(&mut Parser))> { +) -> Option<(SyntaxNodeRef<'_>, ParseFn)> { let node = algo::find_covering_node(node, range); return node .ancestors() .filter_map(|node| reparser(node).map(|r| (node, r))) .next(); - fn reparser(node: SyntaxNodeRef) -> Option { + fn reparser(node: SyntaxNodeRef) -> Option { let res = match node.kind() { BLOCK => grammar::block, NAMED_FIELD_DEF_LIST => grammar::named_field_def_list, -- cgit v1.2.3