Skip to content

Doc comments are allowed on match arms #21823

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

Closed
simias opened this issue Jan 31, 2015 · 6 comments
Closed

Doc comments are allowed on match arms #21823

simias opened this issue Jan 31, 2015 · 6 comments
Labels
C-bug Category: This is a bug.

Comments

@simias
Copy link

simias commented Jan 31, 2015

A very minor issue but I noticed that rustc accepts to build code like this:

fn main() {
    match () {
        /// doc
        _ => (),
    };
}

I would expect an error at /// doc since there's no item to document here.

@alexchandel
Copy link

I would expect no error, just no documentation. Does rustdoc produce anything for this?

@simias
Copy link
Author

simias commented Mar 4, 2015

@alexchandel The problem is that using /// where it doesn't make sense usually produces an error, for instance this won't compile:

fn main() {
    /// Say hello world
    println!("Hello, world!")
}
<anon>:2:5: 2:24 error: expected item after doc comment
<anon>:2     /// Say hello world
             ^~~~~~~~~~~~~~~~~~~

So it's not very coherent.

@sfackler
Copy link
Member

sfackler commented Mar 4, 2015

It's parses because attributes are allowed on match arms, and /// foo desugars to #[doc = "foo"].

@steveklabnik
Copy link
Member

Triage: no change

@estebank
Copy link
Contributor

Current output:

warning: doc comment not used by rustdoc
 --> src/main.rs:3:9
  |
3 |         /// doc
  |         ^^^^^^^
  |
  = note: #[warn(unused_doc_comment)] on by default

@simias
Copy link
Author

simias commented Apr 19, 2018

Sounds acceptable, should I close this? It was not a huge issue to begin with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

6 participants