Skip to content

rustfmt misformat when comment blocks are used #6426

Open
@knoxfighter

Description

@knoxfighter

misformat if two consecutive lines start with /* and the first line only contains comments and no actual code.

rustfmt doesn't correctly parse the end (*/) of /* code blocks. I use a code block to better see the offsets of each field of a type. Unfortunately this causes the second line /* to be changed to just * as if it is a continued comment line.
It only happens if the line starts with /* and has only comments in this line.

.rustfmt.toml:

wrap_comments = true

Input:

pub struct Type {
    /* 0x34 */ // _buf2: Buf<0x4>, // padding
    /* 0x4C */ pub field: u32,
}

Output:

pub struct Type {
    /* 0x34 */ // _buf2: Buf<0x4>, // padding
     * 0x4C */ pub field: u32,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-commentsbugPanic, non-idempotency, invalid code, etc.only-with-optionrequires a non-default option value to reproduce

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions