Replace complex matches!(…, … if …) by if let chain
This commit is contained in:
parent
c267b597d0
commit
6c4cdfaf42
2 changed files with 9 additions and 2 deletions
|
|
@ -150,7 +150,9 @@ impl SlowVectorInit {
|
|||
&& func.ty_rel_def(cx).is_diag_item(cx, sym::vec_with_capacity)
|
||||
{
|
||||
Some(InitializedSize::Initialized(len_expr))
|
||||
} else if matches!(expr.kind, ExprKind::Call(func, []) if func.ty_rel_def(cx).is_diag_item(cx, sym::vec_new)) {
|
||||
} else if let ExprKind::Call(func, []) = expr.kind
|
||||
&& func.ty_rel_def(cx).is_diag_item(cx, sym::vec_new)
|
||||
{
|
||||
Some(InitializedSize::Uninitialized)
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -152,7 +152,12 @@ fn insert_necessary_parens(pat: &mut Pat) {
|
|||
walk_pat(self, pat);
|
||||
let target = match &mut pat.kind {
|
||||
// `i @ a | b`, `box a | b`, and `& mut? a | b`.
|
||||
Ident(.., Some(p)) | Box(p) | Ref(p, _, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
|
||||
Ident(.., Some(p)) | Box(p) | Ref(p, _, _)
|
||||
if let Or(ps) = &p.kind
|
||||
&& ps.len() > 1 =>
|
||||
{
|
||||
p
|
||||
},
|
||||
// `&(mut x)`
|
||||
Ref(p, Pinnedness::Not, Mutability::Not) if matches!(p.kind, Ident(BindingMode::MUT, ..)) => p,
|
||||
_ => return,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue