about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRob Pilling <robpilling@gmail.com>2020-02-01 19:24:51 +0000
committerRob Pilling <robpilling@gmail.com>2020-02-01 19:38:52 +0000
commit07ee472cd18925be45d424d9cfd59c441ea9c9a7 (patch)
tree5fb56733fad30b23cd62b16e1f40ff47230b6de4 /src
parent991d2ee282837a0ca3ec5a730e081274d37fa8b0 (diff)
downloadrust-07ee472cd18925be45d424d9cfd59c441ea9c9a7.tar.gz
rust-07ee472cd18925be45d424d9cfd59c441ea9c9a7.zip
Avoid qualified path recovery when not followed by identifier
Diffstat (limited to 'src')
-rw-r--r--src/librustc_parse/parser/path.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_parse/parser/path.rs b/src/librustc_parse/parser/path.rs
index 5aa14c1739f..a09eb42dcfe 100644
--- a/src/librustc_parse/parser/path.rs
+++ b/src/librustc_parse/parser/path.rs
@@ -82,13 +82,17 @@ impl<'a> Parser<'a> {
     }
 
     /// Recover from an invalid single colon, when the user likely meant a qualified path.
+    /// We avoid emitting this if not followed by an identifier, as our assumption that the user
+    /// intended this to be a qualified path may not be correct.
     ///
     /// ```ignore (diagnostics)
     /// <Bar as Baz<T>>:Qux
     ///                ^ help: use double colon
     /// ```
     fn recover_colon_before_qpath_proj(&mut self) -> bool {
-        if self.token.kind != token::Colon {
+        if self.token.kind != token::Colon
+            || self.look_ahead(1, |t| !t.is_ident() || t.is_reserved_ident())
+        {
             return false;
         }