Skip to content

Commit e95f119

Browse files
committed
rustfmt tests
1 parent 7443127 commit e95f119

File tree

2 files changed

+64
-62
lines changed

2 files changed

+64
-62
lines changed

src/test/compile-fail/rfc1623.rs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,89 +10,91 @@
1010

1111
#![allow(dead_code)]
1212

13-
fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 { a }
13+
fn non_elidable<'a, 'b>(a: &'a u8, b: &'b u8) -> &'a u8 {
14+
a
15+
}
1416

1517
// the boundaries of elision
16-
static NON_ELIDABLE_FN : &fn(&u8, &u8) -> &u8 =
17-
//~^ ERROR: missing lifetime specifier
18-
&(non_elidable as fn(&u8, &u8) -> &u8);
18+
static NON_ELIDABLE_FN: &fn(&u8, &u8) -> &u8 = &(non_elidable as fn(&u8, &u8) -> &u8);
1919

2020
struct SomeStruct<'x, 'y, 'z: 'x> {
2121
foo: &'x Foo<'z>,
2222
bar: &'x Bar<'z>,
2323
f: &'y for<'a, 'b: 'a> Fn(&'a Foo<'b>) -> &'a Bar<'b>,
2424
}
2525

26-
fn id<T>(t: T) -> T { t }
26+
fn id<T>(t: T) -> T {
27+
t
28+
}
2729

28-
static SOME_STRUCT : &SomeStruct = SomeStruct {
30+
static SOME_STRUCT: &SomeStruct = SomeStruct {
2931
foo: &Foo { bools: &[false, true] },
3032
bar: &Bar { bools: &[true, true] },
3133
f: &id,
3234
};
3335

3436
// very simple test for a 'static static with default lifetime
35-
static STATIC_STR : &'static str = "&'static str";
36-
const CONST_STR : &'static str = "&'static str";
37+
static STATIC_STR: &'static str = "&'static str";
38+
const CONST_STR: &'static str = "&'static str";
3739

3840
// this should be the same as without default:
39-
static EXPLICIT_STATIC_STR : &'static str = "&'static str";
40-
const EXPLICIT_CONST_STR : &'static str = "&'static str";
41+
static EXPLICIT_STATIC_STR: &'static str = "&'static str";
42+
const EXPLICIT_CONST_STR: &'static str = "&'static str";
4143

4244
// a function that elides to an unbound lifetime for both in- and output
43-
fn id_u8_slice(arg: &[u8]) -> &[u8] { arg }
45+
fn id_u8_slice(arg: &[u8]) -> &[u8] {
46+
arg
47+
}
4448

4549
// one with a function, argument elided
46-
static STATIC_SIMPLE_FN : &'static fn(&[u8]) -> &[u8] =
47-
&(id_u8_slice as fn(&[u8]) -> &[u8]);
48-
const CONST_SIMPLE_FN : &'static fn(&[u8]) -> &[u8] =
49-
&(id_u8_slice as fn(&[u8]) -> &[u8]);
50+
static STATIC_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]);
51+
const CONST_SIMPLE_FN: &'static fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]);
5052

5153
// this should be the same as without elision
52-
static STATIC_NON_ELIDED_fN : &'static for<'a> fn(&'a [u8]) -> &'a [u8] =
53-
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
54-
const CONST_NON_ELIDED_fN : &'static for<'a> fn(&'a [u8]) -> &'a [u8] =
55-
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
54+
static STATIC_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] =
55+
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
56+
const CONST_NON_ELIDED_fN: &'static for<'a> fn(&'a [u8]) -> &'a [u8] =
57+
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
5658

5759
// another function that elides, each to a different unbound lifetime
58-
fn multi_args(a: &u8, b: &u8, c: &u8) { }
60+
fn multi_args(a: &u8, b: &u8, c: &u8) {}
5961

60-
static STATIC_MULTI_FN : &'static fn(&u8, &u8, &u8) =
61-
&(multi_args as fn(&u8, &u8, &u8));
62-
const CONST_MULTI_FN : &'static fn(&u8, &u8, &u8) =
63-
&(multi_args as fn(&u8, &u8, &u8));
62+
static STATIC_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8));
63+
const CONST_MULTI_FN: &'static fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8));
6464

6565
struct Foo<'a> {
66-
bools: &'a [bool]
66+
bools: &'a [bool],
6767
}
6868

69-
static STATIC_FOO : Foo<'static> = Foo { bools: &[true, false] };
70-
const CONST_FOO : Foo<'static> = Foo { bools: &[true, false] };
69+
static STATIC_FOO: Foo<'static> = Foo { bools: &[true, false] };
70+
const CONST_FOO: Foo<'static> = Foo { bools: &[true, false] };
7171

7272
type Bar<'a> = Foo<'a>;
7373

74-
static STATIC_BAR : Bar<'static> = Bar { bools: &[true, false] };
75-
const CONST_BAR : Bar<'static> = Bar { bools: &[true, false] };
74+
static STATIC_BAR: Bar<'static> = Bar { bools: &[true, false] };
75+
const CONST_BAR: Bar<'static> = Bar { bools: &[true, false] };
7676

7777
type Baz<'a> = fn(&'a [u8]) -> Option<u8>;
7878

79-
fn baz(e: &[u8]) -> Option<u8> { e.first().map(|x| *x) }
79+
fn baz(e: &[u8]) -> Option<u8> {
80+
e.first().map(|x| *x)
81+
}
8082

