about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2022-03-27 06:05:18 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2022-03-27 06:05:18 +0000
commit157c67b7a8c47de44b47eed9611e5a97981553eb (patch)
tree5e62721ca297f35db20124b79bbf1603dfc13093 /compiler/rustc_parse/src
parent6874bd27f527b6c5f40e8fd866d91813da2df35a (diff)
downloadrust-157c67b7a8c47de44b47eed9611e5a97981553eb.tar.gz
rust-157c67b7a8c47de44b47eed9611e5a97981553eb.zip
Handle `,` to `;` substitution in arg params
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/path.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs
index 596099bf2de..93663a349f5 100644
--- a/compiler/rustc_parse/src/parser/path.rs
+++ b/compiler/rustc_parse/src/parser/path.rs
@@ -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