aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ide_assists/src/handlers/add_type_ascription.rs6
1 files 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
30 mark::hit!(add_type_ascription_already_typed); 30 mark::hit!(add_type_ascription_already_typed);
31 return None 31 return None
32 } 32 }
33 let type_pos = let_stmt.pat()?.syntax().last_token()?.text_range().end();
33 34
34 let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| { 35 let ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| {
35 let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?; 36 let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?;
@@ -58,14 +59,13 @@ pub(crate) fn add_type_ascription(acc: &mut Assists, ctx: &AssistContext) -> Opt
58 mark::hit!(add_type_ascription_non_generic); 59 mark::hit!(add_type_ascription_non_generic);
59 return None; 60 return None;
60 } 61 }
61 let pat = let_stmt.pat()?.syntax().last_token()?.text_range().end();
62 acc.add( 62 acc.add(
63 AssistId("add_type_ascription", AssistKind::RefactorRewrite), 63 AssistId("add_type_ascription", AssistKind::RefactorRewrite),
64 "Add `: _` before assignment operator", 64 "Add `: _` before assignment operator",
65 ident.text_range(), 65 ident.text_range(),
66 |builder| match ctx.config.snippet_cap { 66 |builder| match ctx.config.snippet_cap {
67 Some(cap) => builder.insert_snippet(cap, pat, ": ${0:_}"), 67 Some(cap) => builder.insert_snippet(cap, type_pos, ": ${0:_}"),
68 None => builder.insert(pat, ": _"), 68 None => builder.insert(type_pos, ": _"),
69 }, 69 },
70 ) 70 )
71} 71}