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 committed May 29, 2018
1 parent 4f6d9bf commit daa5b81
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 @@ -767,6 +767,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 @@ -2527,8 +2530,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 daa5b81

Please sign in to comment.