-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option space_before_fn_sig_paren (#4302)
* Add option space_after_function_name * Rename option and change type to bool * Revert "Rename option and change type to bool" This reverts commit 6350a15. * Cover other styles * Fix comments from review * Use simpler interface * Add indent_style test * Rename to space_before_fn_sig_paren
- Loading branch information
Showing
13 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// rustfmt-max_width: 30 | ||
// Function space before function paren | ||
|
||
fn foo() { | ||
// ... | ||
} | ||
fn foo_with_multi_lined(a: u32, b: u32, c: u32) { | ||
// ... | ||
} | ||
fn foo<T>(bar: T) { | ||
// ... | ||
} | ||
fn foo<T>(a: T, b: u32, c: u32) { | ||
// ... | ||
} | ||
fn foo<T: Foo + Bar, F: FooBar>(a: T, b: u32, c: u32) { | ||
// ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// Function space before function paren | ||
|
||
fn lorem() { | ||
// body | ||
} | ||
|
||
fn lorem(ipsum: usize) { | ||
// body | ||
} | ||
|
||
fn lorem<T>(ipsum: T) | ||
where | ||
T: Add + Sub + Mul + Div, | ||
{ | ||
// body | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/source/configs/space_before_fn_sig_paren/indent_style.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// rustfmt-indent_style: Visual | ||
// rustfmt-max_width: 30 | ||
// Function space before function paren | ||
|
||
fn foo() { | ||
// ... | ||
} | ||
fn foo_with_multi_lined(a: u32, b: u32, c: u32) { | ||
// ... | ||
} | ||
fn foo<T>(bar: T) { | ||
// ... | ||
} | ||
fn foo<T>(a: T, b: u32, c: u32) { | ||
// ... | ||
} | ||
fn foo<T: Foo + Bar, F: FooBar>(a: T, b: u32, c: u32) { | ||
// ... | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/source/configs/space_before_fn_sig_paren/max_width.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// rustfmt-max_width: 118 | ||
// Trait space before function paren | ||
|
||
trait Story { | ||
fn swap_context<T: 'static + Context + Send + Sync>(&mut self, context: T) -> Option<Box<Context + Send + Sync>>; | ||
} | ||
|
||
impl Story for () { | ||
fn swap_context<T: 'static + Context + Send + Sync>(&mut self, context: T) -> Option<Box<Context + Send + Sync>> { | ||
// ... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// Trait space before function paren | ||
|
||
trait Story { | ||
fn swap_context<T>(&mut self, context: T) -> Option<Box<Context>> | ||
where | ||
T: Context; | ||
} | ||
|
||
impl Story { | ||
fn swap_context<T>(&mut self, context: T) -> Option<Box<Context>> | ||
where | ||
T: Context, | ||
{ | ||
// ... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// rustfmt-max_width: 30 | ||
// Function space before function paren | ||
|
||
fn foo () { | ||
// ... | ||
} | ||
fn foo_with_multi_lined ( | ||
a: u32, | ||
b: u32, | ||
c: u32, | ||
) { | ||
// ... | ||
} | ||
fn foo<T> (bar: T) { | ||
// ... | ||
} | ||
fn foo<T> ( | ||
a: T, | ||
b: u32, | ||
c: u32, | ||
) { | ||
// ... | ||
} | ||
fn foo< | ||
T: Foo + Bar, | ||
F: FooBar, | ||
> ( | ||
a: T, | ||
b: u32, | ||
c: u32, | ||
) { | ||
// ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// Function space before function paren | ||
|
||
fn lorem () { | ||
// body | ||
} | ||
|
||
fn lorem (ipsum: usize) { | ||
// body | ||
} | ||
|
||
fn lorem<T> (ipsum: T) | ||
where | ||
T: Add + Sub + Mul + Div, | ||
{ | ||
// body | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/target/configs/space_before_fn_sig_paren/indent_style.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// rustfmt-indent_style: Visual | ||
// rustfmt-max_width: 30 | ||
// Function space before function paren | ||
|
||
fn foo () { | ||
// ... | ||
} | ||
fn foo_with_multi_lined (a: u32, | ||
b: u32, | ||
c: u32) | ||
{ | ||
// ... | ||
} | ||
fn foo<T> (bar: T) { | ||
// ... | ||
} | ||
fn foo<T> (a: T, | ||
b: u32, | ||
c: u32) { | ||
// ... | ||
} | ||
fn foo<T: Foo + Bar, | ||
F: FooBar> ( | ||
a: T, | ||
b: u32, | ||
c: u32) { | ||
// ... | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/target/configs/space_before_fn_sig_paren/max_width.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// rustfmt-max_width: 118 | ||
// Trait space before function paren | ||
|
||
trait Story { | ||
fn swap_context<T: 'static + Context + Send + Sync> (&mut self, context: T) | ||
-> Option<Box<Context + Send + Sync>>; | ||
} | ||
|
||
impl Story for () { | ||
fn swap_context<T: 'static + Context + Send + Sync> ( | ||
&mut self, | ||
context: T, | ||
) -> Option<Box<Context + Send + Sync>> { | ||
// ... | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// rustfmt-space_before_fn_sig_paren: true | ||
// Trait space before function paren | ||
|
||
trait Story { | ||
fn swap_context<T> (&mut self, context: T) -> Option<Box<Context>> | ||
where | ||
T: Context; | ||
} | ||
|
||
impl Story { | ||
fn swap_context<T> (&mut self, context: T) -> Option<Box<Context>> | ||
where | ||
T: Context, | ||
{ | ||
// ... | ||
} | ||
} |