Skip to content

Comment after last || branch in an if clause is forced to a separate line #6207

Open
@nc7s

Description

@nc7s

This code:

if lower.contains("expiry date:")
|| lower.contains("expires:") /* .am, .br, .dk, .edu, .is, .lt, .se, .ua */
|| lower.contains("expire:") /* .ar, .cz */
{
	// ...
}

is formatted to:

if lower.contains("expiry date:")
|| lower.contains("expires:") /* .am, .br, .dk, .edu, .is, .lt, .se, .ua */
|| lower.contains("expire:")
/* .ar, .cz */
{
	// ...
}

Supposedly rustfmt is assuming the comment between if and { is comment for the entire if clause. Ideally it should take || into account and take the comment before { as comment for the last || branch. (Probably also &&)

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