-
Notifications
You must be signed in to change notification settings - Fork 1k
file-lines modifies unselected fn signature lines #6864
Copy link
Copy link
Open
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issueStatus: a Minimal Complete and Verifiable Example has been found for this issueUO-file_linesUnstable option: file_linesUnstable option: file_lines
Metadata
Metadata
Assignees
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICES-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issueStatus: a Minimal Complete and Verifiable Example has been found for this issueUO-file_linesUnstable option: file_linesUnstable option: file_lines
Type
Fields
Give feedbackNo fields configured for issues without a type.
If the opening brace of a function is on a separate line, then when partially formatting the body of the function with
--file-linesthe opening brace can be moved to the previous line, even if neither of those lines were selected.Summary
Consider the following file
test.rswhich defines a function where the opening brace of the function is on its own line:I would like to use
--file-lines '[{"file":"test.rs","range":[5,5]}]'to format just the last line of the function.Expected Behavior
Only the selected line is formatted:
Actual Behavior
The selected line, the preceding line, and the first two lines of the function are modified:
I have a separate issue up for the fact that line 4 is also modified (#6863), this issue is meant to focus on the fact that lines 1-2 are modified even though they are outside the selected range.
Configuration
rustfmtcli options used:rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[5,5]}]' test.rs