Skip to content

Commit 07ee472

Browse files
committed
Avoid qualified path recovery when not followed by identifier
1 parent 991d2ee commit 07ee472

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc_parse/parser/path.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,17 @@ impl<'a> Parser<'a> {
8282
}
8383

8484
/// Recover from an invalid single colon, when the user likely meant a qualified path.
85+
/// We avoid emitting this if not followed by an identifier, as our assumption that the user
86+
/// intended this to be a qualified path may not be correct.
8587
///
8688
/// ```ignore (diagnostics)
8789
/// <Bar as Baz<T>>:Qux
8890
/// ^ help: use double colon
8991
/// ```
9092
fn recover_colon_before_qpath_proj(&mut self) -> bool {
91-
if self.token.kind != token::Colon {
93+
if self.token.kind != token::Colon
94+
|| self.look_ahead(1, |t| !t.is_ident() || t.is_reserved_ident())
95+
{
9296
return false;
9397
}
9498

0 commit comments

Comments
 (0)