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

Added comment line above any comment that starts with - #5088

Closed
DevinR528 opened this issue Nov 17, 2021 · 3 comments · Fixed by #5097
Closed

Added comment line above any comment that starts with - #5088

DevinR528 opened this issue Nov 17, 2021 · 3 comments · Fixed by #5097
Labels
a-comments only-with-option requires a non-default option value to reproduce

Comments

@DevinR528
Copy link

DevinR528 commented Nov 17, 2021

Any place a comment is added like:

// - 16 because we push in the above seq of instructions

rustfmt turns it into

//
// - 16 because we push in the above seq of instructions

I'm not sure if it's trying to be smart and add newline before what it thinks is a list item in the markdown or something else?

cargo fmt --version
rustfmt 1.4.38-nightly (891ca5f 2021-11-15)
@calebcartwright
Copy link
Member

Could you please provide a short, but reproducible example, and also include any non-default configuration options you are using?

I'm unable to reproduce this using as a standalone comment, so suspect there's config and/or context missing.

@calebcartwright calebcartwright added the needs-mcve needs a Minimal Complete and Verifiable Example label Nov 17, 2021
@DevinR528
Copy link
Author

DevinR528 commented Nov 18, 2021

It's wrap_comments = true sorry this should have been obviously helpful info. The problem goes away when turned off.

@ytmimi
Copy link
Contributor

ytmimi commented Nov 18, 2021

I'm able to reproduce this on the latest master rustfmt 1.4.38-nightly (eee8f041 2021-11-17) with the option wrap_comments=true using a slightly modified mcve:

 // - a

When I run cargo run --bin rustfmt -- --check --config=wrap_comments=true I get this diff

 // 
 // - a

And I get the following error:

error[internal]: left behind trailing whitespace
  |
1 | //
  |   ^
  |
  = note: set `error_on_unformatted = false` to suppress the warning against comments or string literals

warning: rustfmt has failed to format. See previous 1 errors.

@ytmimi ytmimi added a-comments only-with-option requires a non-default option value to reproduce and removed needs-mcve needs a Minimal Complete and Verifiable Example labels Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-comments only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants