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

Formatting empty where clause with trailing_comma = "Never" leaves trailing whitespace, causing an error. #5012

Closed
Esper89 opened this issue Sep 30, 2021 · 1 comment · Fixed by #5019
Labels
bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce

Comments

@Esper89
Copy link

Esper89 commented Sep 30, 2021

Formatting the following code with trailing_comma = "Never" will leave trailing whitespace:

pub struct Matrix<T, const R: usize, const C: usize>
where
    [T; R * C]: 
{
    contents: [T; R * C]
}
    [T; R * C]: 
               ^ right here

Without trailing_comma = "Never", the line is formatted like this:

    [T; R * C]: ,

The trailing whitespace causes rustfmt has failed to format, resulting in the whole file not being formatted.

A workaround is to leave a comment at the end of the line like this:

    [T; R * C]:  //
@calebcartwright
Copy link
Member

Thanks for the report!

@calebcartwright calebcartwright added bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce labels Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants