1
Fork 0

Rollup merge of #134460 - oli-obk:push-ysuklyupnzpq, r=jieyouxu

Merge some patterns together

just something I noticed while browsing code. No change in functionality, deduplicates the 100% equal match arms by creating one big or pattern
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-12-18 22:56:58 +08:00 committed by GitHub
commit 29d201a3cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -170,27 +170,11 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
| PatKind::TupleStruct(qpath, ..)
| PatKind::Struct(qpath, ..),
..
}) => {
if let QPath::TypeRelative(qpath_ty, ..) = qpath
&& qpath_ty.hir_id == ty.hir_id
{
Some(path.span)
} else {
None
}
}
Node::Expr(Expr { kind: ExprKind::Path(qpath), .. }) => {
if let QPath::TypeRelative(qpath_ty, ..) = qpath
&& qpath_ty.hir_id == ty.hir_id
{
Some(path.span)
} else {
None
}
}
// Can't unify these two branches because qpath below is `&&` and above is `&`
// and `A | B` paths don't play well together with adjustments, apparently.
Node::Expr(Expr { kind: ExprKind::Struct(qpath, ..), .. }) => {
})
| Node::Expr(
Expr { kind: ExprKind::Path(qpath), .. }
| &Expr { kind: ExprKind::Struct(qpath, ..), .. },
) => {
if let QPath::TypeRelative(qpath_ty, ..) = qpath
&& qpath_ty.hir_id == ty.hir_id
{