From 4dd7ec94bc92055f09fe2aa6a8920a4e32075cef Mon Sep 17 00:00:00 2001 From: Yerkebulan Tulibergenov Date: Tue, 15 Jan 2019 20:27:15 -0800 Subject: use has_semi --- crates/ra_ide_api_light/src/assists/introduce_variable.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'crates/ra_ide_api_light') diff --git a/crates/ra_ide_api_light/src/assists/introduce_variable.rs b/crates/ra_ide_api_light/src/assists/introduce_variable.rs index e51cb22f0..230d23039 100644 --- a/crates/ra_ide_api_light/src/assists/introduce_variable.rs +++ b/crates/ra_ide_api_light/src/assists/introduce_variable.rs @@ -20,16 +20,15 @@ pub fn introduce_variable<'a>(ctx: AssistCtx) -> Option { buf.push_str("let var_name = "); expr.syntax().text().push_to(&mut buf); - let is_full_stmt = if let Some(expr_stmt) = ast::ExprStmt::cast(anchor_stmt) { + let full_stmt = ast::ExprStmt::cast(anchor_stmt); + let is_full_stmt = if let Some(expr_stmt) = full_stmt { Some(expr.syntax()) == expr_stmt.expr().map(|e| e.syntax()) } else { false }; if is_full_stmt { - if let Some(last_child) = expr.syntax().last_child() { - if last_child.kind() != SEMI && !is_semi_right_after(expr.syntax()) { - buf.push_str(";"); - } + if !full_stmt.unwrap().has_semi() { + buf.push_str(";"); } edit.replace(expr.syntax().range(), buf); } else { -- cgit v1.2.3