Skip to content

file-lines changes whitespace outside of given range #5136

Open
@not-my-profile

Description

@not-my-profile
$ printf '\n\n\nmod test;' | rustfmt +nightly --unstable-features --file-lines []
mod test;
$ printf '    mod test;' | rustfmt +nightly --unstable-features --file-lines []
mod test;
$ printf '//! ' | rustfmt +nightly --unstable-features --file-lines [] | tr ' ' .
//!
$ printf '' | rustfmt +nightly --unstable-features --file-lines [] | tr $'\n' X
X
$ printf 'fn f(){} // what' | rustfmt +nightly --unstable-features --file-lines []
fn f(){}// what

Note that:

  • intial newlines are removed
  • initial whitespace is removed
  • the space after the doc comment is removed
  • a newline at the end of the file is added
  • a space before a comment is lost in certain cases

Why this is a problem
file-lines is meant to restrict the reformatting to specific sets of lines. Whitespace changes elsewhere are therefore undesirable.

#3397

Metadata

Metadata

Assignees

No one assigned

    Labels

    only-with-optionrequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions