diff options
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/handlers/extract_variable.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs index 481baf1a4..f5637a740 100644 --- a/crates/ra_assists/src/handlers/extract_variable.rs +++ b/crates/ra_assists/src/handlers/extract_variable.rs | |||
@@ -37,7 +37,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
37 | return None; | 37 | return None; |
38 | } | 38 | } |
39 | let expr = node.ancestors().find_map(valid_target_expr)?; | 39 | let expr = node.ancestors().find_map(valid_target_expr)?; |
40 | let (anchor_stmt, wrap_in_block) = anchor_stmt(expr.clone())?; | 40 | let (anchor_stmt, wrap_in_block) = anchor_stmt(&expr)?; |
41 | let indent = anchor_stmt.prev_sibling_or_token()?.as_token()?.clone(); | 41 | let indent = anchor_stmt.prev_sibling_or_token()?.as_token()?.clone(); |
42 | if indent.kind() != WHITESPACE { | 42 | if indent.kind() != WHITESPACE { |
43 | return None; | 43 | return None; |
@@ -143,7 +143,7 @@ fn valid_target_expr(node: SyntaxNode) -> Option<ast::Expr> { | |||
143 | /// to produce correct code. | 143 | /// to produce correct code. |
144 | /// It can be a statement, the last in a block expression or a wanna be block | 144 | /// It can be a statement, the last in a block expression or a wanna be block |
145 | /// expression like a lambda or match arm. | 145 | /// expression like a lambda or match arm. |
146 | fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { | 146 | fn anchor_stmt(expr: &ast::Expr) -> Option<(SyntaxNode, bool)> { |
147 | expr.syntax().ancestors().find_map(|node| { | 147 | expr.syntax().ancestors().find_map(|node| { |
148 | if let Some(expr) = node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.expr()) { | 148 | if let Some(expr) = node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.expr()) { |
149 | if expr.syntax() == &node { | 149 | if expr.syntax() == &node { |