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
I've noticed a regression that happened between rustfmt 1.5.2-nightly (fe7454b 2023-06-19) and rustfmt 1.5.3-nightly (4651421 2023-06-20).
In my project [1], whenever I run cargo fmt, some comment lines are mangled unexpectedly. Here's the full diff: https://pastebin.com/raw/HwqgrCUz
If I disable wrap_comments=true in rustfmt.toml, the problem no longer occurs.
Interestingly, I couldn't reproduce the problem using a small demonstration program. It only happens when using rustfmt or cargo fmt in my project (which has around 75k LoC).
This is similar to #5835, but not quite the same problem.
Please let me know if you need more info to look into this.
@xxchan thanks for helping to look into this and for providing a workaround for the issue.
@rwestphal Thanks for the report. Confirming I can reproduce this with rustfmt 1.6.0-nightly (a9ae7462 2023-07-19). Here's a minimal reproducible example.
Basically #5423 will remove all spaces after item markers (+, 1., etc.), so I cannot tell it's a bug or feature, unlike #5835 which is definitely a bug.
#5836 is somewhat similar. i.e., the style of how to format a markdown list is controversial..
But you used comment // instead of doc comment ///. Not sure whether it's reasonable to assume // is markdown 🤔️
I believe we're incorrectly calling code that goes down the doc comment rewrite path, even when we're rewriting a normal comment. #5536 should solve the issue highlighted in #5862 (comment)
On further reflection I don't think that's the case.
@xxchan Do you have any interest in workin on the? Part of me thinks that the solution might be as simple as wrapping this in a check for is_doc_comment so we don't try to parse out code blocks or lists if we're not in a doc comment.
Activity
xxchan commentedon Jul 29, 2023
This looks exactly the same as #5835Oh, it's not..is due to numbered list, but why+is also affected 🤔️xxchan commentedon Jul 29, 2023
It seems #5423 also changed how unordered list works
xxchan commentedon Jul 29, 2023
In theory your graph contains markdown lists. You can change it to table characters or wrap it in "```", which will also make hovering doc nicer.
xxchan commentedon Jul 29, 2023
But you used comment
//instead of doc comment///. Not sure whether it's reasonable to assume//is markdown 🤔️Rust style guide doesn't mention Markdown
https://doc.rust-lang.org/nightly/style-guide/index.html#comments
Rustdoc says it uses Markdown
https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html?highlight=markdown#markdown
ytmimi commentedon Aug 1, 2023
@xxchan thanks for helping to look into this and for providing a workaround for the issue.
@rwestphal Thanks for the report. Confirming I can reproduce this with
rustfmt 1.6.0-nightly (a9ae7462 2023-07-19). Here's a minimal reproducible example.input
output (using
wrap_comments=true):xxchan commentedon Aug 4, 2023
Basically #5423 will remove all spaces after item markers (
+,1., etc.), so I cannot tell it's a bug or feature, unlike #5835 which is definitely a bug.#5836 is somewhat similar. i.e., the style of how to format a markdown list is controversial..
ytmimi commentedon Aug 25, 2023
I believe we're incorrectly calling code that goes down the doc comment rewrite path, even when we're rewriting a normal comment. #5536 should solve the issue highlighted in #5862 (comment)On further reflection I don't think that's the case.
ytmimi commentedon Aug 30, 2023
@xxchan Do you have any interest in workin on the? Part of me thinks that the solution might be as simple as wrapping this in a check for
is_doc_commentso we don't try to parse out code blocks or lists if we're not in a doc comment.rustfmt/src/comment.rs
Lines 806 to 813 in f89cd3c
ci: add PR code formatting check
ci: add PR code formatting check
ci: add PR code formatting check
ci: add PR code formatting check