clippy: Fix new_ret_no_self

This commit is contained in:
Alan Du 2018-10-16 13:31:16 -04:00
parent 2268a2f8c6
commit 2ae9dfa812
7 changed files with 17 additions and 17 deletions

View File

@ -233,7 +233,7 @@ pub struct FnDescriptor {
} }
impl FnDescriptor { impl FnDescriptor {
pub fn new(node: ast::FnDef) -> Option<Self> { pub fn new_opt(node: ast::FnDef) -> Option<Self> {
let name = node.name()?.text().to_string(); let name = node.name()?.text().to_string();
// Strip the body out for the label. // Strip the body out for the label.

View File

@ -362,7 +362,7 @@ impl AnalysisImpl {
for (_, fs) in file_symbols { for (_, fs) in file_symbols {
if fs.kind == FN_DEF { if fs.kind == FN_DEF {
if let Some(fn_def) = find_node_at_offset(syntax, fs.node_range.start()) { 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 // If we have a calling expression let's find which argument we are on
let mut current_parameter = None; let mut current_parameter = None;

View File

@ -11,7 +11,7 @@ pub struct JobToken {
} }
impl JobHandle { impl JobHandle {
pub fn new() -> (JobHandle, JobToken) { pub fn new_pair() -> (JobHandle, JobToken) {
let (sender_alive, receiver_alive) = bounded(0); let (sender_alive, receiver_alive) = bounded(0);
let (sender_canceled, receiver_canceled) = bounded(0); let (sender_canceled, receiver_canceled) = bounded(0);
let token = JobToken { let token = JobToken {

View File

@ -62,7 +62,7 @@ fn get_signature(text: &str) -> (FnDescriptor, Option<usize>) {
let (offset, code) = extract_offset(text); let (offset, code) = extract_offset(text);
let code = code.as_str(); let code = code.as_str();
let (_handle, token) = JobHandle::new(); let (_handle, token) = JobHandle::new_pair();
let snap = analysis(&[("/lib.rs", code)]); let snap = analysis(&[("/lib.rs", code)]);
snap.resolve_callable(FileId(1), offset, &token).unwrap() snap.resolve_callable(FileId(1), offset, &token).unwrap()
@ -71,7 +71,7 @@ fn get_signature(text: &str) -> (FnDescriptor, Option<usize>) {
#[test] #[test]
fn test_resolve_module() { fn test_resolve_module() {
let snap = analysis(&[("/lib.rs", "mod foo;"), ("/foo.rs", "")]); 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); let symbols = snap.approximately_resolve_symbol(FileId(1), 4.into(), &token);
assert_eq_dbg( assert_eq_dbg(
r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#, r#"[(FileId(2), FileSymbol { name: "foo", node_range: [0; 0), kind: MODULE })]"#,

View File

@ -63,7 +63,7 @@ impl FnScopes {
.syntax() .syntax()
.descendants() .descendants()
.filter_map(ast::BindPat::cast) .filter_map(ast::BindPat::cast)
.filter_map(ScopeEntry::new); .filter_map(ScopeEntry::new_opt);
self.scopes[scope].entries.extend(entries); self.scopes[scope].entries.extend(entries);
} }
fn add_params_bindings(&mut self, scope: ScopeId, params: Option<ast::ParamList>) { fn add_params_bindings(&mut self, scope: ScopeId, params: Option<ast::ParamList>) {
@ -88,7 +88,7 @@ pub struct ScopeEntry {
} }
impl ScopeEntry { impl ScopeEntry {
fn new(pat: ast::BindPat) -> Option<ScopeEntry> { fn new_opt(pat: ast::BindPat) -> Option<ScopeEntry> {
if pat.name().is_some() { if pat.name().is_some() {
Some(ScopeEntry { Some(ScopeEntry {
syntax: pat.syntax().owned(), syntax: pat.syntax().owned(),

View File

@ -22,14 +22,14 @@ impl ModuleScope {
let mut entries = Vec::new(); let mut entries = Vec::new();
for item in items { for item in items {
let entry = match item { let entry = match item {
ast::ModuleItem::StructDef(item) => Entry::new(item), ast::ModuleItem::StructDef(item) => Entry::new_item(item),
ast::ModuleItem::EnumDef(item) => Entry::new(item), ast::ModuleItem::EnumDef(item) => Entry::new_item(item),
ast::ModuleItem::FnDef(item) => Entry::new(item), ast::ModuleItem::FnDef(item) => Entry::new_item(item),
ast::ModuleItem::ConstDef(item) => Entry::new(item), ast::ModuleItem::ConstDef(item) => Entry::new_item(item),
ast::ModuleItem::StaticDef(item) => Entry::new(item), ast::ModuleItem::StaticDef(item) => Entry::new_item(item),
ast::ModuleItem::TraitDef(item) => Entry::new(item), ast::ModuleItem::TraitDef(item) => Entry::new_item(item),
ast::ModuleItem::TypeDef(item) => Entry::new(item), ast::ModuleItem::TypeDef(item) => Entry::new_item(item),
ast::ModuleItem::Module(item) => Entry::new(item), ast::ModuleItem::Module(item) => Entry::new_item(item),
ast::ModuleItem::UseItem(item) => { ast::ModuleItem::UseItem(item) => {
if let Some(tree) = item.use_tree() { if let Some(tree) = item.use_tree() {
collect_imports(tree, &mut entries); collect_imports(tree, &mut entries);
@ -50,7 +50,7 @@ impl ModuleScope {
} }
impl Entry { impl Entry {
fn new<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> { fn new_item<'a>(item: impl ast::NameOwner<'a>) -> Option<Entry> {
let name = item.name()?; let name = item.name()?;
Some(Entry { Some(Entry {
node: name.syntax().owned(), node: name.syntax().owned(),

View File

@ -355,7 +355,7 @@ impl<'a> PoolDispatcher<'a> {
}; };
match req.cast::<R>() { match req.cast::<R>() {
Ok((id, params)) => { Ok((id, params)) => {
let (handle, token) = JobHandle::new(); let (handle, token) = JobHandle::new_pair();
let world = self.world.snapshot(); let world = self.world.snapshot();
let sender = self.sender.clone(); let sender = self.sender.clone();
self.pool.spawn(move || { self.pool.spawn(move || {