Skip to content

Commit

Permalink
Issue rust-lang#50974: Suboptimal error in case of duplicate , in s…
Browse files Browse the repository at this point in the history
…truct constructor
  • Loading branch information
lambtowolf authored and pietroalbini committed Jun 22, 2018
1 parent 7dae5c0 commit 7969b78
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ impl<'a> Parser<'a> {
err.span_label(self.span, format!("expected identifier, found {}", token_descr));
} else {
err.span_label(self.span, "expected identifier");
if self.token == token::Comma {
err.span_suggestion(self.span, "try removing a comma", ",".into());
}
}
err
}
Expand Down Expand Up @@ -2446,8 +2449,11 @@ impl<'a> Parser<'a> {
Err(mut e) => {
e.span_label(struct_sp, "while parsing this struct");
e.emit();
self.recover_stmt();
break;

if self.token != token::Comma {
self.recover_stmt();
break;
}
}
}

Expand Down

0 comments on commit 7969b78

Please sign in to comment.