Skip to content

Wrapping long trailing comments #6726

@yshui

Description

@yshui

(from #5577 (comment), sorry for the off-topic comment!)

Don't align unrelated trailing comments after items or at the end of blocks

#5577 (comment)

I got hit by this change. There are occasions where I do want to break a trailing comment into multiple lines. Now I can't do that because rustfmt no longer align them.

If the intention is stopping unrelated comments from being aligned, is there a way for me to indicate that those comments are indeed related?

but i want make this issue more general. right now, rustfmt is not able to wrap long trailing comments:

func(); // a really long explanation of what this function does and why it does it and why it should be called here and such and such.

desired behavior with wrap_comments=true:

func(); // a really long explanation of what this function
        // does and why it does it and why it should
        // be called here and such and such

actual behavior: nothing happens.

before style-edition=2024, i could still manually break the comment up and rustfmt will properly align the lines. after, i am no longer able to, since rustfmt will format it as:

func(); // a really long explanation of what this function
// does and why it does it and why it should
// be called here and such and such

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions