use if let guards where possible

This commit is contained in:
Deadbeef
2025-06-15 14:59:05 +08:00
parent 32b51523f8
commit 96fd9fc2dd
2 changed files with 12 additions and 20 deletions

View File

@@ -2273,23 +2273,18 @@ impl<'a> Parser<'a> {
),
// Also catches `fn foo(&a)`.
PatKind::Ref(ref inner_pat, mutab)
if matches!(inner_pat.clone().kind, PatKind::Ident(..)) =>
if let PatKind::Ident(_, ident, _) = inner_pat.clone().kind =>
{
match inner_pat.clone().kind {
PatKind::Ident(_, ident, _) => {
let mutab = mutab.prefix_str();
(
ident,
"self: ",
format!("{ident}: &{mutab}TypeName"),
"_: ",
pat.span.shrink_to_lo(),
pat.span,
pat.span.shrink_to_lo(),
)
}
_ => unreachable!(),
}
let mutab = mutab.prefix_str();
(
ident,
"self: ",
format!("{ident}: &{mutab}TypeName"),
"_: ",
pat.span.shrink_to_lo(),
pat.span,
pat.span.shrink_to_lo(),
)
}
_ => {
// Otherwise, try to get a type and emit a suggestion.