From ed3d93b875f25da6f81b8a107a8c200311240627 Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 4 Jun 2019 02:38:13 -0400 Subject: Fix clippy::single_char_pattern --- crates/ra_assists/src/introduce_variable.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs index fb7333c8c..28467d341 100644 --- a/crates/ra_assists/src/introduce_variable.rs +++ b/crates/ra_assists/src/introduce_variable.rs @@ -57,9 +57,9 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx) -> Option if text.starts_with("\r\n") { buf.push_str("\r\n"); buf.push_str(text.trim_start_matches("\r\n")); - } else if text.starts_with("\n") { + } else if text.starts_with('\n') { buf.push_str("\n"); - buf.push_str(text.trim_start_matches("\n")); + buf.push_str(text.trim_start_matches('\n')); } else { buf.push_str(text); } -- cgit v1.2.3 From b28ca32db22d5e2ed34db556c6fd50a5fc2d679c Mon Sep 17 00:00:00 2001 From: Alan Du Date: Mon, 3 Jun 2019 10:27:51 -0400 Subject: Fix clippy::or_fun_call --- crates/ra_assists/src/auto_import.rs | 4 ++-- crates/ra_assists/src/change_visibility.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs index 1566cf179..9617beb5c 100644 --- a/crates/ra_assists/src/auto_import.rs +++ b/crates/ra_assists/src/auto_import.rs @@ -334,7 +334,7 @@ fn best_action_for_target<'b, 'a: 'b>( .filter_map(ast::UseItem::use_tree) .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target)) .fold(None, |best, a| { - best.and_then(|best| Some(*ImportAction::better(&best, &a))).or(Some(a)) + best.and_then(|best| Some(*ImportAction::better(&best, &a))).or_else(|| Some(a)) }); match best_action { @@ -347,7 +347,7 @@ fn best_action_for_target<'b, 'a: 'b>( let anchor = container .children() .find(|n| n.range().start() < anchor.range().start()) - .or(Some(anchor)); + .or_else(|| Some(anchor)); return ImportAction::add_new_use(anchor, false); } diff --git a/crates/ra_assists/src/change_visibility.rs b/crates/ra_assists/src/change_visibility.rs index 620f534b5..4eb24d27f 100644 --- a/crates/ra_assists/src/change_visibility.rs +++ b/crates/ra_assists/src/change_visibility.rs @@ -59,7 +59,7 @@ fn vis_offset(node: &SyntaxNode) -> TextUnit { }) .next() .map(|it| it.range().start()) - .unwrap_or(node.range().start()) + .unwrap_or_else(|| node.range().start()) } fn change_vis(mut ctx: AssistCtx, vis: &ast::Visibility) -> Option { -- cgit v1.2.3 From 964edd99433e965aa24f2237d1530ce1c575fa8e Mon Sep 17 00:00:00 2001 From: Alan Du Date: Tue, 4 Jun 2019 02:58:22 -0400 Subject: Fix clippy::while_let_loop --- crates/ra_assists/src/ast_editor.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index cabb3d862..de0529b32 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs @@ -212,21 +212,17 @@ impl AstEditor { } pub fn strip_attrs_and_docs(&mut self) { - loop { - if let Some(start) = self - .ast() - .syntax() - .children_with_tokens() - .find(|it| it.kind() == ATTR || it.kind() == COMMENT) - { - let end = match start.next_sibling_or_token() { - Some(el) if el.kind() == WHITESPACE => el, - Some(_) | None => start, - }; - self.ast = self.replace_children(RangeInclusive::new(start, end), iter::empty()); - } else { - break; - } + while let Some(start) = self + .ast() + .syntax() + .children_with_tokens() + .find(|it| it.kind() == ATTR || it.kind() == COMMENT) + { + let end = match start.next_sibling_or_token() { + Some(el) if el.kind() == WHITESPACE => el, + Some(_) | None => start, + }; + self.ast = self.replace_children(RangeInclusive::new(start, end), iter::empty()); } } } -- cgit v1.2.3