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
This commit is contained in:
commit
af89769c82
9 changed files with 89 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue