Skip to content

Comments removed before unnecessary semicolon #4383

@HactarCE

Description

@HactarCE

Describe the bug

When rustfmt deletes an unnecessary semicolon, it also deletes comments immediately before that semicolon.

Obviously this isn't a common scenario, but rustfmt should never delete comments.

To Reproduce

Try it on the Rust Playground

Expected behavior

The extraneous semicolon should be deleted but the comment should remain.

Meta

  • rustfmt version: 1.4.20-nightly (2020-08-09 48f6c32)
  • From where did you install rustfmt?: Rust Playground (also rustup)
  • How do you run rustfmt: Rust Playground (also cargo fmt)

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-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