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

Block comment inside match adds unnecessary comma #6373

Open
mfarberbrodsky opened this issue Oct 23, 2024 · 1 comment · May be fixed by #6376
Open

Block comment inside match adds unnecessary comma #6373

mfarberbrodsky opened this issue Oct 23, 2024 · 1 comment · May be fixed by #6376
Labels
a-comments a-matches match arms, patterns, blocks, etc bug Panic, non-idempotency, invalid code, etc.

Comments

@mfarberbrodsky
Copy link

Using rustfmt 1.7.1-stable (eeb90cda 2024-09-04), In the following example:

fn main() {
    let x: Option<i32> = Some(10);
    let value = match x {
        Some(i) => i /* comment */,
        None => 0
    };
    println!("{}", value);
}

Rustfmt adds an additional comma before the block comment, which causes the following error:

error: expected pattern, found `,`
 --> src/test.rs:4:36
  |
4 |         Some(i) => i, /* comment */,
  |                                    ^ expected pattern

error: aborting due to 1 previous error
@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. a-comments a-matches match arms, patterns, blocks, etc labels Oct 23, 2024
@mfarberbrodsky
Copy link
Author

Hey, I debugged the issue and opened a PR to fix it. Will be happy to respond to any comments. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments a-matches match arms, patterns, blocks, etc bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants