Skip to content

Commit

Permalink
Comments.
Browse files Browse the repository at this point in the history
- Move the option
- Add some more tests (don't pass yet)
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Nov 17, 2015
1 parent 8658774 commit a96a69b
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Expand Up @@ -266,6 +266,7 @@ create_config! {
"Maximum width in the body of a struct lit before falling back to vertical formatting";
newline_style: NewlineStyle, NewlineStyle::Unix, "Unix or Windows line endings";
fn_brace_style: BraceStyle, BraceStyle::SameLineWhere, "Brace style for functions";
item_brace_style: BraceStyle, BraceStyle::SameLineWhere, "Brace style for structs and enums";
fn_return_indent: ReturnIndent, ReturnIndent::WithArgs,
"Location of return type in function declaration";
fn_args_paren_newline: bool, true, "If function argument parenthesis goes on a newline";
Expand Down Expand Up @@ -302,5 +303,4 @@ create_config! {
take_source_hints: bool, true, "Retain some formatting characteristics from the source code";
hard_tabs: bool, false, "Use tab characters for indentation, spaces for alignment";
wrap_comments: bool, false, "Break comments to fit on the line";
item_brace_style: BraceStyle, BraceStyle::SameLineWhere, "Brace style for structs and enums";
}
29 changes: 29 additions & 0 deletions tests/source/item-brace-style-next-line.rs
@@ -0,0 +1,29 @@
// rustfmt-item_brace_style: AlwaysNextLine

mod M {
enum A {
A,
}

struct B {
b: i32,
}

// For empty enums and structs, the brace remains on the same line.
enum C {}

struct D {}

enum A<T> where T: Copy {
A,
}

struct B<T> where T: Copy {
b: i32,
}

// For empty enums and structs, the brace remains on the same line.
enum C<T> where T: Copy {}

struct D<T> where T: Copy {}
}
29 changes: 29 additions & 0 deletions tests/source/item-brace-style-same-line.rs
@@ -0,0 +1,29 @@
// rustfmt-item_brace_style: PreferSameLine

mod M {
enum A
{
A,
}

struct B
{
b: i32,
}

enum C {}

struct D {}

enum A<T> where T: Copy {
A,
}

struct B<T> where T: Copy {
b: i32,
}

enum C<T> where T: Copy {}

struct D<T> where T: Copy {}
}
16 changes: 0 additions & 16 deletions tests/source/item-brace-style.rs

This file was deleted.

39 changes: 39 additions & 0 deletions tests/target/item-brace-style-next-line.rs
@@ -0,0 +1,39 @@
// rustfmt-item_brace_style: AlwaysNextLine

mod M {
enum A
{
A,
}

struct B
{
b: i32,
}

// For empty enums and structs, the brace remains on the same line.
enum C {}

struct D {}

enum A<T>
where T: Copy
{
A,
}

struct B<T>
where T: Copy
{
b: i32,
}

// For empty enums and structs, the brace remains on the same line.
enum C<T>
where T: Copy
{}

struct D<T>
where T: Copy
{}
}
31 changes: 31 additions & 0 deletions tests/target/item-brace-style-same-line.rs
@@ -0,0 +1,31 @@
// rustfmt-item_brace_style: PreferSameLine

mod M {
enum A {
A,
}

struct B {
b: i32,
}

enum C {}

struct D {}

enum A<T>
where T: Copy {
A,
}

struct B<T>
where T: Copy {
b: i32,
}

enum C<T>
where T: Copy {}

struct D<T>
where T: Copy {}
}
18 changes: 0 additions & 18 deletions tests/target/item-brace-style.rs

This file was deleted.

0 comments on commit a96a69b

Please sign in to comment.