Skip to content

Trailing doc comments in trait definition causes an error #4106

Closed
@brendanzab

Description

@brendanzab

trait_comments.rs

trait A {
    fn a();     /// doc comment
}

fn main() {}

error:

$ rustc trait_comments.rs 
trait_comments.rs:3:0: 3:1 error: unexpected token: `}`
trait_comments.rs:3 }

It seems to only be triple slashes that cause it - // comment compiles fine.

Edit: Interestingly it seems that this compiles fine:

trait A {
    fn a();     /// comment
    fn b();     // comment
}

fn main() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frontendArea: Compiler frontend (errors, parsing and HIR)A-grammarArea: The grammar of RustA-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions