diff options
Diffstat (limited to 'crates/ra_assists/src/introduce_variable.rs')
-rw-r--r-- | crates/ra_assists/src/introduce_variable.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs index df6c58989..911de2d48 100644 --- a/crates/ra_assists/src/introduce_variable.rs +++ b/crates/ra_assists/src/introduce_variable.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | use std::fmt::Write; | ||
2 | |||
1 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 4 | use ra_syntax::{ |
3 | ast::{self, AstNode}, | 5 | ast::{self, AstNode}, |
@@ -35,8 +37,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option | |||
35 | buf.push_str("let var_name = "); | 37 | buf.push_str("let var_name = "); |
36 | TextUnit::of_str("let ") | 38 | TextUnit::of_str("let ") |
37 | }; | 39 | }; |
38 | 40 | write!(buf, "{}", expr.syntax()).unwrap(); | |
39 | expr.syntax().text().push_to(&mut buf); | ||
40 | let full_stmt = ast::ExprStmt::cast(anchor_stmt.clone()); | 41 | let full_stmt = ast::ExprStmt::cast(anchor_stmt.clone()); |
41 | let is_full_stmt = if let Some(expr_stmt) = &full_stmt { | 42 | let is_full_stmt = if let Some(expr_stmt) = &full_stmt { |
42 | Some(expr.syntax().clone()) == expr_stmt.expr().map(|e| e.syntax().clone()) | 43 | Some(expr.syntax().clone()) == expr_stmt.expr().map(|e| e.syntax().clone()) |