Merge pull request #20221 from lnicola/assist-let-chain
Some checks are pending
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
metrics / generate_final_metrics (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run

minor: Revert "remove `if-let` chains"
This commit is contained in:
Laurențiu Nicola 2025-07-10 05:37:26 +00:00 committed by GitHub
commit 69c8a6892a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -64,13 +64,12 @@ pub(crate) fn replace_is_method_with_if_let_method(
let pat = make.tuple_struct_pat(make.ident_path(text), [var_pat.into()]);
let let_expr = make.expr_let(pat.into(), receiver);
if let Some(cap) = ctx.config.snippet_cap {
if let Some(ast::Pat::TupleStructPat(pat)) = let_expr.pat() {
if let Some(first_var) = pat.fields().next() {
let placeholder = edit.make_placeholder_snippet(cap);
editor.add_annotation(first_var.syntax(), placeholder);
}
}
if let Some(cap) = ctx.config.snippet_cap
&& let Some(ast::Pat::TupleStructPat(pat)) = let_expr.pat()
&& let Some(first_var) = pat.fields().next()
{
let placeholder = edit.make_placeholder_snippet(cap);
editor.add_annotation(first_var.syntax(), placeholder);
}
editor.replace(call_expr.syntax(), let_expr.syntax());