Skip to content

trailing comma after function call chains may need a comment barrier #5165

Open
@ratmice

Description

@ratmice

When given a function call chain, and a comment rustfmt will move the comma above the comment,
which cause

fn main() {
    ().foo(
        ().foo
            .foo()
            .foo()
            .foo()
            .foo()
            .foo()
            .foo()
            .foo()
            .foo()
            .foo()
            .foo()
            //.foo()
            ,
    )
}

afterwords the last line looks like:
.foo(), //.foo()

Which moves the comment from the first parameter, to the second (nonexistent!) parameter if one were to uncomment it,
This makes the addition of a comment, followed by rustfmt, followed by the removal of a comment syntactically invalid which can be inconvenient.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions