-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
If I write this code:
#[cfg(FALSE)]
extern const fn hello() {}
error: expected `fn`, found keyword `const`
--> src/lib.rs:2:8
| ...
= note: keyword order for functions declaration is `default`, `pub`, `const`, `async`, `unsafe`, `extern`
That's a great message, very helpful... except the order is wrong. If I write:
#[cfg(FALSE)]
default pub const async unsafe extern fn hello() {}
The compiler gives me a weird error message.
The correct order is pub
, default
, const
, async
, unsafe
, extern
; in other words, pub
before everything else.
Indeed, the following code compiles without complaint:
#[cfg(FALSE)]
pub default const async unsafe extern fn hello() {}
(as well as other variants with pub(crate)
, crate
, etc)
The diagnostic suggestion should be fixed.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.