Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nc7s opened this issue Jun 22, 2024 · 0 comments
Open

Comments

@nc7s
Copy link

nc7s commented Jun 22, 2024

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 &&)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants