From a5da770ec60a73abcc5350f25146be973540063f Mon Sep 17 00:00:00 2001 From: Alan Du Date: Wed, 17 Oct 2018 19:25:37 -0400 Subject: Fix function calls --- crates/ra_analysis/src/descriptors.rs | 3 +-- crates/ra_analysis/src/imp.rs | 2 +- crates/ra_editor/src/typing.rs | 2 +- crates/ra_lsp_server/src/main.rs | 2 +- crates/ra_lsp_server/src/main_loop/handlers.rs | 4 ++-- crates/ra_lsp_server/src/project_model.rs | 1 - crates/ra_lsp_server/src/vfs.rs | 1 - crates/ra_syntax/src/lexer/ptr.rs | 2 +- crates/ra_syntax/src/reparsing.rs | 2 +- crates/ra_syntax/src/utils.rs | 2 +- 10 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crates/ra_analysis/src/descriptors.rs b/crates/ra_analysis/src/descriptors.rs index 98429326c..dced99b07 100644 --- a/crates/ra_analysis/src/descriptors.rs +++ b/crates/ra_analysis/src/descriptors.rs @@ -183,8 +183,7 @@ impl Link { root: ast::Root<'a>, ) -> ast::Module<'a> { modules(root) - .filter(|(name, _)| name == &tree.link(self).name) - .next() + .find(|(name, _)| name == &tree.link(self).name) .unwrap() .1 } diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 1c16852b8..b4faf0b5b 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -393,7 +393,7 @@ impl AnalysisImpl { // If we have a method call eat the first param since it's just self. if has_self { - commas = commas + 1; + commas += 1; } current_parameter = Some(commas); diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs index 50b52e7a1..5a457d148 100644 --- a/crates/ra_editor/src/typing.rs +++ b/crates/ra_editor/src/typing.rs @@ -58,7 +58,7 @@ pub fn join_lines(file: &File, range: TextRange) -> LocalEdit { pub fn on_enter(file: &File, offset: TextUnit) -> Option { let comment = find_leaf_at_offset(file.syntax(), offset) .left_biased() - .and_then(|it| ast::Comment::cast(it))?; + .and_then(ast::Comment::cast)?; if let ast::CommentFlavor::Multiline = comment.flavor() { return None; diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index 9f62347f1..c07eb0140 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs @@ -18,7 +18,7 @@ fn main() -> Result<()> { .directory("log") .start()?; info!("lifecycle: server started"); - match ::std::panic::catch_unwind(|| main_inner()) { + match ::std::panic::catch_unwind(main_inner) { Ok(res) => { info!("lifecycle: terminating process with {:?}", res); res diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 49bd7895a..3e58e6f54 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -289,8 +289,8 @@ pub fn handle_runnables( .filter_map(|ws| { let tgt = ws.target_by_root(path)?; Some(( - tgt.package(ws).name(ws).clone(), - tgt.name(ws).clone(), + tgt.package(ws).name(ws), + tgt.name(ws), tgt.kind(ws), )) }) diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index d170ceb73..cedb67bae 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -173,7 +173,6 @@ pub fn workspace_loader() -> (Worker>, ThreadWat 1, |input_receiver, output_sender| { input_receiver - .into_iter() .map(|path| CargoWorkspace::from_cargo_metadata(path.as_path())) .for_each(|it| output_sender.send(it)) }, diff --git a/crates/ra_lsp_server/src/vfs.rs b/crates/ra_lsp_server/src/vfs.rs index 417a3c19a..6e317d854 100644 --- a/crates/ra_lsp_server/src/vfs.rs +++ b/crates/ra_lsp_server/src/vfs.rs @@ -24,7 +24,6 @@ pub fn roots_loader() -> (Worker)>, ThreadWatc 128, |input_receiver, output_sender| { input_receiver - .into_iter() .map(|path| { debug!("loading {} ...", path.as_path().display()); let events = load_root(path.as_path()); diff --git a/crates/ra_syntax/src/lexer/ptr.rs b/crates/ra_syntax/src/lexer/ptr.rs index fa79d8862..4c291b9c4 100644 --- a/crates/ra_syntax/src/lexer/ptr.rs +++ b/crates/ra_syntax/src/lexer/ptr.rs @@ -31,7 +31,7 @@ impl<'s> Ptr<'s> { /// For example, 0 will return the current token, 1 will return the next, etc. pub fn nth(&self, n: u32) -> Option { let mut chars = self.chars().peekable(); - chars.by_ref().skip(n as usize).next() + chars.by_ref().nth(n as usize) } /// Checks whether the current character is `c`. diff --git a/crates/ra_syntax/src/reparsing.rs b/crates/ra_syntax/src/reparsing.rs index 377152de4..eae01b1d5 100644 --- a/crates/ra_syntax/src/reparsing.rs +++ b/crates/ra_syntax/src/reparsing.rs @@ -135,7 +135,7 @@ fn find_reparsable_node( } fn is_balanced(tokens: &[Token]) -> bool { - if tokens.len() == 0 + if tokens.is_empty() || tokens.first().unwrap().kind != L_CURLY || tokens.last().unwrap().kind != R_CURLY { diff --git a/crates/ra_syntax/src/utils.rs b/crates/ra_syntax/src/utils.rs index ca4160378..8ee02724d 100644 --- a/crates/ra_syntax/src/utils.rs +++ b/crates/ra_syntax/src/utils.rs @@ -5,7 +5,7 @@ use std::fmt::Write; /// Parse a file and create a string representation of the resulting parse tree. pub fn dump_tree(syntax: SyntaxNodeRef) -> String { - let mut errors: Vec<_> = syntax.root_data().iter().cloned().collect(); + let mut errors: Vec<_> = syntax.root_data().to_vec(); errors.sort_by_key(|e| e.offset); let mut err_pos = 0; let mut level = 0; -- cgit v1.2.3