From d0165956fe070d12090896aa5546e509045471eb Mon Sep 17 00:00:00 2001 From: surechen Date: Thu, 26 Sep 2024 12:35:44 +0800 Subject: Add suggestion for removing invalid path separator `::` in function definition. for example: `fn invalid_path_separator::() {}` fixes: #130791 --- compiler/rustc_parse/src/parser/generics.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_parse/src/parser/generics.rs') diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index b9256daa725..5aebe716b0a 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -269,6 +269,13 @@ impl<'a> Parser<'a> { /// | ( < lifetimes , typaramseq ( , )? > ) /// where typaramseq = ( typaram ) | ( typaram , typaramseq ) pub(super) fn parse_generics(&mut self) -> PResult<'a, ast::Generics> { + // invalid path separator `::` in function definition + // for example `fn invalid_path_separator::() {}` + if self.eat_noexpect(&token::PathSep) { + self.dcx() + .emit_err(errors::InvalidPathSepInFnDefinition { span: self.prev_token.span }); + } + let span_lo = self.token.span; let (params, span) = if self.eat_lt() { let params = self.parse_generic_params()?; -- cgit 1.4.1-3-g733a5