diff options
author | Aleksey Kladov <[email protected]> | 2019-09-02 19:41:50 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-09-02 19:52:06 +0100 |
commit | e94587e3153b52684fd3f6b82c8e7efc09ff5c8d (patch) | |
tree | 6d268b721027a5350928a6c5a0ec227b5fde8ebc /crates/ra_assists/src/introduce_variable.rs | |
parent | 5e3f291195b580580be7ce5622f54ebca75fb9f0 (diff) |
fix assists
Diffstat (limited to 'crates/ra_assists/src/introduce_variable.rs')
-rw-r--r-- | crates/ra_assists/src/introduce_variable.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs index 95c18d0e3..470ffe120 100644 --- a/crates/ra_assists/src/introduce_variable.rs +++ b/crates/ra_assists/src/introduce_variable.rs | |||
@@ -3,7 +3,8 @@ use hir::db::HirDatabase; | |||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | ast::{self, AstNode}, | 4 | ast::{self, AstNode}, |
5 | SyntaxKind::{ | 5 | SyntaxKind::{ |
6 | BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, WHITESPACE, | 6 | BLOCK_EXPR, BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, |
7 | WHITESPACE, | ||
7 | }, | 8 | }, |
8 | SyntaxNode, TextUnit, | 9 | SyntaxNode, TextUnit, |
9 | }; | 10 | }; |
@@ -80,10 +81,12 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option | |||
80 | /// In general that's true for any expression, but in some cases that would produce invalid code. | 81 | /// In general that's true for any expression, but in some cases that would produce invalid code. |
81 | fn valid_target_expr(node: SyntaxNode) -> Option<ast::Expr> { | 82 | fn valid_target_expr(node: SyntaxNode) -> Option<ast::Expr> { |
82 | match node.kind() { | 83 | match node.kind() { |
83 | PATH_EXPR => None, | 84 | PATH_EXPR | LOOP_EXPR => None, |
84 | BREAK_EXPR => ast::BreakExpr::cast(node).and_then(|e| e.expr()), | 85 | BREAK_EXPR => ast::BreakExpr::cast(node).and_then(|e| e.expr()), |
85 | RETURN_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), | 86 | RETURN_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), |
86 | LOOP_EXPR => ast::ReturnExpr::cast(node).and_then(|e| e.expr()), | 87 | BLOCK_EXPR => { |
88 | ast::BlockExpr::cast(node).filter(|it| it.is_standalone()).map(ast::Expr::from) | ||
89 | } | ||
87 | _ => ast::Expr::cast(node), | 90 | _ => ast::Expr::cast(node), |
88 | } | 91 | } |
89 | } | 92 | } |