mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
remove if-let
chains
Signed-off-by: Hayashi Mikihiro <34ttrweoewiwe28@gmail.com>
This commit is contained in:
parent
f6a247dc57
commit
fcc81a38b3
@ -64,12 +64,13 @@ pub(crate) fn replace_is_method_with_if_let_method(
|
|||||||
let pat = make.tuple_struct_pat(make.ident_path(text), [var_pat.into()]);
|
let pat = make.tuple_struct_pat(make.ident_path(text), [var_pat.into()]);
|
||||||
let let_expr = make.expr_let(pat.into(), receiver);
|
let let_expr = make.expr_let(pat.into(), receiver);
|
||||||
|
|
||||||
if let Some(cap) = ctx.config.snippet_cap
|
if let Some(cap) = ctx.config.snippet_cap {
|
||||||
&& let Some(ast::Pat::TupleStructPat(pat)) = let_expr.pat()
|
if let Some(ast::Pat::TupleStructPat(pat)) = let_expr.pat() {
|
||||||
&& let Some(first_var) = pat.fields().next()
|
if let Some(first_var) = pat.fields().next() {
|
||||||
{
|
let placeholder = edit.make_placeholder_snippet(cap);
|
||||||
let placeholder = edit.make_placeholder_snippet(cap);
|
editor.add_annotation(first_var.syntax(), placeholder);
|
||||||
editor.add_annotation(first_var.syntax(), placeholder);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.replace(call_expr.syntax(), let_expr.syntax());
|
editor.replace(call_expr.syntax(), let_expr.syntax());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user