-
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 lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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
I tried this code:
/// Some documentation. Below "async" is before "pub" by mistake.
async pub fn hello() {}
fn main() {
}
I expected to see this happen: a clear error message telling me about the mistake (async
before pub
).
Instead, this happened:
error: expected item after doc comment
--> src/main.rs:1:1
|
1 | /// Some documentation. Below "async" is before "pub" by mistake.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doc comment doesn't document anything
This is a confusing error message. Without the comment, the error is clearer (though arguably still not completely obvious):
error: expected item, found keyword `async`
--> src/main.rs:1:1
|
1 | async pub fn hello() {}
| ^^^^^ expected item
Meta
rustc --version --verbose
:
rustc 1.43.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.43.0
LLVM version: 10.0
Backtrace
No backtrace.
edward-shen, roy-work and AuroraLantean
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-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.