Enforce rust keyword order
Rust keyword should be used in a given order
pubdefaultconstasyncunsafeextern
Rust provides multiple messages and notes to help with that:
5 | extern const pub fn myfun() {
| -------^^^^^
| | |
| | expected `fn`
| help: `const` must come before `extern`: `const extern`
|
= note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
- We do have some
FunctionQualifierstructure to store the state of a function but not all those informations are kept in it. - We parse in different ways those qualifiers and provide multiple error message.
We should probably unify all those under one same structure (FunctionQualifier) and create a function to parse a FunctionQualifier that could be used everytime we expect a function.
This function could emit an error as well as a note (rust_note) when the syntax is wrong.
Choose an appropriate API for this function. Should it return an Optional<FunctionQualifier> ? Always return a FunctionQualifier with private/safe/sync attributes ? Probably the latter.
Maybe we should wait for #2815 to be merged ? Also, rustc use unified Function and ExternalFunction, maybe we should do the same since function body is now optional ?
I will try this