about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-12-18 22:56:58 +0800
committerGitHub <noreply@github.com>2024-12-18 22:56:58 +0800
commit29d201a3cb0ce0d0052bb4edd5fdca9c2d08894d (patch)
tree3a46abe48ef1e1326dfe3eb9b5b575c9cbb2438a
parentfbb9e692262f5d218fba6fe4de69164183c4af5c (diff)
parent9ee1695885c0c82edd127e6d9519476707a6b6d3 (diff)
downloadrust-29d201a3cb0ce0d0052bb4edd5fdca9c2d08894d.tar.gz
rust-29d201a3cb0ce0d0052bb4edd5fdca9c2d08894d.zip
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
-rw-r--r--compiler/rustc_lint/src/internal.rs26
1 files changed, 5 insertions, 21 deletions
diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs
index d32666d8895..b31a4c74787 100644
--- a/compiler/rustc_lint/src/internal.rs
+++ b/compiler/rustc_lint/src/internal.rs
@@ -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
                             {