Skip to content

fix: #6520, move comment above line if it would cross out the type in…#6577

Open
MarcusGrass wants to merge 1 commit intorust-lang:mainfrom
MarcusGrass:mg/6520-fix-arg-comment-miscompilation
Open

fix: #6520, move comment above line if it would cross out the type in…#6577
MarcusGrass wants to merge 1 commit intorust-lang:mainfrom
MarcusGrass:mg/6520-fix-arg-comment-miscompilation

Conversation

@MarcusGrass
Copy link
Contributor

… a function arg.

fixes #6520

A bit unsure about this one.

The problem is that if you have a comment that spans to the end of the line, then pushing the ty_str after it will make that ty_str part of the comment.

It's similar to this #2976 except isolates comments that do not close themselves.

There's some nuance here, since the decision has to be made where to put the comment. Putting it on top is the simplest, putting it last on the line would require making sure that nothing follows the comment.

Lastly, checking the comment style processes the span again, which is why that's only done conditionally if there is some comment there, so it shouldn't hit most cases. The alternative is a bigger refactor where either the comment style is identified before being passed down to identify_comment, or that metadata is propagated up from the caller. Neither of those options seemed nice.

@MarcusGrass MarcusGrass force-pushed the mg/6520-fix-arg-comment-miscompilation branch from dc163d8 to a3fa7fb Compare October 12, 2025 16:54
@jieyouxu jieyouxu added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed pr-not-reviewed labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formatting a line comment inbetween a function parameter and its type results in the type being commented out

3 participants