Skip to content

Commit ec12a89

Browse files
committed
Add tests for rust-lang#3614
1 parent 944fc57 commit ec12a89

File tree

6 files changed

+172
-0
lines changed

6 files changed

+172
-0
lines changed

tests/source/fn-single-line.rs renamed to tests/source/fn-single-line/version_one.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// rustfmt-fn_single_line: true
2+
// rustfmt-version: One
23
// Test single-line functions.
34

45
fn foo_expr() {
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// rustfmt-fn_single_line: true
2+
// rustfmt-version: Two
3+
// Test single-line functions.
4+
5+
fn foo_expr() {
6+
1
7+
}
8+
9+
fn foo_stmt() {
10+
foo();
11+
}
12+
13+
fn foo_decl_local() {
14+
let z = 5;
15+
}
16+
17+
fn foo_decl_item(x: &mut i32) {
18+
x = 3;
19+
}
20+
21+
fn empty() {
22+
23+
}
24+
25+
fn foo_return() -> String {
26+
"yay"
27+
}
28+
29+
fn foo_where() -> T where T: Sync {
30+
let x = 2;
31+
}
32+
33+
fn fooblock() {
34+
{
35+
"inner-block"
36+
}
37+
}
38+
39+
fn fooblock2(x: i32) {
40+
let z = match x {
41+
_ => 2,
42+
};
43+
}
44+
45+
fn comment() {
46+
// this is a test comment
47+
1
48+
}
49+
50+
fn comment2() {
51+
// multi-line comment
52+
let z = 2;
53+
1
54+
}
55+
56+
fn only_comment() {
57+
// Keep this here
58+
}
59+
60+
fn aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name() {
61+
let z = "aaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwww";
62+
}
63+
64+
fn lots_of_space () {
65+
1
66+
}
67+
68+
fn mac() -> Vec<i32> { vec![] }
69+
70+
trait CoolTypes {
71+
fn dummy(&self) {
72+
}
73+
}
74+
75+
trait CoolerTypes { fn dummy(&self) {
76+
}
77+
}
78+
79+
fn Foo<T>() where T: Bar {
80+
}

tests/target/fn-single-line.rs renamed to tests/target/fn-single-line/version_one.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// rustfmt-fn_single_line: true
2+
// rustfmt-version: One
23
// Test single-line functions.
34

45
fn foo_expr() { 1 }
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// rustfmt-fn_single_line: true
2+
// rustfmt-version: Two
3+
// Test single-line functions.
4+
5+
fn foo_expr() { 1 }
6+
7+
fn foo_stmt() { foo(); }
8+
9+
fn foo_decl_local() { let z = 5; }
10+
11+
fn foo_decl_item(x: &mut i32) { x = 3; }
12+
13+
fn empty() {}
14+
15+
fn foo_return() -> String { "yay" }
16+
17+
fn foo_where() -> T
18+
where
19+
T: Sync,
20+
{
21+
let x = 2;
22+
}
23+
24+
fn fooblock() { { "inner-block" } }
25+
26+
fn fooblock2(x: i32) {
27+
let z = match x {
28+
_ => 2,
29+
};
30+
}
31+
32+
fn comment() {
33+
// this is a test comment
34+
1
35+
}
36+
37+
fn comment2() {
38+
// multi-line comment
39+
let z = 2;
40+
1
41+
}
42+
43+
fn only_comment() {
44+
// Keep this here
45+
}
46+
47+
fn aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name() {
48+
let z = "aaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwww";
49+
}
50+
51+
fn lots_of_space() { 1 }
52+
53+
fn mac() -> Vec<i32> { vec![] }
54+
55+
trait CoolTypes {
56+
fn dummy(&self) {}
57+
}
58+
59+
trait CoolerTypes {
60+
fn dummy(&self) {}
61+
}
62+
63+
fn Foo<T>()
64+
where
65+
T: Bar,
66+
{
67+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// rustfmt-version: One
2+
3+
fn main() {
4+
let toto = || {
5+
if true {
6+
42
7+
} else {
8+
24
9+
}
10+
};
11+
12+
{
13+
T
14+
}
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// rustfmt-version: Two
2+
3+
fn main() {
4+
let toto = || {
5+
if true { 42 } else { 24 }
6+
};
7+
{ T }
8+
}

0 commit comments

Comments
 (0)