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: remove multiple trailing lines in comments #6163

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Jul 31, 2024

  1. Remove multiple trailing lines in comments

    Previously, rustfmt would remove one blank, trailing line in a comment
    every time it ran, so formatting was not idempotent if a comment had
    multiple trailing lines. Comments are only reformatted in this way if
    `comment::rewrite_comment_inner` is called, which is enabled by any of the
    config options `normalize_comments`, `wrap_comments`, or
    `format_code_in_doc_comments` (for doc comments only). Absent those
    config options, no trailing line reformatting occurs at all.
    
    In this commit, when the existing condition that detects a blank, trailing
    line is true, any preceding blank lines are removed from the reformatted
    comment. A source/target "system test" was added to prevent regression.
    
    Signed-off-by: Ross Williams <[email protected]>
    overhacked committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    c7504a2 View commit details
    Browse the repository at this point in the history
  2. Also remove trailing bare lines in comments

    Block comments with bare lines are handled differently than those
    without bare lines (unless `normalize_comments` is configured). If
    `normalize_comments` is false but `wrap_comments` is true, trailing
    blank lines should be removed from block comments, including those with
    bare lines.
    
    Signed-off-by: Ross Williams <[email protected]>
    overhacked committed Jul 31, 2024
    Configuration menu
    Copy the full SHA
    f66d7d8 View commit details
    Browse the repository at this point in the history