diff options
author | Aleksey Kladov <[email protected]> | 2019-11-13 07:54:50 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-13 07:54:50 +0000 |
commit | 2a69d584d6afc842d6dc8503f3fd3a0a691ea385 (patch) | |
tree | dad0363b01c01985eb76dd31ee14e370be29df3d /crates/ra_assists | |
parent | 018255efe3e456aa8d712f68a714d5c6e010d03f (diff) |
Add a bit of types
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/assists/early_return.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index f44610001..8507a60fb 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs | |||
@@ -45,12 +45,12 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
45 | let cond = if_expr.condition()?; | 45 | let cond = if_expr.condition()?; |
46 | 46 | ||
47 | // Check if there is an IfLet that we can handle. | 47 | // Check if there is an IfLet that we can handle. |
48 | let if_let_ident = match cond.pat() { | 48 | let bound_ident = match cond.pat() { |
49 | None => None, // No IfLet, supported. | 49 | None => None, // No IfLet, supported. |
50 | Some(TupleStructPat(pat)) if pat.args().count() == 1 => { | 50 | Some(TupleStructPat(pat)) if pat.args().count() == 1 => { |
51 | let path = pat.path()?; | 51 | let path = pat.path()?; |
52 | match path.qualifier() { | 52 | match path.qualifier() { |
53 | None => Some(path.syntax().to_string()), | 53 | None => Some(path.segment()?.name_ref()?), |
54 | Some(_) => return None, | 54 | Some(_) => return None, |
55 | } | 55 | } |
56 | } | 56 | } |
@@ -94,7 +94,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
94 | 94 | ||
95 | ctx.add_assist(AssistId("convert_to_guarded_return"), "convert to guarded return", |edit| { | 95 | ctx.add_assist(AssistId("convert_to_guarded_return"), "convert to guarded return", |edit| { |
96 | let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); | 96 | let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); |
97 | let new_block = match if_let_ident { | 97 | let new_block = match bound_ident { |
98 | None => { | 98 | None => { |
99 | // If. | 99 | // If. |
100 | let early_expression = &(early_expression.to_owned() + ";"); | 100 | let early_expression = &(early_expression.to_owned() + ";"); |
@@ -102,11 +102,11 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
102 | if_indent_level.increase_indent(make::if_expression(&expr, early_expression)); | 102 | if_indent_level.increase_indent(make::if_expression(&expr, early_expression)); |
103 | replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) | 103 | replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) |
104 | } | 104 | } |
105 | Some(if_let_ident) => { | 105 | Some(bound_ident) => { |
106 | // If-let. | 106 | // If-let. |
107 | let new_expr = if_indent_level.increase_indent(make::let_match_early( | 107 | let new_expr = if_indent_level.increase_indent(make::let_match_early( |
108 | expr, | 108 | expr, |
109 | &if_let_ident, | 109 | &bound_ident.syntax().to_string(), |
110 | early_expression, | 110 | early_expression, |
111 | )); | 111 | )); |
112 | replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) | 112 | replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) |