Skip to content

Commit 97cb2d5

Browse files
committed
don't include trailing open parens in labels for reference patterns
(cherry picked from commit a064e78)
1 parent 6ff2d19 commit 97cb2d5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26392639
// If the subpattern's span is is from an expansion, the emitted label will not be trimmed.
26402640
let source_map = self.tcx.sess.source_map();
26412641
let cutoff_span = source_map
2642-
.span_extend_prev_while(cutoff_span, char::is_whitespace)
2642+
.span_extend_prev_while(cutoff_span, |c| c.is_whitespace() || c == '(')
26432643
.unwrap_or(cutoff_span);
26442644
// Ensure we use the syntax context and thus edition of `subpat.span`; this will be a hard
26452645
// error if the subpattern is of edition >= 2024.

tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ error: reference patterns may only be written when the default binding mode is `
284284
--> $DIR/migration_lint.rs:150:10
285285
|
286286
LL | let [&(_)] = &[&0];
287-
| -^^---
287+
| -^----
288288
| ||
289289
| |this reference pattern
290290
| default binding mode is `ref`

0 commit comments

Comments
 (0)