Skip to content

Commit 6350a15

Browse files
committed
Rename option and change type to bool
1 parent a626b1e commit 6350a15

File tree

10 files changed

+54
-64
lines changed

10 files changed

+54
-64
lines changed

Configurations.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,15 +2063,47 @@ fn lorem<T:Eq>(t:T) {
20632063

20642064
See also: [`space_before_colon`](#space_before_colon).
20652065

2066-
## `space_after_function_name`
2066+
## `space_before_colon`
2067+
2068+
Leave a space before the colon.
2069+
2070+
- **Default value**: `false`
2071+
- **Possible values**: `true`, `false`
2072+
- **Stable**: No (tracking issue: [#3365](https://github.com/rust-lang/rustfmt/issues/3365))
2073+
2074+
#### `false` (default):
2075+
2076+
```rust
2077+
fn lorem<T: Eq>(t: T) {
2078+
let lorem: Dolor = Lorem {
2079+
ipsum: dolor,
2080+
sit: amet,
2081+
};
2082+
}
2083+
```
20672084

2068-
Leave a space after the function name.
2085+
#### `true`:
20692086

2070-
- **Default value**: `"Never"`
2071-
- **Possible values**: `"AfterGenerics"`, `"Never"`
2087+
```rust
2088+
fn lorem<T : Eq>(t : T) {
2089+
let lorem : Dolor = Lorem {
2090+
ipsum : dolor,
2091+
sit : amet,
2092+
};
2093+
}
2094+
```
2095+
2096+
See also: [`space_after_colon`](#space_after_colon).
2097+
2098+
## `space_before_fn_params`
2099+
2100+
Leave a space before function parameters.
2101+
2102+
- **Default value**: `false`
2103+
- **Possible values**: `true`, `false`
20722104
- **Stable**: No (tracking issue: [#3564](https://github.com/rust-lang/rustfmt/issues/3564))
20732105

2074-
#### `"Never"` (default):
2106+
#### `false` (default):
20752107

20762108
```rust
20772109
fn lorem() {
@@ -2090,7 +2122,7 @@ where
20902122
}
20912123
```
20922124

2093-
#### `"AfterGenerics"`:
2125+
#### `true`:
20942126

20952127
```rust
20962128
fn lorem () {
@@ -2109,38 +2141,6 @@ where
21092141
}
21102142
```
21112143

2112-
## `space_before_colon`
2113-
2114-
Leave a space before the colon.
2115-
2116-
- **Default value**: `false`
2117-
- **Possible values**: `true`, `false`
2118-
- **Stable**: No (tracking issue: [#3365](https://github.com/rust-lang/rustfmt/issues/3365))
2119-
2120-
#### `false` (default):
2121-
2122-
```rust
2123-
fn lorem<T: Eq>(t: T) {
2124-
let lorem: Dolor = Lorem {
2125-
ipsum: dolor,
2126-
sit: amet,
2127-
};
2128-
}
2129-
```
2130-
2131-
#### `true`:
2132-
2133-
```rust
2134-
fn lorem<T : Eq>(t : T) {
2135-
let lorem : Dolor = Lorem {
2136-
ipsum : dolor,
2137-
sit : amet,
2138-
};
2139-
}
2140-
```
2141-
2142-
See also: [`space_after_colon`](#space_after_colon).
2143-
21442144
## `spaces_around_ranges`
21452145

21462146
Put spaces around the .., ..=, and ... range operators

src/config.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ create_config! {
9494
spaces_around_ranges: bool, false, false, "Put spaces around the .. and ..= range operators";
9595
binop_separator: SeparatorPlace, SeparatorPlace::Front, true,
9696
"Where to put a binary operator when a binary expression goes multiline";
97-
space_after_function_name: SpaceAfterFunctionName, SpaceAfterFunctionName::Never, false,
98-
"Leave a space after the function name.";
97+
space_before_fn_params: bool, false, false, "Leave a space before function parameters.";
9998

10099
// Misc.
101100
remove_nested_parens: bool, true, true, "Remove nested parens";
@@ -599,7 +598,7 @@ space_after_colon = true
599598
space_around_attr_eq = true
600599
spaces_around_ranges = false
601600
binop_separator = "Front"
602-
space_after_function_name = "Never"
601+
space_before_fn_params = false
603602
remove_nested_parens = true
604603
combine_control_expr = true
605604
overflow_delimited_expr = false

src/config/options.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,6 @@ pub enum MatchArmLeadingPipe {
359359
KeepExisting,
360360
}
361361

362-
#[config_type]
363-
/// Where to add spaces after the function name.
364-
pub enum SpaceAfterFunctionName {
365-
/// Never add spaces.
366-
Never,
367-
/// Add a space, and put generics before the space.
368-
AfterGenerics,
369-
}
370-
371362
#[cfg(test)]
372363
mod test {
373364
use std::path::PathBuf;

src/formatting/items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::{ast, ptr};
99
use rustc_span::{source_map, symbol, BytePos, Span, DUMMY_SP};
1010

1111
use crate::config::lists::*;
12-
use crate::config::{BraceStyle, Config, IndentStyle, SpaceAfterFunctionName};
12+
use crate::config::{BraceStyle, Config, IndentStyle};
1313
use crate::formatting::{
1414
attr::filter_inline_attrs,
1515
comment::{
@@ -2228,7 +2228,7 @@ fn rewrite_fn_base(
22282228
.last()
22292229
.map_or(false, |l| l.trim_start().len() == 1);
22302230

2231-
if let SpaceAfterFunctionName::AfterGenerics = context.config.space_after_function_name() {
2231+
if context.config.space_before_fn_params() {
22322232
result.push(' ');
22332233
}
22342234

tests/source/configs/space_after_function_name/fn_after_generics.rs renamed to tests/source/configs/space_before_fn_params/fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// rustfmt-space_after_function_name: AfterGenerics
2-
// Function space after function name
1+
// rustfmt-space_before_fn_params: true
2+
// Function space before function parameters
33

44
fn lorem() {
55
// body

tests/source/configs/space_after_function_name/trait_after_generics.rs renamed to tests/source/configs/space_before_fn_params/trait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// rustfmt-space_after_function_name: AfterGenerics
2-
// Trait space after function name
1+
// rustfmt-space_before_fn_params: true
2+
// Trait space before function parameters
33

44
trait Story {
55
fn swap_context<T>(&mut self, context: T) -> Option<Box<Context>>

tests/source/configs/space_after_function_name/width_heuristics.rs renamed to tests/source/configs/space_before_fn_params/width_heuristics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// rustfmt-space_after_function_name: AfterGenerics
1+
// rustfmt-space_before_fn_params: true
22
// rustfmt-max_width: 118
3-
// Trait space after function name
3+
// Trait space before function parameters
44

55
trait Story {
66
fn swap_context<T: 'static + Context + Send + Sync>(&mut self, context: T) -> Option<Box<Context + Send + Sync>>;

tests/target/configs/space_after_function_name/fn_after_generics.rs renamed to tests/target/configs/space_before_fn_params/fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// rustfmt-space_after_function_name: AfterGenerics
2-
// Function space after function name
1+
// rustfmt-space_before_fn_params: true
2+
// Function space before function parameters
33

44
fn lorem () {
55
// body

tests/target/configs/space_after_function_name/trait_after_generics.rs renamed to tests/target/configs/space_before_fn_params/trait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// rustfmt-space_after_function_name: AfterGenerics
2-
// Trait space after function name
1+
// rustfmt-space_before_fn_params: true
2+
// Trait space before function parameters
33

44
trait Story {
55
fn swap_context<T> (&mut self, context: T) -> Option<Box<Context>>

tests/target/configs/space_after_function_name/width_heuristics.rs renamed to tests/target/configs/space_before_fn_params/width_heuristics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// rustfmt-space_after_function_name: AfterGenerics
1+
// rustfmt-space_before_fn_params: true
22
// rustfmt-max_width: 118
3-
// Trait space after function name
3+
// Trait space before function parameters
44

55
trait Story {
66
fn swap_context<T: 'static + Context + Send + Sync> (&mut self, context: T)

0 commit comments

Comments
 (0)