Skip to content

Wrapping long trailing comments #6726

Open

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

Activity

  1. added
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Nov 18, 2025
  2. changed the title [-]Wrapping trailing comments in `style-edition=2024`[/-] [+]Wrapping long trailing comments[/+] on Nov 18, 2025
  3. added
    P-lowLow priority
    and removed
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions