Closed
Description
Code: playpen
fn main() {
/// print to terminal
println!("Hello, world!");
}
Error:
rustc 1.14.0-nightly (289f3a4ca 2016-09-29)
error: attributes on non-item statements and expressions are experimental. (see issue #15701)
--> <anon>:2:5
|
2 | /// print to terminal
| ^^^^^^^^^^^^^^^^^^^^^
The current error message is pretty unfortunate for new users. Imagine someone saw ///
everywhere and just assumed it was the comment syntax. Then they are presented with this weird error about attributes, items, statements, experimental features, and issue numbers, and all they wanted to do was comment their code! Many advanced users don't even know doc comments desugar to attributes in my experience.
Ideally we would detect this and print a help
message suggesting the correct non-doc comment syntax.