aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-21 16:50:10 +0100
committerAleksey Kladov <[email protected]>2020-07-21 16:50:19 +0100
commit3bb1b3070a51d5bd0ddffff85069260d3f83207d (patch)
tree5e1d84d1119d9b7d848456f6c331c0f78c1597c5 /crates/ra_assists/src
parent818aeb8a242bba5d8947ce2960e1af27d998f4fc (diff)
minor
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/handlers/extract_variable.rs4
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.
146fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> { 146fn 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 {