Skip to content

Commit a064e78

Browse files
committed
don't include trailing open parens in labels for reference patterns
1 parent 203d310 commit a064e78

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2774,7 +2774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27742774
// If the subpattern's span is is from an expansion, the emitted label will not be trimmed.
27752775
let source_map = self.tcx.sess.source_map();
27762776
let cutoff_span = source_map
2777-
.span_extend_prev_while(cutoff_span, char::is_whitespace)
2777+
.span_extend_prev_while(cutoff_span, |c| c.is_whitespace() || c == '(')
27782778
.unwrap_or(cutoff_span);
27792779
// Ensure we use the syntax context and thus edition of `subpat.span`; this will be a hard
27802780
// error if the subpattern is of edition >= 2024.

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

+1-1
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)