Skip to content

Inconsistent Struct Body Opening Brace Placement After Where Clause #5507

Open
@ytmimi

Description

@ytmimi

When the body of a struct is empty or it only contains comments, the opening brace of the struct body is placed on the same line as the where clause. If the struct body is not empty, the opening brace is placed on a newline.

No configuration values are needed, and I was using rustfmt 1.5.1-nightly (841b4542 2022-08-17) when I came across this.

Input

struct EmptyBody<T>
    where T: Eq {
}

struct LineComment<T>
    where T: Eq {
    // body
}

struct BlockComment<T>
    where T: Eq {
    /* block comment */
}

struct HasBody<T>
    where T: Eq {
    x: T
}

Output

struct EmptyBody<T>
where
    T: Eq, {}

struct LineComment<T>
where
    T: Eq, {
    // body
}

struct BlockComment<T>
where
    T: Eq, {/* block comment */}

struct HasBody<T>
where
    T: Eq,
{
    x: T,
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions