Skip to content

Commit c3e6be7

Browse files
refactor: rename KeepExisting->Preserve variant for match arm pipes (#4305)
1 parent 5947aaf commit c3e6be7

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

Diff for: Configurations.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,7 @@ See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
15501550
Controls whether to include a leading pipe on match arms
15511551

15521552
- **Default value**: `Never`
1553-
- **Possible values**: `Always`, `Never`, `KeepExisting`
1553+
- **Possible values**: `Always`, `Never`, `Preserve`
15541554
- **Stable**: Yes
15551555

15561556
#### `Never` (default):
@@ -1607,7 +1607,7 @@ fn foo() {
16071607
}
16081608
```
16091609

1610-
#### `KeepExisting`:
1610+
#### `Preserve`:
16111611
```rust
16121612
fn foo() {
16131613
match foo {

Diff for: src/config/options.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ pub enum MatchArmLeadingPipe {
355355
Always,
356356
/// Never emit leading pipes on match arms
357357
Never,
358-
/// Maintain any existing leading pipes
359-
KeepExisting,
358+
/// Preserve any existing leading pipes
359+
Preserve,
360360
}
361361

362362
#[cfg(test)]

Diff for: src/formatting/matches.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ fn rewrite_match_arm(
244244
// 2 = `| `
245245
let (pipe_offset, pipe_str) = match context.config.match_arm_leading_pipes() {
246246
MatchArmLeadingPipe::Never => (0, ""),
247-
MatchArmLeadingPipe::KeepExisting if !has_leading_pipe => (0, ""),
248-
MatchArmLeadingPipe::KeepExisting | MatchArmLeadingPipe::Always => (2, "| "),
247+
MatchArmLeadingPipe::Preserve if !has_leading_pipe => (0, ""),
248+
MatchArmLeadingPipe::Preserve | MatchArmLeadingPipe::Always => (2, "| "),
249249
};
250250

251251
// Patterns

Diff for: tests/source/configs/match_arm_leading_pipes/keep_existing.rs renamed to tests/source/configs/match_arm_leading_pipes/preserve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-match_arm_leading_pipes: KeepExisting
1+
// rustfmt-match_arm_leading_pipes: Preserve
22

33
fn foo() {
44
match foo {

Diff for: tests/target/configs/match_arm_leading_pipes/keep_existing.rs renamed to tests/target/configs/match_arm_leading_pipes/preserve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// rustfmt-match_arm_leading_pipes: KeepExisting
1+
// rustfmt-match_arm_leading_pipes: Preserve
22

33
fn foo() {
44
match foo {

0 commit comments

Comments
 (0)