From 1b54ad0585ca25b779be93d1149930664f722dc3 Mon Sep 17 00:00:00 2001 From: akabinds Date: Thu, 18 Aug 2022 16:14:04 -0500 Subject: added improved diagnostic for a function defined with an invalid qualifier --- compiler/rustc_parse/src/parser/diagnostics.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index f4c6b33a529..3bc00635013 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -611,6 +611,15 @@ impl<'a> Parser<'a> { appl, ); } + + if ["def", "fun", "func", "function"].contains(&symbol.as_str()) { + err.span_suggestion_short( + self.prev_token.span, + &format!("write `fn` instead of `{symbol}` to declare a function"), + "fn", + appl, + ); + } } // Add suggestion for a missing closing angle bracket if '>' is included in expected_tokens -- cgit 1.4.1-3-g733a5