Skip to content

Compiler fails with docstrings over constructor #2920

@strangeglyph

Description

@strangeglyph

Currently, class constructors can not be documented with the /** */-style docstrings, else the compiler complains about unexpected tokens.

This code:

fn main() {}

class foo {

    let bar: bool;

    /**
     * Creates a foo object
     */
    new() {
        self.bar = true;
        io::println("foo");
    }
}

produces the following output:

testpad.rs:10:4: 10:7 error: unexpected token: 'new'
testpad.rs:10     new() {
                  ^~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions