From 07ee472cd18925be45d424d9cfd59c441ea9c9a7 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sat, 1 Feb 2020 19:24:51 +0000 Subject: Avoid qualified path recovery when not followed by identifier --- src/librustc_parse/parser/path.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/librustc_parse/parser') 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) /// >: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; } -- cgit 1.4.1-3-g733a5