Handle ,
to ;
substitution in arg params
This commit is contained in:
parent
6874bd27f5
commit
157c67b7a8
4 changed files with 36 additions and 7 deletions
|
@ -478,6 +478,23 @@ impl<'a> Parser<'a> {
|
|||
while let Some(arg) = self.parse_angle_arg(ty_generics)? {
|
||||
args.push(arg);
|
||||
if !self.eat(&token::Comma) {
|
||||
if self.token.kind == token::Semi
|
||||
&& self.look_ahead(1, |t| t.is_ident() || t.is_lifetime())
|
||||
{
|
||||
// Add `>` to the list of expected tokens.
|
||||
self.check(&token::Gt);
|
||||
// Handle `,` to `;` substitution
|
||||
let mut err = self.unexpected::<()>().unwrap_err();
|
||||
self.bump();
|
||||
err.span_suggestion_verbose(
|
||||
self.prev_token.span.until(self.token.span),
|
||||
"use a comma to separate type parameters",
|
||||
", ".to_string(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
continue;
|
||||
}
|
||||
if !self.token.kind.should_end_const_arg() {
|
||||
if self.handle_ambiguous_unbraced_const_arg(&mut args)? {
|
||||
// We've managed to (partially) recover, so continue trying to parse
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue