summary refs log tree commit diff
diff options
context:
space:
mode:
authordianne <diannes.gm@gmail.com>2025-02-04 03:27:59 -0800
committerdianne <diannes.gm@gmail.com>2025-02-10 23:33:10 -0800
commit97cb2d553a1d3ef677ce89350655620228b7c8d2 (patch)
tree8b96274cb42570289f73eaef3180bbec32f19d19
parent6ff2d19d1ca79f94d1972a82d03f73184d95beff (diff)
downloadrust-97cb2d553a1d3ef677ce89350655620228b7c8d2.tar.gz
rust-97cb2d553a1d3ef677ce89350655620228b7c8d2.zip
don't include trailing open parens in labels for reference patterns
(cherry picked from commit a064e786633ac81c35abcf00abd9dc57a40ad9bf)
-rw-r--r--compiler/rustc_hir_typeck/src/pat.rs2
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 073de7890c9..91deaa72604 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -2639,7 +2639,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         // If the subpattern's span is is from an expansion, the emitted label will not be trimmed.
         let source_map = self.tcx.sess.source_map();
         let cutoff_span = source_map
-            .span_extend_prev_while(cutoff_span, char::is_whitespace)
+            .span_extend_prev_while(cutoff_span, |c| c.is_whitespace() || c == '(')
             .unwrap_or(cutoff_span);
         // Ensure we use the syntax context and thus edition of `subpat.span`; this will be a hard
         // error if the subpattern is of edition >= 2024.
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr
index febf10cd1f3..eaba337f06b 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr
@@ -284,7 +284,7 @@ error: reference patterns may only be written when the default binding mode is `
   --> $DIR/migration_lint.rs:150:10
    |
 LL |     let [&(_)] = &[&0];
-   |         -^^---
+   |         -^----
    |         ||
    |         |this reference pattern
    |         default binding mode is `ref`