diff options
| author | akabinds <staticxxd@gmail.com> | 2022-08-18 16:14:04 -0500 |
|---|---|---|
| committer | akabinds <staticxxd@gmail.com> | 2022-08-18 16:14:04 -0500 |
| commit | 1b54ad0585ca25b779be93d1149930664f722dc3 (patch) | |
| tree | 3f56da8171e0297af4739417f7f71c56e9e974dc /compiler/rustc_parse/src/parser | |
| parent | 801821d1560f84e4716fcbd9244ec959320a13d5 (diff) | |
| download | rust-1b54ad0585ca25b779be93d1149930664f722dc3.tar.gz rust-1b54ad0585ca25b779be93d1149930664f722dc3.zip | |
added improved diagnostic for a function defined with an invalid qualifier
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 9 |
1 files changed, 9 insertions, 0 deletions
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 |
