aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Du <[email protected]>2018-10-16 19:08:52 +0100
committerAlan Du <[email protected]>2018-10-18 00:42:23 +0100
commitfc8024de51261d252b1ad88566db6e246d14ee16 (patch)
treed0bc86ad9bf304fa246461898a54aa81724b54c9
parentbc774fe6cf9948bd554e3fb5b51398b9328e0f4e (diff)
clippy: type_complexity
-rw-r--r--crates/ra_lsp_server/src/thread_watcher.rs10
-rw-r--r--crates/ra_syntax/src/reparsing.rs9
2 files changed, 11 insertions, 8 deletions
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<I, O> Worker<I, O> {
16 I: Send + 'static, 16 I: Send + 'static,
17 O: Send + 'static, 17 O: Send + 'static,
18 { 18 {
19 let ((inp, out), inp_r, out_s) = worker_chan(buf); 19 let (worker, inp_r, out_s) = worker_chan(buf);
20 let worker = Worker { inp, out };
21 let watcher = ThreadWatcher::spawn(name, move || f(inp_r, out_s)); 20 let watcher = ThreadWatcher::spawn(name, move || f(inp_r, out_s));
22 (worker, watcher) 21 (worker, watcher)
23 } 22 }
@@ -66,11 +65,14 @@ impl ThreadWatcher {
66/// Sets up worker channels in a deadlock-avoind way. 65/// Sets up worker channels in a deadlock-avoind way.
67/// If one sets both input and output buffers to a fixed size, 66/// If one sets both input and output buffers to a fixed size,
68/// a worker might get stuck. 67/// a worker might get stuck.
69fn worker_chan<I, O>(buf: usize) -> ((Sender<I>, Receiver<O>), Receiver<I>, Sender<O>) { 68fn worker_chan<I, O>(buf: usize) -> (Worker<I, O>, Receiver<I>, Sender<O>) {
70 let (input_sender, input_receiver) = bounded::<I>(buf); 69 let (input_sender, input_receiver) = bounded::<I>(buf);
71 let (output_sender, output_receiver) = unbounded::<O>(); 70 let (output_sender, output_receiver) = unbounded::<O>();
72 ( 71 (
73 (input_sender, output_receiver), 72 Worker {
73 inp: input_sender,
74 out: output_receiver,
75 },
74 input_receiver, 76 input_receiver,
75 output_sender, 77 output_sender,
76 ) 78 )
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 {
98 } 98 }
99} 99}
100 100
101fn find_reparsable_node<'node>( 101type ParseFn = fn(&mut Parser);
102 node: SyntaxNodeRef<'node>, 102fn find_reparsable_node(
103 node: SyntaxNodeRef<'_>,
103 range: TextRange, 104 range: TextRange,
104) -> Option<(SyntaxNodeRef<'node>, fn(&mut Parser))> { 105) -> Option<(SyntaxNodeRef<'_>, ParseFn)> {
105 let node = algo::find_covering_node(node, range); 106 let node = algo::find_covering_node(node, range);
106 return node 107 return node
107 .ancestors() 108 .ancestors()
108 .filter_map(|node| reparser(node).map(|r| (node, r))) 109 .filter_map(|node| reparser(node).map(|r| (node, r)))
109 .next(); 110 .next();
110 111
111 fn reparser(node: SyntaxNodeRef) -> Option<fn(&mut Parser)> { 112 fn reparser(node: SyntaxNodeRef) -> Option<ParseFn> {
112 let res = match node.kind() { 113 let res = match node.kind() {
113 BLOCK => grammar::block, 114 BLOCK => grammar::block,
114 NAMED_FIELD_DEF_LIST => grammar::named_field_def_list, 115 NAMED_FIELD_DEF_LIST => grammar::named_field_def_list,