Skip to content

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

Open
@Emilgardis

Description

@Emilgardis

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions