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_analysis/src/descriptors.rs | 2 +- crates/ra_analysis/src/imp.rs | 2 +- crates/ra_analysis/src/job.rs | 2 +- crates/ra_analysis/tests/tests.rs | 4 ++-- crates/ra_editor/src/scope/fn_scope.rs | 4 ++-- crates/ra_editor/src/scope/mod_scope.rs | 18 +++++++++--------- crates/ra_lsp_server/src/main_loop/mod.rs | 2 +- 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 { } impl FnDescriptor { - pub fn new(node: ast::FnDef) -> Option { + pub fn new_opt(node: ast::FnDef) -> Option { let name = node.name()?.text().to_string(); // 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 { for (_, fs) in file_symbols { if fs.kind == FN_DEF { if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) { - if let Some(descriptor) = FnDescriptor::new(fn_def) { + if let Some(descriptor) = FnDescriptor::new_opt(fn_def) { // If we have a calling expression let's find which argument we are on let mut current_parameter = None; 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 { } impl JobHandle { - pub fn new() -> (JobHandle, JobToken) { + pub fn new_pair() -> (JobHandle, JobToken) { let (sender_alive, receiver_alive) = bounded(0); let (sender_canceled, receiver_canceled) = bounded(0); 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) { let (offset, code) = extract_offset(text); let code = code.as_str(); - let (_handle, token) = JobHandle::new(); + let (_handle, token) = JobHandle::new_pair(); let snap = analysis(&[("/lib.rs", code)]); snap.resolve_callable(FileId(1), offset, &token).unwrap() @@ -71,7 +71,7 @@ fn get_signature(text: &str) -> (FnDescriptor, Option) { #[test] fn test_resolve_module() { let snap = analysis(&[("/lib.rs", "mod foo;"), ("/foo.rs", "")]); - let (_handle, token) = JobHandle::new(); + let (_handle, token) = JobHandle::new_pair(); let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into(), &token); assert_eq_dbg( 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 { .syntax() .descendants() .filter_map(ast::BindPat::cast) - .filter_map(ScopeEntry::new); + .filter_map(ScopeEntry::new_opt); self.scopes[scope].entries.extend(entries); } fn add_params_bindings(&mut self, scope: ScopeId, params: Option) { @@ -88,7 +88,7 @@ pub struct ScopeEntry { } impl ScopeEntry { - fn new(pat: ast::BindPat) -> Option { + fn new_opt(pat: ast::BindPat) -> Option { if pat.name().is_some() { Some(ScopeEntry { 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 { let mut entries = Vec::new(); for item in items { let entry = match item { - ast::ModuleItem::StructDef(item) => Entry::new(item), - ast::ModuleItem::EnumDef(item) => Entry::new(item), - ast::ModuleItem::FnDef(item) => Entry::new(item), - ast::ModuleItem::ConstDef(item) => Entry::new(item), - ast::ModuleItem::StaticDef(item) => Entry::new(item), - ast::ModuleItem::TraitDef(item) => Entry::new(item), - ast::ModuleItem::TypeDef(item) => Entry::new(item), - ast::ModuleItem::Module(item) => Entry::new(item), + ast::ModuleItem::StructDef(item) => Entry::new_item(item), + ast::ModuleItem::EnumDef(item) => Entry::new_item(item), + ast::ModuleItem::FnDef(item) => Entry::new_item(item), + ast::ModuleItem::ConstDef(item) => Entry::new_item(item), + ast::ModuleItem::StaticDef(item) => Entry::new_item(item), + ast::ModuleItem::TraitDef(item) => Entry::new_item(item), + ast::ModuleItem::TypeDef(item) => Entry::new_item(item), + ast::ModuleItem::Module(item) => Entry::new_item(item), ast::ModuleItem::UseItem(item) => { if let Some(tree) = item.use_tree() { collect_imports(tree, &mut entries); @@ -50,7 +50,7 @@ impl ModuleScope { } impl Entry { - fn new<'a>(item: impl ast::NameOwner<'a>) -> Option { + fn new_item<'a>(item: impl ast::NameOwner<'a>) -> Option { let name = item.name()?; Some(Entry { 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> { }; 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