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

rustfmt cannot format code example with long #-hiding line #5627

Open
Emilgardis opened this issue Dec 6, 2022 · 2 comments
Open

rustfmt cannot format code example with long #-hiding line #5627

Emilgardis opened this issue Dec 6, 2022 · 2 comments
Assignees
Labels
a-comments only-with-option requires a non-default option value to reproduce poor-formatting

Comments

@Emilgardis
Copy link
Contributor

I've had an issue with format_code_in_doc_comments for some time and decided to finally try to fix it. The issue was that some of my examples did not get formatted.

While trying to implement a fix I managed to find the cause (#) and a workaround, but I'm not able to go further. A minimal repro here

https://github.com/Emilgardis/rustfmt-no-format/blob/main/src/lib.rs

and the fix being to increase max_width (in this example to 101)

Now, the line that is problematic is

/// # let long: Fooooooooooooooooooooooooooooooooo = Fooooooooooooooooooooooooooooooooo::hi();

however, that's only 94 characters in total starting from the start of the line, not from /// .

My expectation with #-hiding in rust examples is that it should not prevent this, and in fact, removing the # you can make the line as long as you want and the other code (and the long line) gets formatted.

@ytmimi ytmimi added poor-formatting a-comments only-with-option requires a non-default option value to reproduce labels Dec 7, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Dec 7, 2022

Thanks for reaching out!

I think I know what's going on here, but need to investigate a little further. I'll follow up once I've had a chance to dive a little deeper into this.

@ytmimi ytmimi self-assigned this Dec 7, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Dec 7, 2022

Linking tracking issue for format_code_in_doc_comments #3348

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 poor-formatting
Projects
None yet
Development

No branches or pull requests

2 participants