Recover gracefully from struct parse errors
This commit is contained in:
parent
3df25ae186
commit
2e9b45e1dd
5 changed files with 4 additions and 18 deletions
|
|
@ -1313,7 +1313,7 @@ impl<'a> Parser<'a> {
|
|||
vis: Visibility,
|
||||
attrs: Vec<Attribute>,
|
||||
) -> PResult<'a, StructField> {
|
||||
let name = self.parse_ident()?;
|
||||
let name = self.parse_ident_common(false)?;
|
||||
self.expect(&token::Colon)?;
|
||||
let ty = self.parse_ty()?;
|
||||
Ok(StructField {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ pub(crate) struct Bar<T> {
|
|||
foo: T,
|
||||
|
||||
trait T { //~ ERROR expected identifier, found keyword `trait`
|
||||
//~^ ERROR expected `:`, found `T`
|
||||
fn foo(&self);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this file contains an unclosed delimiter
|
||||
--> $DIR/missing-close-brace-in-struct.rs:14:65
|
||||
--> $DIR/missing-close-brace-in-struct.rs:13:65
|
||||
|
|
||||
LL | pub(crate) struct Bar<T> {
|
||||
| - unclosed delimiter
|
||||
|
|
@ -13,11 +13,5 @@ error: expected identifier, found keyword `trait`
|
|||
LL | trait T {
|
||||
| ^^^^^ expected identifier, found keyword
|
||||
|
||||
error: expected `:`, found `T`
|
||||
--> $DIR/missing-close-brace-in-struct.rs:4:7
|
||||
|
|
||||
LL | trait T {
|
||||
| ^ expected `:`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
struct S {
|
||||
let foo: (),
|
||||
//~^ ERROR expected identifier, found keyword `let`
|
||||
//~^^ ERROR expected `:`, found `foo`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,5 @@ error: expected identifier, found keyword `let`
|
|||
LL | let foo: (),
|
||||
| ^^^ expected identifier, found keyword
|
||||
|
||||
error: expected `:`, found `foo`
|
||||
--> $DIR/removed-syntax-field-let.rs:2:9
|
||||
|
|
||||
LL | let foo: (),
|
||||
| ^^^ expected `:`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue