Closed
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.