Support where predicates on the same line
This commit is contained in:
parent
6f3c329500
commit
02a01350ff
8 changed files with 44 additions and 1 deletions
|
@ -92,6 +92,7 @@ create_config! {
|
||||||
fn_args_layout: Density,
|
fn_args_layout: Density,
|
||||||
fn_arg_indent: BlockIndentStyle,
|
fn_arg_indent: BlockIndentStyle,
|
||||||
where_indent: BlockIndentStyle, // Visual will be treated like Tabbed
|
where_indent: BlockIndentStyle, // Visual will be treated like Tabbed
|
||||||
|
where_layout: ListTactic,
|
||||||
generics_indent: BlockIndentStyle,
|
generics_indent: BlockIndentStyle,
|
||||||
struct_trailing_comma: SeparatorTactic,
|
struct_trailing_comma: SeparatorTactic,
|
||||||
struct_lit_trailing_comma: SeparatorTactic,
|
struct_lit_trailing_comma: SeparatorTactic,
|
||||||
|
@ -120,6 +121,7 @@ impl Default for Config {
|
||||||
fn_args_layout: Density::Tall,
|
fn_args_layout: Density::Tall,
|
||||||
fn_arg_indent: BlockIndentStyle::Visual,
|
fn_arg_indent: BlockIndentStyle::Visual,
|
||||||
where_indent: BlockIndentStyle::Tabbed,
|
where_indent: BlockIndentStyle::Tabbed,
|
||||||
|
where_layout: ListTactic::Vertical,
|
||||||
generics_indent: BlockIndentStyle::Visual,
|
generics_indent: BlockIndentStyle::Visual,
|
||||||
struct_trailing_comma: SeparatorTactic::Vertical,
|
struct_trailing_comma: SeparatorTactic::Vertical,
|
||||||
struct_lit_trailing_comma: SeparatorTactic::Vertical,
|
struct_lit_trailing_comma: SeparatorTactic::Vertical,
|
||||||
|
|
|
@ -823,7 +823,7 @@ impl<'a> FmtVisitor<'a> {
|
||||||
span_end);
|
span_end);
|
||||||
|
|
||||||
let fmt = ListFormatting {
|
let fmt = ListFormatting {
|
||||||
tactic: ListTactic::Vertical,
|
tactic: self.config.where_layout,
|
||||||
separator: ",",
|
separator: ",",
|
||||||
trailing_separator: SeparatorTactic::Never,
|
trailing_separator: SeparatorTactic::Never,
|
||||||
indent: offset,
|
indent: offset,
|
||||||
|
|
|
@ -28,6 +28,8 @@ pub enum ListTactic {
|
||||||
Mixed,
|
Mixed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl_enum_decodable!(ListTactic, Vertical, Horizontal, HorizontalVertical, Mixed);
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
|
||||||
pub enum SeparatorTactic {
|
pub enum SeparatorTactic {
|
||||||
Always,
|
Always,
|
||||||
|
|
|
@ -9,6 +9,7 @@ fn_args_paren_newline = true
|
||||||
fn_args_layout = "Tall"
|
fn_args_layout = "Tall"
|
||||||
fn_arg_indent = "Visual"
|
fn_arg_indent = "Visual"
|
||||||
where_indent = "Tabbed"
|
where_indent = "Tabbed"
|
||||||
|
where_layout = "Vertical"
|
||||||
generics_indent = "Visual"
|
generics_indent = "Visual"
|
||||||
struct_trailing_comma = "Vertical"
|
struct_trailing_comma = "Vertical"
|
||||||
struct_lit_trailing_comma = "Vertical"
|
struct_lit_trailing_comma = "Vertical"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// rustfmt-fn_arg_indent: Inherit
|
// rustfmt-fn_arg_indent: Inherit
|
||||||
// rustfmt-generics_indent: Tabbed
|
// rustfmt-generics_indent: Tabbed
|
||||||
// rustfmt-where_indent: Inherit
|
// rustfmt-where_indent: Inherit
|
||||||
|
// rustfmt-where_layout: Mixed
|
||||||
// Test different indents.
|
// Test different indents.
|
||||||
|
|
||||||
fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
||||||
|
@ -15,6 +16,10 @@ fn baz() where X: TTTTTTTT {
|
||||||
baz();
|
baz();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn qux() where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT {
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn foo(self, a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
fn foo(self, a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
||||||
foo();
|
foo();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// rustfmt-fn_arg_indent: Tabbed
|
// rustfmt-fn_arg_indent: Tabbed
|
||||||
// rustfmt-generics_indent: Inherit
|
// rustfmt-generics_indent: Inherit
|
||||||
|
// rustfmt-where_layout: HorizontalVertical
|
||||||
// Test different indents.
|
// Test different indents.
|
||||||
|
|
||||||
fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
fn foo(a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
||||||
|
@ -10,6 +11,14 @@ fn bar<'a: 'bbbbbbbbbbbbbbbbbbbbbbbbbbb, TTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUU: WW
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn qux() where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT {
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn qux() where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT {
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn foo(self, a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
fn foo(self, a: Aaaaaaaaaaaaaaa, b: Bbbbbbbbbbbbbbbb, c: Ccccccccccccccccc, d: Ddddddddddddddddddddddddd, e: Eeeeeeeeeeeeeeeeeee) {
|
||||||
foo();
|
foo();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// rustfmt-fn_arg_indent: Inherit
|
// rustfmt-fn_arg_indent: Inherit
|
||||||
// rustfmt-generics_indent: Tabbed
|
// rustfmt-generics_indent: Tabbed
|
||||||
// rustfmt-where_indent: Inherit
|
// rustfmt-where_indent: Inherit
|
||||||
|
// rustfmt-where_layout: Mixed
|
||||||
// Test different indents.
|
// Test different indents.
|
||||||
|
|
||||||
fn foo(a: Aaaaaaaaaaaaaaa,
|
fn foo(a: Aaaaaaaaaaaaaaa,
|
||||||
|
@ -24,6 +25,13 @@ where X: TTTTTTTT
|
||||||
baz();
|
baz();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn qux()
|
||||||
|
where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
|
||||||
|
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
|
||||||
|
{
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn foo(self,
|
fn foo(self,
|
||||||
a: Aaaaaaaaaaaaaaa,
|
a: Aaaaaaaaaaaaaaa,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// rustfmt-fn_arg_indent: Tabbed
|
// rustfmt-fn_arg_indent: Tabbed
|
||||||
// rustfmt-generics_indent: Inherit
|
// rustfmt-generics_indent: Inherit
|
||||||
|
// rustfmt-where_layout: HorizontalVertical
|
||||||
// Test different indents.
|
// Test different indents.
|
||||||
|
|
||||||
fn foo(a: Aaaaaaaaaaaaaaa,
|
fn foo(a: Aaaaaaaaaaaaaaa,
|
||||||
|
@ -17,6 +18,21 @@ UUUUUUUUUUUUUUUUUUUU: WWWWWWWWWWWWWWWWWWWWWWWW>
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn qux()
|
||||||
|
where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT, X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
|
||||||
|
{
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn qux()
|
||||||
|
where X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
|
||||||
|
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
|
||||||
|
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT,
|
||||||
|
X: TTTTTTTTTTTTTTTTTTTTTTTTTTTT
|
||||||
|
{
|
||||||
|
baz();
|
||||||
|
}
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn foo(self,
|
fn foo(self,
|
||||||
a: Aaaaaaaaaaaaaaa,
|
a: Aaaaaaaaaaaaaaa,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue