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

Fix for handling empty code block in doc comment #5601

Merged

Conversation

davidBar-On
Copy link
Contributor

Fixes #5234

Suggested fix is by trimming the code block, as discussed in (now obsolete) PR #4902.

Copy link
Contributor

@ytmimi ytmimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening up this new PR!

@tgross35
Copy link
Contributor

Related open PR: #5235

@ytmimi
Copy link
Contributor

ytmimi commented Nov 19, 2022

@tgross35 thanks, I was aware of the other PR and was planning on closing it. Will do so now

@calebcartwright
Copy link
Member

While I think there's little rationale and utility in practice for having a doc comment codeblock with nothing but whitespace, and obviously a panic is unacceptable, but do we feel that trimming that whitespace is the correct/desirable behavior?

@tgross35
Copy link
Contributor

Imho I generally expect rustfmt to eliminate unneeded whitespace, so I would say yes. This would be consistent with what happens when it gets a file with no content and only blank lines - it removes them.

@calebcartwright
Copy link
Member

Imho I generally expect rustfmt to eliminate unneeded whitespace, so I would say yes. This would be consistent with what happens when it gets a file with no content and only blank lines - it removes them.

Yeah that's a fair way of looking at it 👍

@calebcartwright calebcartwright merged commit b08130c into rust-lang:master Jan 29, 2023
@calebcartwright calebcartwright added release-notes Needs an associated changelog entry and removed pr-ready-to-merge labels Jan 29, 2023
@calebcartwright calebcartwright removed the release-notes Needs an associated changelog entry label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

format_code_in_doc_comments causes panic for empty code blocks.
4 participants