81-
static STATIC_BAZ : &'static Baz<'static> = &(baz as Baz);
82-
const CONST_BAZ : &'static Baz<'static> = &(baz as Baz);
83+
static STATIC_BAZ: &'static Baz<'static> = &(baz as Baz);
84+
const CONST_BAZ: &'static Baz<'static> = &(baz as Baz);
8385

84-
static BYTES : &'static [u8] = &[1, 2, 3];
86+
static BYTES: &'static [u8] = &[1, 2, 3];
8587

8688
fn main() {
8789
let x = &[1u8, 2, 3];
8890
let y = x;
8991

90-
//this works, so lifetime < `'static` is valid
92+
// this works, so lifetime < `'static` is valid
9193
assert_eq!(Some(1), STATIC_BAZ(y));
9294
assert_eq!(Some(1), CONST_BAZ(y));
9395

9496
let y = &[1u8, 2, 3];
95-
//^~ ERROR: borrowed values does not live long enough
97+
// ^~ ERROR: borrowed values does not live long enough
9698
STATIC_BAZ(BYTES); // BYTES has static lifetime
9799
CONST_BAZ(y); // This forces static lifetime, which y has not
98100
}

src/test/run-pass/rfc1623.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,56 @@
1111
#![allow(dead_code)]
1212

1313
// very simple test for a 'static static with default lifetime
14-
static STATIC_STR : &str = "&'static str";
15-
const CONST_STR : &str = "&'static str";
14+
static STATIC_STR: &str = "&'static str";
15+
const CONST_STR: &str = "&'static str";
1616

1717
// this should be the same as without default:
18-
static EXPLICIT_STATIC_STR : &'static str = "&'static str";
19-
const EXPLICIT_CONST_STR : &'static str = "&'static str";
18+
static EXPLICIT_STATIC_STR: &'static str = "&'static str";
19+
const EXPLICIT_CONST_STR: &'static str = "&'static str";
2020

2121
// a function that elides to an unbound lifetime for both in- and output
22-
fn id_u8_slice(arg: &[u8]) -> &[u8] { arg }
22+
fn id_u8_slice(arg: &[u8]) -> &[u8] {
23+
arg
24+
}
2325

2426
// one with a function, argument elided
25-
static STATIC_SIMPLE_FN : &fn(&[u8]) -> &[u8] =
26-
&(id_u8_slice as fn(&[u8]) -> &[u8]);
27-
const CONST_SIMPLE_FN : &fn(&[u8]) -> &[u8] =
28-
&(id_u8_slice as fn(&[u8]) -> &[u8]);
27+
static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]);
28+
const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]);
2929

3030
// this should be the same as without elision
31-
static STATIC_NON_ELIDED_fN : &for<'a> fn(&'a [u8]) -> &'a [u8] =
32-
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
33-
const CONST_NON_ELIDED_fN : &for<'a> fn(&'a [u8]) -> &'a [u8] =
34-
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
31+
static STATIC_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] =
32+
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
33+
const CONST_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] =
34+
&(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]);
3535

3636
// another function that elides, each to a different unbound lifetime
37-
fn multi_args(a: &u8, b: &u8, c: &u8) { }
37+
fn multi_args(a: &u8, b: &u8, c: &u8) {}
3838

39-
static STATIC_MULTI_FN : &fn(&u8, &u8, &u8) =
40-
&(multi_args as fn(&u8, &u8, &u8));
41-
const CONST_MULTI_FN : &fn(&u8, &u8, &u8) =
42-
&(multi_args as fn(&u8, &u8, &u8));
39+
static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8));
40+
const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8));
4341

4442
struct Foo<'a> {
45-
bools: &'a [bool]
43+
bools: &'a [bool],
4644
}
4745

48-
static STATIC_FOO : Foo = Foo { bools: &[true, false] };
49-
const CONST_FOO : Foo = Foo { bools: &[true, false] };
46+
static STATIC_FOO: Foo = Foo { bools: &[true, false] };
47+
const CONST_FOO: Foo = Foo { bools: &[true, false] };
5048

5149
type Bar<'a> = Foo<'a>;
5250

53-
static STATIC_BAR : Bar = Bar { bools: &[true, false] };
54-
const CONST_BAR : Bar = Bar { bools: &[true, false] };
51+
static STATIC_BAR: Bar = Bar { bools: &[true, false] };
52+
const CONST_BAR: Bar = Bar { bools: &[true, false] };
5553

5654
type Baz<'a> = fn(&'a [u8]) -> Option<u8>;
5755

58-
fn baz(e: &[u8]) -> Option<u8> { e.first().map(|x| *x) }
56+
fn baz(e: &[u8]) -> Option<u8> {
57+
e.first().map(|x| *x)
58+
}
5959

60-
static STATIC_BAZ : &Baz = &(baz as Baz);
61-
const CONST_BAZ : &Baz = &(baz as Baz);
60+
static STATIC_BAZ: &Baz = &(baz as Baz);
61+
const CONST_BAZ: &Baz = &(baz as Baz);
6262

63-
static BYTES : &[u8] = &[1, 2, 3];
63+
static BYTES: &[u8] = &[1, 2, 3];
6464

6565
fn main() {
6666
// make sure that the lifetime is actually elided (and not defaulted)

0 commit comments

Comments
 (0)