diff options
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r-- | crates/ra_assists/src/assists/early_return.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index 827170f8f..4322d3737 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs | |||
@@ -38,7 +38,6 @@ use crate::{ | |||
38 | pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 38 | pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
39 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; | 39 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; |
40 | let cond = if_expr.condition()?; | 40 | let cond = if_expr.condition()?; |
41 | let pat = &cond.pat(); | ||
42 | let expr = cond.expr()?; | 41 | let expr = cond.expr()?; |
43 | let then_block = if_expr.then_branch()?.block()?; | 42 | let then_block = if_expr.then_branch()?.block()?; |
44 | if if_expr.else_branch().is_some() { | 43 | if if_expr.else_branch().is_some() { |
@@ -79,7 +78,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Opt | |||
79 | 78 | ||
80 | ctx.add_assist(AssistId("convert_to_guarded_return"), "convert to guarded return", |edit| { | 79 | ctx.add_assist(AssistId("convert_to_guarded_return"), "convert to guarded return", |edit| { |
81 | let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); | 80 | let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); |
82 | let new_block = match pat { | 81 | let new_block = match cond.pat() { |
83 | None => { | 82 | None => { |
84 | // If. | 83 | // If. |
85 | let early_expression = &(early_expression.to_owned() + ";"); | 84 | let early_expression = &(early_expression.to_owned() + ";"); |