mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
chore: rename var
This commit is contained in:
parent
705712993f
commit
218390b9fb
1 changed files with 3 additions and 3 deletions
|
@ -30,6 +30,7 @@ pub(crate) fn add_type_ascription(acc: &mut Assists, ctx: &AssistContext) -> Opt
|
||||||
mark::hit!(add_type_ascription_already_typed);
|
mark::hit!(add_type_ascription_already_typed);
|
||||||
return None
|
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 ident = ctx.find_token_syntax_at_offset(SyntaxKind::IDENT).or_else(|| {
|
||||||
let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?;
|
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
|
||||||
mark::hit!(add_type_ascription_non_generic);
|
mark::hit!(add_type_ascription_non_generic);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let pat = let_stmt.pat()?.syntax().last_token()?.text_range().end();
|
|
||||||
acc.add(
|
acc.add(
|
||||||
AssistId("add_type_ascription", AssistKind::RefactorRewrite),
|
AssistId("add_type_ascription", AssistKind::RefactorRewrite),
|
||||||
"Add `: _` before assignment operator",
|
"Add `: _` before assignment operator",
|
||||||
ident.text_range(),
|
ident.text_range(),
|
||||||
|builder| match ctx.config.snippet_cap {
|
|builder| match ctx.config.snippet_cap {
|
||||||
Some(cap) => builder.insert_snippet(cap, pat, ": ${0:_}"),
|
Some(cap) => builder.insert_snippet(cap, type_pos, ": ${0:_}"),
|
||||||
None => builder.insert(pat, ": _"),
|
None => builder.insert(type_pos, ": _"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue