rustfmt cannot format code example with long `#`-hiding line
@ytmimi is already working on this.
Since Dec 7, 2022.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.