You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very related to #5244 -- not sure if this should be merged with that. Either way, a similar behavior occurs with code snippets in comments. Given the following...
/// This is a comment with some code `foo bar`.
If the comment reaches the maximum width inside the code snippet, it'll break it up like so:
/// This is a comment with some code `foo
/// bar`
I think it would be more expected for it to treat the snippet as a single lexeme, and insert the line break prior to the start (foo).
I just want to call out that although this has to do with wrapping code snippets, I don't necessarily know if I'd say its related to #5244. Mostly the issue here is that rustfmt doesn't do any real parsing of doc comments to figure out if it's dealing with some markdown construct. Everything is just text. Some consideration is given to markdown items that start lines (headers, lists, quotes), but the list of things that rustfmt is looking out for in comments is pretty small.
This one will be a little tricky to solve since the code snippets could appear anywhere, not just at the start of each line.
Activity
ytmimi commentedon Mar 2, 2022
Thanks for another report!
I just want to call out that although this has to do with wrapping code snippets, I don't necessarily know if I'd say its related to #5244. Mostly the issue here is that rustfmt doesn't do any real parsing of doc comments to figure out if it's dealing with some markdown construct. Everything is just text. Some consideration is given to markdown items that start lines (headers, lists, quotes), but the list of things that rustfmt is looking out for in comments is pretty small.
This one will be a little tricky to solve since the code snippets could appear anywhere, not just at the start of each line.
PSeitz commentedon Mar 11, 2022
I have a similar problem when addressing types. They get split over multiple lines and are not valid links anymore
Fixes rust-lang#5250