diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-20 07:09:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-20 07:09:05 +0200 |
| commit | af89769c82eeae85d5e7ecac94ac97ede0f0f147 (patch) | |
| tree | d0854d61c9a2e3114a5960022b9fbb396d46a3c4 /compiler/rustc_parse/src | |
| parent | 1e47e8a9ee83f2b6e110f225f3738392088aa2a9 (diff) | |
| parent | 1b54ad0585ca25b779be93d1149930664f722dc3 (diff) | |
| download | rust-af89769c82eeae85d5e7ecac94ac97ede0f0f147.tar.gz rust-af89769c82eeae85d5e7ecac94ac97ede0f0f147.zip | |
Rollup merge of #100750 - akabinds:akabinds/improved-invalid-function-qual-error, r=davidtwco
improved diagnostic for function defined with `def`, `fun`, `func`, or `function` instead of `fn` Closes #99751
Diffstat (limited to 'compiler/rustc_parse/src')
| -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 eeedfd157be..744ec7e6114 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -640,6 +640,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 |
