don't include trailing open parens in labels for reference patterns

This commit is contained in:
dianne 2025-02-04 03:27:59 -08:00
parent 203d3109d8
commit a064e78663
2 changed files with 2 additions and 2 deletions

View File

@ -2774,7 +2774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// If the subpattern's span is is from an expansion, the emitted label will not be trimmed. // 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 source_map = self.tcx.sess.source_map();
let cutoff_span = 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); .unwrap_or(cutoff_span);
// Ensure we use the syntax context and thus edition of `subpat.span`; this will be a hard // 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. // error if the subpattern is of edition >= 2024.

View File

@ -284,7 +284,7 @@ error: reference patterns may only be written when the default binding mode is `
--> $DIR/migration_lint.rs:150:10 --> $DIR/migration_lint.rs:150:10
| |
LL | let [&(_)] = &[&0]; LL | let [&(_)] = &[&0];
| -^^--- | -^----
| || | ||
| |this reference pattern | |this reference pattern
| default binding mode is `ref` | default binding mode is `ref`