aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/introduce_variable.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-20 14:52:33 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-20 14:52:33 +0100
commit3983ccca4ac46bb7b206a5b373b10c9822280931 (patch)
treee72c3798558b7b0494990d1c994ebd9c0f3c03f3 /crates/ra_assists/src/introduce_variable.rs
parentdac6adbef90286f053f034eace9df65d6a19c0ff (diff)
parentf6bcc2d7459a3e10090391a6f9b9a2789e9cab55 (diff)
Merge #1566
1566: align SyntaxText API with upstream r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/introduce_variable.rs')
-rw-r--r--crates/ra_assists/src/introduce_variable.rs5
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 @@
1use std::fmt::Write;
2
1use hir::db::HirDatabase; 3use hir::db::HirDatabase;
2use ra_syntax::{ 4use 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())