about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-16 14:25:08 +0000
committerbors <bors@rust-lang.org>2025-06-16 14:25:08 +0000
commit3bc767e1a215c4bf8f099b32e84edb85780591b1 (patch)
tree3da6113318c7c7b0fb401939b8888137c2c7388b /compiler/rustc_parse/src/parser/diagnostics.rs
parentd9ca9bd014074e2bac567eaa2b66bfacb2591028 (diff)
parent78d12b7e56ef5691d31b6f1697aba79eabe4bb2f (diff)
downloadrust-3bc767e1a215c4bf8f099b32e84edb85780591b1.tar.gz
rust-3bc767e1a215c4bf8f099b32e84edb85780591b1.zip
Auto merge of #142574 - Kobzol:rollup-ldj386u, r=Kobzol
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#141639 (Expose discriminant values in stable_mir)
 - rust-lang/rust#142082 (Refactor `rustc_attr_data_structures` documentation)
 - rust-lang/rust#142125 (Stabilize "file_lock" feature)
 - rust-lang/rust#142236 (Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls)
 - rust-lang/rust#142373 (Fix Debug for Location)
 - rust-lang/rust#142416 (Assorted bootstrap cleanups (step 2))
 - rust-lang/rust#142431 (Add initial version of snapshot tests to bootstrap)
 - rust-lang/rust#142450 (Add documentation on top of `rustc_middle/src/query/mod.rs`)
 - rust-lang/rust#142528 (clarify `rustc_do_not_const_check` comment)
 - rust-lang/rust#142530 (use `if let` guards where possible)
 - rust-lang/rust#142561 (Remove an `njn:` comment accidentaly left behind.)
 - rust-lang/rust#142566 (Fix `-nopt` CI jobs)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/diagnostics.rs')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs27
1 files changed, 11 insertions, 16 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index b49a13ce584..215202c4bd5 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -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.