Skip to content

rustfmt produces invalid syntax for struct with unmatched quote in trailing block comment #4744

Closed
@soruh

Description

@soruh

Describe the bug

This code:

struct Foo {
    field: u8, /* test " */
}

is turned into this by running cargo fmt

struct Foo {
    field: u8, /* test " */
               }
}

A version without the unmatched quote is formatted correctly:
This code:

struct Foo {
    field: u8, /* test */
}

is not changed

To Reproduce

run rustfmt on the above code.

Expected behavior

rustfmt should not produce the erroneous closing brace

Meta

  • rustfmt version:
rustfmt 1.4.36-nightly (7de6968 2021-02-07)
cargo 1.52.0-nightly (c68432f1e 2021-03-02)
rustc 1.52.0-nightly (234781afe 2021-03-07)
  • From where did you install rustfmt?:
rustup
  • How do you run rustfmt:
- cargo fmt
- rust-analyser in vscode

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