diff options
author | Kirill Bulatov <[email protected]> | 2020-02-18 13:32:19 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-02-18 14:12:37 +0000 |
commit | eceaf94f1936436e33ae235ca65bf2a6d4f77da5 (patch) | |
tree | 83d42e6f014f80b84f9193e6b5c7c1e2aded9fa7 /crates/ra_assists/src/handlers | |
parent | b8ddcb0652f3ec8683023afc1e1f5166d6a712f4 (diff) |
More manual clippy fixes
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r-- | crates/ra_assists/src/handlers/add_custom_impl.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/move_guard.rs | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index 4d3a72c18..74aa4b001 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -43,7 +43,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
43 | .clone(); | 43 | .clone(); |
44 | 44 | ||
45 | let trait_token = | 45 | let trait_token = |
46 | ctx.token_at_offset().filter(|t| t.kind() == IDENT && *t.text() != attr_name).next()?; | 46 | ctx.token_at_offset().find(|t| t.kind() == IDENT && *t.text() != attr_name)?; |
47 | 47 | ||
48 | let annotated = attr.syntax().siblings(Direction::Next).find_map(ast::Name::cast)?; | 48 | let annotated = attr.syntax().siblings(Direction::Next).find_map(ast::Name::cast)?; |
49 | let annotated_name = annotated.syntax().text().to_string(); | 49 | let annotated_name = annotated.syntax().text().to_string(); |
@@ -86,7 +86,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
86 | .next_sibling_or_token() | 86 | .next_sibling_or_token() |
87 | .filter(|t| t.kind() == WHITESPACE) | 87 | .filter(|t| t.kind() == WHITESPACE) |
88 | .map(|t| t.text_range()) | 88 | .map(|t| t.text_range()) |
89 | .unwrap_or(TextRange::from_to(TextUnit::from(0), TextUnit::from(0))); | 89 | .unwrap_or_else(|| TextRange::from_to(TextUnit::from(0), TextUnit::from(0))); |
90 | edit.delete(line_break_range); | 90 | edit.delete(line_break_range); |
91 | 91 | ||
92 | attr_range.len() + line_break_range.len() | 92 | attr_range.len() + line_break_range.len() |
diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/ra_assists/src/handlers/move_guard.rs index a61a2ba3e..1cc498638 100644 --- a/crates/ra_assists/src/handlers/move_guard.rs +++ b/crates/ra_assists/src/handlers/move_guard.rs | |||
@@ -44,7 +44,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option<Assist> { | |||
44 | edit.target(guard.syntax().text_range()); | 44 | edit.target(guard.syntax().text_range()); |
45 | let offseting_amount = match space_before_guard.and_then(|it| it.into_token()) { | 45 | let offseting_amount = match space_before_guard.and_then(|it| it.into_token()) { |
46 | Some(tok) => { | 46 | Some(tok) => { |
47 | if let Some(_) = ast::Whitespace::cast(tok.clone()) { | 47 | if ast::Whitespace::cast(tok.clone()).is_some() { |
48 | let ele = tok.text_range(); | 48 | let ele = tok.text_range(); |
49 | edit.delete(ele); | 49 | edit.delete(ele); |
50 | ele.len() | 50 | ele.len() |
@@ -98,11 +98,11 @@ pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx) -> Option<Assist> { | |||
98 | let then_block = if_expr.then_branch()?; | 98 | let then_block = if_expr.then_branch()?; |
99 | 99 | ||
100 | // Not support if with else branch | 100 | // Not support if with else branch |
101 | if let Some(_) = if_expr.else_branch() { | 101 | if if_expr.else_branch().is_some() { |
102 | return None; | 102 | return None; |
103 | } | 103 | } |
104 | // Not support moving if let to arm guard | 104 | // Not support moving if let to arm guard |
105 | if let Some(_) = cond.pat() { | 105 | if cond.pat().is_some() { |
106 | return None; | 106 | return None; |
107 | } | 107 | } |
108 | 108 | ||