From 2a69d584d6afc842d6dc8503f3fd3a0a691ea385 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 13 Nov 2019 10:54:50 +0300 Subject: Add a bit of types --- crates/ra_assists/src/assists/early_return.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index f44610001..8507a60fb 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs @@ -45,12 +45,12 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Opt let cond = if_expr.condition()?; // Check if there is an IfLet that we can handle. - let if_let_ident = match cond.pat() { + let bound_ident = match cond.pat() { None => None, // No IfLet, supported. Some(TupleStructPat(pat)) if pat.args().count() == 1 => { let path = pat.path()?; match path.qualifier() { - None => Some(path.syntax().to_string()), + None => Some(path.segment()?.name_ref()?), Some(_) => return None, } } @@ -94,7 +94,7 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Opt ctx.add_assist(AssistId("convert_to_guarded_return"), "convert to guarded return", |edit| { let if_indent_level = IndentLevel::from_node(&if_expr.syntax()); - let new_block = match if_let_ident { + let new_block = match bound_ident { None => { // If. let early_expression = &(early_expression.to_owned() + ";"); @@ -102,11 +102,11 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Opt if_indent_level.increase_indent(make::if_expression(&expr, early_expression)); replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) } - Some(if_let_ident) => { + Some(bound_ident) => { // If-let. let new_expr = if_indent_level.increase_indent(make::let_match_early( expr, - &if_let_ident, + &bound_ident.syntax().to_string(), early_expression, )); replace(new_expr.syntax(), &then_block, &parent_block, &if_expr) -- cgit v1.2.3