Skip to content

Commit de8d7aa

Browse files
Rollup merge of rust-lang#77444 - estebank:pat-field-label, r=davidtwco
Fix span for incorrect pattern field and add label Address rust-lang#73750.
2 parents 14d8ee3 + 7d5a620 commit de8d7aa

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

compiler/rustc_parse/src/parser/pat.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ impl<'a> Parser<'a> {
795795
}
796796
self.bump();
797797
let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
798+
e.span_label(path.span, "while parsing the fields for this pattern");
798799
e.emit();
799800
self.recover_stmt();
800801
(vec![], true)
@@ -844,7 +845,7 @@ impl<'a> Parser<'a> {
844845

845846
// check that a comma comes after every field
846847
if !ate_comma {
847-
let err = self.struct_span_err(self.prev_token.span, "expected `,`");
848+
let err = self.struct_span_err(self.token.span, "expected `,`");
848849
if let Some(mut delayed) = delayed_err {
849850
delayed.emit();
850851
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
error: expected `,`
2-
--> $DIR/bind-struct-early-modifiers.rs:4:19
2+
--> $DIR/bind-struct-early-modifiers.rs:4:20
33
|
44
LL | Foo { ref x: ref x } => {},
5-
| ^
5+
| --- ^
6+
| |
7+
| while parsing the fields for this pattern
68

79
error: aborting due to previous error
810

src/test/ui/parser/issue-10392.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error: expected identifier, found `,`
22
--> $DIR/issue-10392.rs:6:13
33
|
44
LL | let A { , } = a();
5-
| ^ expected identifier
5+
| - ^ expected identifier
6+
| |
7+
| while parsing the fields for this pattern
68

79
error: aborting due to previous error
810

src/test/ui/parser/issue-63135.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ error: expected one of `!` or `[`, found `}`
3535
--> $DIR/issue-63135.rs:3:16
3636
|
3737
LL | fn i(n{...,f #
38-
| ^ expected one of `!` or `[`
38+
| - ^ expected one of `!` or `[`
39+
| |
40+
| while parsing the fields for this pattern
3941

4042
error: aborting due to 5 previous errors
4143

src/test/ui/resolve/issue-54379.stderr

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ LL | MyStruct { .., Some(_) } => {},
88
| `..` must be at the end and cannot have a trailing comma
99

1010
error: expected `,`
11-
--> $DIR/issue-54379.rs:9:24
11+
--> $DIR/issue-54379.rs:9:28
1212
|
1313
LL | MyStruct { .., Some(_) } => {},
14-
| ^^^^
14+
| -------- ^
15+
| |
16+
| while parsing the fields for this pattern
1517

1618
error: aborting due to 2 previous errors
1719

0 commit comments

Comments
 (0)