From 218390b9fb0cfa713d4b6b38425f3a07fee2b564 Mon Sep 17 00:00:00 2001 From: Conrad Ludgate Date: Mon, 1 Mar 2021 11:21:02 +0000 Subject: chore: rename var --- crates/ide_assists/src/handlers/add_type_ascription.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ide_assists/src/handlers/add_type_ascription.rs b/crates/ide_assists/src/handlers/add_type_ascription.rs index e9dc37150..ea9f249d3 100644 --- a/crates/ide_assists/src/handlers/add_type_ascription.rs +++ b/crates/ide_assists/src/handlers/add_type_ascription.rs @@ -30,6 +30,7 @@ pub(crate) fn add_type_ascription(acc: &mut Assists, ctx: &AssistContext) -> Opt mark::hit!(add_type_ascription_already_typed); return None } + let type_pos = let_stmt.pat()?.syntax().last_token()?.text_range().end(); let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| { let arg_list = ctx.find_node_at_offset::()?; @@ -58,14 +59,13 @@ pub(crate) fn add_type_ascription(acc: &mut Assists, ctx: &AssistContext) -> Opt mark::hit!(add_type_ascription_non_generic); return None; } - let pat = let_stmt.pat()?.syntax().last_token()?.text_range().end(); acc.add( AssistId("add_type_ascription", AssistKind::RefactorRewrite), "Add `: _` before assignment operator", ident.text_range(), |builder| match ctx.config.snippet_cap { - Some(cap) => builder.insert_snippet(cap, pat, ": ${0:_}"), - None => builder.insert(pat, ": _"), + Some(cap) => builder.insert_snippet(cap, type_pos, ": ${0:_}"), + None => builder.insert(type_pos, ": _"), }, ) } -- cgit v1.2.3