Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using doc comments where they aren't allowed should have a better error message #36946

Closed
solson opened this issue Oct 3, 2016 · 1 comment
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@solson
Copy link
Member

solson commented Oct 3, 2016

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.

cc @joshtriplett

@Aatch Aatch added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 4, 2016
@GuillaumeGomez
Copy link
Member

Seems like a good idea. Working on it.

eddyb added a commit to eddyb/rust that referenced this issue Oct 19, 2016
…athandturner

Add invalid doc comment help message

Fixes rust-lang#36946.

Any opinion on the message?
eddyb added a commit to eddyb/rust that referenced this issue Oct 19, 2016
…athandturner

Add invalid doc comment help message

Fixes rust-lang#36946.

Any opinion on the message?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants