syntax: Fix regression in diagnostics for patterns in trait method parameters

This commit is contained in:
Vadim Petrochenkov 2019-01-01 19:14:00 +03:00
parent cae164753f
commit 3df500db29
3 changed files with 15 additions and 2 deletions

View file

@ -1866,7 +1866,8 @@ impl<'a> Parser<'a> {
let parser_snapshot_before_ty = self.clone();
self.eat_incorrect_doc_comment("a method argument's type");
let mut ty = self.parse_ty();
if ty.is_ok() && self.token == token::Colon {
if ty.is_ok() && self.token != token::Comma &&
self.token != token::CloseDelim(token::Paren) {
// This wasn't actually a type, but a pattern looking like a type,
// so we are going to rollback and re-parse for recovery.
ty = self.unexpected();