Skip to content

Blank document comment in trait raises error different from with that in function. #56766

@bkda

Description

@bkda

If I use document comment that doesn't document anything in function,

fn test(){
    println!("Hello world");
    ///
}

it will raise error:

error[E0585]: found a documentation comment that doesn't document anything.

But if I use this in trait, the error confuses me.

trait User{
    fn test();
    ///
}
fn main() {
    println!("Hello world");
}
error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `}`
 --> src/main.rs:4:1
  |
3 |     ///
  |        - expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe` here
4 | }
  | ^ unexpected token

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions