Fix span for incorrect pattern field and add label
This commit is contained in:
parent
4529af972e
commit
7d5a6203ec
5 changed files with 16 additions and 7 deletions
|
@ -795,6 +795,7 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
self.bump();
|
self.bump();
|
||||||
let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
|
let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| {
|
||||||
|
e.span_label(path.span, "while parsing the fields for this pattern");
|
||||||
e.emit();
|
e.emit();
|
||||||
self.recover_stmt();
|
self.recover_stmt();
|
||||||
(vec![], true)
|
(vec![], true)
|
||||||
|
@ -844,7 +845,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
// check that a comma comes after every field
|
// check that a comma comes after every field
|
||||||
if !ate_comma {
|
if !ate_comma {
|
||||||
let err = self.struct_span_err(self.prev_token.span, "expected `,`");
|
let err = self.struct_span_err(self.token.span, "expected `,`");
|
||||||
if let Some(mut delayed) = delayed_err {
|
if let Some(mut delayed) = delayed_err {
|
||||||
delayed.emit();
|
delayed.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
error: expected `,`
|
error: expected `,`
|
||||||
--> $DIR/bind-struct-early-modifiers.rs:4:19
|
--> $DIR/bind-struct-early-modifiers.rs:4:20
|
||||||
|
|
|
|
||||||
LL | Foo { ref x: ref x } => {},
|
LL | Foo { ref x: ref x } => {},
|
||||||
| ^
|
| --- ^
|
||||||
|
| |
|
||||||
|
| while parsing the fields for this pattern
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@ error: expected identifier, found `,`
|
||||||
--> $DIR/issue-10392.rs:6:13
|
--> $DIR/issue-10392.rs:6:13
|
||||||
|
|
|
|
||||||
LL | let A { , } = a();
|
LL | let A { , } = a();
|
||||||
| ^ expected identifier
|
| - ^ expected identifier
|
||||||
|
| |
|
||||||
|
| while parsing the fields for this pattern
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,9 @@ error: expected one of `!` or `[`, found `}`
|
||||||
--> $DIR/issue-63135.rs:3:16
|
--> $DIR/issue-63135.rs:3:16
|
||||||
|
|
|
|
||||||
LL | fn i(n{...,f #
|
LL | fn i(n{...,f #
|
||||||
| ^ expected one of `!` or `[`
|
| - ^ expected one of `!` or `[`
|
||||||
|
| |
|
||||||
|
| while parsing the fields for this pattern
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@ LL | MyStruct { .., Some(_) } => {},
|
||||||
| `..` must be at the end and cannot have a trailing comma
|
| `..` must be at the end and cannot have a trailing comma
|
||||||
|
|
||||||
error: expected `,`
|
error: expected `,`
|
||||||
--> $DIR/issue-54379.rs:9:24
|
--> $DIR/issue-54379.rs:9:28
|
||||||
|
|
|
|
||||||
LL | MyStruct { .., Some(_) } => {},
|
LL | MyStruct { .., Some(_) } => {},
|
||||||
| ^^^^
|
| -------- ^
|
||||||
|
| |
|
||||||
|
| while parsing the fields for this pattern
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue