aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Du <[email protected]>2018-10-16 18:31:16 +0100
committerAlan Du <[email protected]>2018-10-18 00:42:23 +0100
commit2ae9dfa812ccf18867373f77a106161378a6d91d (patch)
treec3ff8017bfa41dd31de37de6716eb97db132ebcf
parent2268a2f8c6557301ecdcaeb4074331a0bd37dccd (diff)
clippy: Fix new_ret_no_self
-rw-r--r--crates/ra_analysis/src/descriptors.rs2
-rw-r--r--crates/ra_analysis/src/imp.rs2
-rw-r--r--crates/ra_analysis/src/job.rs2
-rw-r--r--crates/ra_analysis/tests/tests.rs4
-rw-r--r--crates/ra_editor/src/scope/fn_scope.rs4
-rw-r--r--crates/ra_editor/src/scope/mod_scope.rs18
-rw-r--r--crates/ra_lsp_server/src/main_loop/mod.rs2
7 files changed, 17 insertions, 17 deletions
diff --git a/crates/ra_analysis/src/descriptors.rs b/crates/ra_analysis/src/descriptors.rs
index 6f26f9935..f64fcee16 100644
--- a/crates/ra_analysis/src/descriptors.rs
+++ b/crates/ra_analysis/src/descriptors.rs
@@ -233,7 +233,7 @@ pub struct FnDescriptor {
233} 233}
234 234
235impl FnDescriptor { 235impl FnDescriptor {
236 pub fn new(node: ast::FnDef) -> Option<Self> { 236 pub fn new_opt(node: ast::FnDef) -> Option<Self> {
237 let name = node.name()?.text().to_string(); 237 let name = node.name()?.text().to_string();
238 238
239 // Strip the body out for the label. 239 // Strip the body out for the label.
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 9b0d935af..1c16852b8 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -362,7 +362,7 @@ impl AnalysisImpl {
362 for (_, fs) in file_symbols { 362 for (_, fs) in file_symbols {
363 if fs.kind == FN_DEF { 363 if fs.kind == FN_DEF {
364 if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) { 364 if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) {
365 if let Some(descriptor) = FnDescriptor::new(fn_def) { 365 if let Some(descriptor) = FnDescriptor::new_opt(fn_def) {
366 // If we have a calling expression let's find which argument we are on 366 // If we have a calling expression let's find which argument we are on
367 let mut current_parameter = None; 367 let mut current_parameter = None;
368 368
diff --git a/crates/ra_analysis/src/job.rs b/crates/ra_analysis/src/job.rs
index 2871f9839..57215c862 100644
--- a/crates/ra_analysis/src/job.rs
+++ b/crates/ra_analysis/src/job.rs
@@ -11,7 +11,7 @@ pub struct JobToken {
11} 11}
12 12
13impl JobHandle { 13impl JobHandle {
14 pub fn new() -> (JobHandle, JobToken) { 14 pub fn new_pair() -> (JobHandle, JobToken) {
15 let (sender_alive, receiver_alive) = bounded(0); 15 let (sender_alive, receiver_alive) = bounded(0);
16 let (sender_canceled, receiver_canceled) = bounded(0); 16 let (sender_canceled, receiver_canceled) = bounded(0);
17 let token = JobToken { 17 let token = JobToken {
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs
index e0c637d65..3302e1151 100644
--- a/crates/ra_analysis/tests/tests.rs
+++ b/crates/ra_analysis/tests/tests.rs
@@ -62,7 +62,7 @@ fn get_signature(text: &str) -> (FnDescriptor, Option<usize>) {
62 let (offset, code) = extract_offset(text); 62 let (offset, code) = extract_offset(text);
63 let code = code.as_str(); 63 let code = code.as_str();
64 64
65 let (_handle, token) = JobHandle::new(); 65 let (_handle, token) = JobHandle::new_pair();
66 let snap = analysis(&[("/lib.rs", code)]); 66 let snap = analysis(&[("/lib.rs", code)]);
67 67
68 snap.resolve_callable(FileId(1), offset, &token).unwrap() 68 snap.resolve_callable(FileId(1), offset, &token).unwrap()
@@ -71,7 +71,7 @@ fn get_signature(text: &str) -> (FnDescriptor, Option<usize>) {
71#[test] 71#[test]
72fn test_resolve_module() { 72fn test_resolve_module() {
73 let snap = analysis(&[("/lib.rs", "mod foo;"), ("/foo.rs", "")]); 73 let snap = analysis(&[("/lib.rs", "mod foo;"), ("/foo.rs", "")]);
74 let (_handle, token) = JobHandle::new(); 74 let (_handle, token) = JobHandle::new_pair();
75 let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into(), &token); 75 let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into(), &token);
76 assert_eq_dbg( 76 assert_eq_dbg(
77 r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, 77 r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#,
diff --git a/crates/ra_editor/src/scope/fn_scope.rs b/crates/ra_editor/src/scope/fn_scope.rs
index 9088e5a60..84f036c7e 100644
--- a/crates/ra_editor/src/scope/fn_scope.rs
+++ b/crates/ra_editor/src/scope/fn_scope.rs
@@ -63,7 +63,7 @@ impl FnScopes {
63 .syntax() 63 .syntax()
64 .descendants() 64 .descendants()
65 .filter_map(ast::BindPat::cast) 65 .filter_map(ast::BindPat::cast)
66 .filter_map(ScopeEntry::new); 66 .filter_map(ScopeEntry::new_opt);
67 self.scopes[scope].entries.extend(entries); 67 self.scopes[scope].entries.extend(entries);
68 } 68 }
69 fn add_params_bindings(&mut self, scope: ScopeId, params: Option<ast::ParamList>) { 69 fn add_params_bindings(&mut self, scope: ScopeId, params: Option<ast::ParamList>) {
@@ -88,7 +88,7 @@ pub struct ScopeEntry {
88} 88}
89 89
90impl ScopeEntry { 90impl ScopeEntry {
91 fn new(pat: ast::BindPat) -> Option<ScopeEntry> { 91 fn new_opt(pat: ast::BindPat) -> Option<ScopeEntry> {
92 if pat.name().is_some() { 92 if pat.name().is_some() {
93 Some(ScopeEntry { 93 Some(ScopeEntry {
94 syntax: pat.syntax().owned(), 94 syntax: pat.syntax().owned(),
diff --git a/crates/ra_editor/src/scope/mod_scope.rs b/crates/ra_editor/src/scope/mod_scope.rs
index 8d7e408f8..956ee0e2f 100644
--- a/crates/ra_editor/src/scope/mod_scope.rs
+++ b/crates/ra_editor/src/scope/mod_scope.rs
@@ -22,14 +22,14 @@ impl ModuleScope {
22 let mut entries = Vec::new(); 22 let mut entries = Vec::new();
23 for item in items { 23 for item in items {
24 let entry = match item { 24 let entry = match item {
25 ast::ModuleItem::StructDef(item) => Entry::new(item), 25 ast::ModuleItem::StructDef(item) => Entry::new_item(item),
26 ast::ModuleItem::EnumDef(item) => Entry::new(item), 26 ast::ModuleItem::EnumDef(item) => Entry::new_item(item),
27 ast::ModuleItem::FnDef(item) => Entry::new(item), 27 ast::ModuleItem::FnDef(item) => Entry::new_item(item),
28 ast::ModuleItem::ConstDef(item) => Entry::new(item), 28 ast::ModuleItem::ConstDef(item) => Entry::new_item(item),
29 ast::ModuleItem::StaticDef(item) => Entry::new(item), 29 ast::ModuleItem::StaticDef(item) => Entry::new_item(item),
30 ast::ModuleItem::TraitDef(item) => Entry::new(item), 30 ast::ModuleItem::TraitDef(item) => Entry::new_item(item),
31 ast::ModuleItem::TypeDef(item) => Entry::new(item), 31 ast::ModuleItem::TypeDef(item) => Entry::new_item(item),
32 ast::ModuleItem::Module(item) => Entry::new(item), 32 ast::ModuleItem::Module(item) => Entry::new_item(item),
33 ast::ModuleItem::UseItem(item) => { 33 ast::ModuleItem::UseItem(item) => {
34 if let Some(tree) = item.use_tree() { 34 if let Some(tree) = item.use_tree() {
35 collect_imports(tree, &mut entries); 35 collect_imports(tree, &mut entries);
@@ -50,7 +50,7 @@ impl ModuleScope {
50} 50}
51 51
52impl Entry { 52impl Entry {
53 fn new<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> { 53 fn new_item<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> {
54 let name = item.name()?; 54 let name = item.name()?;
55 Some(Entry { 55 Some(Entry {
56 node: name.syntax().owned(), 56 node: name.syntax().owned(),
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> {
355 }; 355 };
356 match req.cast::<R>() { 356 match req.cast::<R>() {
357 Ok((id, params)) => { 357 Ok((id, params)) => {
358 let (handle, token) = JobHandle::new(); 358 let (handle, token) = JobHandle::new_pair();
359 let world = self.world.snapshot(); 359 let world = self.world.snapshot();
360 let sender = self.sender.clone(); 360 let sender = self.sender.clone();
361 self.pool.spawn(move || { 361 self.pool.spawn(move || {