Skip to content

Trailing comma is duplicated when obstructed by comments #3876

Closed
@Proximyst

Description

@Proximyst

In the following snippet, there is a trailing comment following the entire builder chain after normal_message:

    // Client set up {{{
    discord_client.with_framework(
        StandardFramework::new()
            // Framework configuration {{{{
            .configure(|c| {
                c.with_whitespace(true) // allow `{prefix} command`
                    .case_insensitivity(true) // allow `{prefix}cOmMaNd`
                    .no_dm_prefix(true) // allow `command` in DMs
                    .prefix(config.prefix()) // set the prefix to use for commands
                    .delimiters(vec![" "]) // split arguments at space; `{prefix} test a b c` => [{prefix test}, a, b, c]
            })
            // Normal message {{{{
            .normal_message(|_ctx, _msg| {
            })
            // }}}}
            ,
            // wee
    );
    // }}}

When I run rustfmt on this with default settings:

$ rustfmt --version
rustfmt 1.4.8-nightly (afb1ee1 2019-09-08)

I get this result:

    // Client set up {{{
    discord_client.with_framework(
        StandardFramework::new()
            // Framework configuration {{{{
            .configure(|c| {
                c.with_whitespace(true) // allow `{prefix} command`
                    .case_insensitivity(true) // allow `{prefix}cOmMaNd`
                    .no_dm_prefix(true) // allow `command` in DMs
                    .prefix(config.prefix()) // set the prefix to use for commands
                    .delimiters(vec![" "]) // split arguments at space; `{prefix} test a b c` => [{prefix test}, a, b, c]
            })
            // Normal message {{{{
            .normal_message(|_ctx, _msg| {}), // }}}}
                                              , // uh oh.. there's a comma over this one as well! ;o
                                              // wee
    );
    // }}}

The comma clearly duplicated where it wasn't supposed to.
The //uh oh comment was added in the issue creation; the rest was from my source code, except "a bit" stripped down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1x-backport:pendingFixed/resolved in source but not yet backported to a 1x branch and releasea-chainsa-commentsbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions