Skip to content

Commit 780a917

Browse files
committed
Run rustfmt on tests/codegen-units/.
1 parent 72800d3 commit 780a917

32 files changed

+208
-229
lines changed

rustfmt.toml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ ignore = [
1515
# - some UI tests are broken by different formatting
1616
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
1717
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
18-
"/tests/codegen-units/",
1918
"/tests/coverage/",
2019
"/tests/coverage-run-rustdoc/",
2120
"/tests/crashes/",

tests/codegen-units/item-collection/auxiliary/cgu_export_trait_method.rs

+28-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,43 @@
22

33
#![crate_type = "lib"]
44

5-
pub trait Trait : Sized {
5+
pub trait Trait: Sized {
66
fn without_self() -> u32;
7-
fn without_self_default() -> u32 { 0 }
7+
fn without_self_default() -> u32 {
8+
0
9+
}
810

9-
fn with_default_impl(self) -> Self { self }
10-
fn with_default_impl_generic<T>(self, x: T) -> (Self, T) { (self, x) }
11+
fn with_default_impl(self) -> Self {
12+
self
13+
}
14+
fn with_default_impl_generic<T>(self, x: T) -> (Self, T) {
15+
(self, x)
16+
}
1117

1218
fn without_default_impl(x: u32) -> (Self, u32);
1319
fn without_default_impl_generic<T>(x: T) -> (Self, T);
1420
}
1521

1622
impl Trait for char {
17-
fn without_self() -> u32 { 2 }
18-
fn without_default_impl(x: u32) -> (Self, u32) { ('c', x) }
19-
fn without_default_impl_generic<T>(x: T) -> (Self, T) { ('c', x) }
23+
fn without_self() -> u32 {
24+
2
25+
}
26+
fn without_default_impl(x: u32) -> (Self, u32) {
27+
('c', x)
28+
}
29+
fn without_default_impl_generic<T>(x: T) -> (Self, T) {
30+
('c', x)
31+
}
2032
}
2133

2234
impl Trait for u32 {
23-
fn without_self() -> u32 { 1 }
24-
fn without_default_impl(x: u32) -> (Self, u32) { (0, x) }
25-
fn without_default_impl_generic<T>(x: T) -> (Self, T) { (0, x) }
35+
fn without_self() -> u32 {
36+
1
37+
}
38+
fn without_default_impl(x: u32) -> (Self, u32) {
39+
(0, x)
40+
}
41+
fn without_default_impl_generic<T>(x: T) -> (Self, T) {
42+
(0, x)
43+
}
2644
}

tests/codegen-units/item-collection/auxiliary/cgu_extern_closures.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,19 @@
22

33
#[inline]
44
pub fn inlined_fn(x: i32, y: i32) -> i32 {
5-
6-
let closure = |a, b| { a + b };
5+
let closure = |a, b| a + b;
76

87
closure(x, y)
98
}
109

1110
pub fn inlined_fn_generic<T>(x: i32, y: i32, z: T) -> (i32, T) {
12-
13-
let closure = |a, b| { a + b };
11+
let closure = |a, b| a + b;
1412

1513
(closure(x, y), z)
1614
}
1715

1816
pub fn non_inlined_fn(x: i32, y: i32) -> i32 {
19-
20-
let closure = |a, b| { a + b };
17+
let closure = |a, b| a + b;
2118

2219
closure(x, y)
2320
}

tests/codegen-units/item-collection/cross-crate-closures.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ extern crate cgu_extern_closures;
1414
//~ MONO_ITEM fn cross_crate_closures::start[0]
1515
#[start]
1616
fn start(_: isize, _: *const *const u8) -> isize {
17-
1817
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]
1918
//~ MONO_ITEM fn cgu_extern_closures::inlined_fn[0]::{{closure}}[0]
2019
let _ = cgu_extern_closures::inlined_fn(1, 2);

tests/codegen-units/item-collection/cross-crate-trait-method.rs

-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ fn start(_: isize, _: *const *const u8) -> isize {
2424
//~ MONO_ITEM fn <char as cgu_export_trait_method::Trait>::with_default_impl
2525
let _ = Trait::with_default_impl('c');
2626

27-
28-
2927
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<&str>
3028
let _ = Trait::with_default_impl_generic(0u32, "abc");
3129
//~ MONO_ITEM fn <u32 as cgu_export_trait_method::Trait>::with_default_impl_generic::<bool>

tests/codegen-units/item-collection/drop_in_place_intrinsic.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ impl Drop for StructWithDtor {
1515
//~ MONO_ITEM fn start
1616
#[start]
1717
fn start(_: isize, _: *const *const u8) -> isize {
18-
1918
//~ MONO_ITEM fn std::ptr::drop_in_place::<[StructWithDtor; 2]> - shim(Some([StructWithDtor; 2])) @@ drop_in_place_intrinsic-cgu.0[Internal]
2019
let x = [StructWithDtor(0), StructWithDtor(1)];
2120

tests/codegen-units/item-collection/function-as-argument.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ fn take_fn_pointer<T1, T2>(f: fn(T1, T2), x: T1, y: T2) {
1616
//~ MONO_ITEM fn start
1717
#[start]
1818
fn start(_: isize, _: *const *const u8) -> isize {
19-
2019
//~ MONO_ITEM fn take_fn_once::<u32, &str, fn(u32, &str) {function::<u32, &str>}>
2120
//~ MONO_ITEM fn function::<u32, &str>
2221
//~ MONO_ITEM fn <fn(u32, &str) {function::<u32, &str>} as std::ops::FnOnce<(u32, &str)>>::call_once - shim(fn(u32, &str) {function::<u32, &str>})

tests/codegen-units/item-collection/generic-drop-glue.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct StructNoDrop<T1, T2> {
2121

2222
enum EnumWithDrop<T1, T2> {
2323
A(T1),
24-
B(T2)
24+
B(T2),
2525
}
2626

2727
impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
@@ -30,10 +30,9 @@ impl<T1, T2> Drop for EnumWithDrop<T1, T2> {
3030

3131
enum EnumNoDrop<T1, T2> {
3232
A(T1),
33-
B(T2)
33+
B(T2),
3434
}
3535

36-
3736
struct NonGenericNoDrop(#[allow(dead_code)] i32);
3837

3938
struct NonGenericWithDrop(#[allow(dead_code)] i32);
@@ -67,24 +66,24 @@ fn start(_: isize, _: *const *const u8) -> isize {
6766
//~ MONO_ITEM fn <EnumWithDrop<i32, i64> as std::ops::Drop>::drop
6867
let _ = match EnumWithDrop::A::<i32, i64>(0) {
6968
EnumWithDrop::A(x) => x,
70-
EnumWithDrop::B(x) => x as i32
69+
EnumWithDrop::B(x) => x as i32,
7170
};
7271

7372
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop<f64, f32>> - shim(Some(EnumWithDrop<f64, f32>)) @@ generic_drop_glue-cgu.0[Internal]
7473
//~ MONO_ITEM fn <EnumWithDrop<f64, f32> as std::ops::Drop>::drop
7574
let _ = match EnumWithDrop::B::<f64, f32>(1.0) {
7675
EnumWithDrop::A(x) => x,
77-
EnumWithDrop::B(x) => x as f64
76+
EnumWithDrop::B(x) => x as f64,
7877
};
7978

8079
let _ = match EnumNoDrop::A::<i32, i64>(0) {
8180
EnumNoDrop::A(x) => x,
82-
EnumNoDrop::B(x) => x as i32
81+
EnumNoDrop::B(x) => x as i32,
8382
};
8483

8584
let _ = match EnumNoDrop::B::<f64, f32>(1.0) {
8685
EnumNoDrop::A(x) => x,
87-
EnumNoDrop::B(x) => x as f64
86+
EnumNoDrop::B(x) => x as f64,
8887
};
8988

9089
0

tests/codegen-units/item-collection/generic-impl.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ struct Struct<T> {
88
f: fn(x: T) -> T,
99
}
1010

11-
fn id<T>(x: T) -> T { x }
11+
fn id<T>(x: T) -> T {
12+
x
13+
}
1214

1315
impl<T> Struct<T> {
14-
1516
fn new(x: T) -> Struct<T> {
16-
Struct {
17-
x: x,
18-
f: id
19-
}
17+
Struct { x: x, f: id }
2018
}
2119

2220
fn get<T2>(self, x: T2) -> (T, T2) {
@@ -25,11 +23,10 @@ impl<T> Struct<T> {
2523
}
2624

2725
pub struct LifeTimeOnly<'a> {
28-
_a: &'a u32
26+
_a: &'a u32,
2927
}
3028

3129
impl<'a> LifeTimeOnly<'a> {
32-
3330
//~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
3431
pub fn foo(&self) {}
3532
//~ MONO_ITEM fn LifeTimeOnly::<'_>::bar

tests/codegen-units/item-collection/instantiation-through-vtable.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ trait Trait {
1010
}
1111

1212
struct Struct<T> {
13-
_a: T
13+
_a: T,
1414
}
1515

1616
impl<T> Trait for Struct<T> {
17-
fn foo(&self) -> u32 { 0 }
17+
fn foo(&self) -> u32 {
18+
0
19+
}
1820
fn bar(&self) {}
1921
}
2022

tests/codegen-units/item-collection/non-generic-drop-glue.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
99
struct StructWithDrop {
10-
x: i32
10+
x: i32,
1111
}
1212

1313
impl Drop for StructWithDrop {
@@ -16,12 +16,12 @@ impl Drop for StructWithDrop {
1616
}
1717

1818
struct StructNoDrop {
19-
x: i32
19+
x: i32,
2020
}
2121

2222
//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) @@ non_generic_drop_glue-cgu.0[Internal]
2323
enum EnumWithDrop {
24-
A(i32)
24+
A(i32),
2525
}
2626

2727
impl Drop for EnumWithDrop {
@@ -30,7 +30,7 @@ impl Drop for EnumWithDrop {
3030
}
3131

3232
enum EnumNoDrop {
33-
A(i32)
33+
A(i32),
3434
}
3535

3636
//~ MONO_ITEM fn start
@@ -39,10 +39,10 @@ fn start(_: isize, _: *const *const u8) -> isize {
3939
let _ = StructWithDrop { x: 0 }.x;
4040
let _ = StructNoDrop { x: 0 }.x;
4141
let _ = match EnumWithDrop::A(0) {
42-
EnumWithDrop::A(x) => x
42+
EnumWithDrop::A(x) => x,
4343
};
4444
let _ = match EnumNoDrop::A(0) {
45-
EnumNoDrop::A(x) => x
45+
EnumNoDrop::A(x) => x,
4646
};
4747

4848
0

tests/codegen-units/item-collection/non-generic-functions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ fn bar() {
2525
baz();
2626
}
2727

28-
struct Struct { _x: i32 }
28+
struct Struct {
29+
_x: i32,
30+
}
2931

3032
impl Struct {
3133
//~ MONO_ITEM fn Struct::foo

tests/codegen-units/item-collection/overloaded-operators.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,35 @@
11
//@ compile-flags:-Zprint-mono-items=eager
22

33
#![deny(dead_code)]
4-
#![crate_type="lib"]
4+
#![crate_type = "lib"]
55

6-
use std::ops::{Index, IndexMut, Add, Deref};
6+
use std::ops::{Add, Deref, Index, IndexMut};
77

88
pub struct Indexable {
9-
data: [u8; 3]
9+
data: [u8; 3],
1010
}
1111

1212
impl Index<usize> for Indexable {
1313
type Output = u8;
1414

1515
//~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index
1616
fn index(&self, index: usize) -> &Self::Output {
17-
if index >= 3 {
18-
&self.data[0]
19-
} else {
20-
&self.data[index]
21-
}
17+
if index >= 3 { &self.data[0] } else { &self.data[index] }
2218
}
2319
}
2420

2521
impl IndexMut<usize> for Indexable {
2622
//~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut
2723
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
28-
if index >= 3 {
29-
&mut self.data[0]
30-
} else {
31-
&mut self.data[index]
32-
}
24+
if index >= 3 { &mut self.data[0] } else { &mut self.data[index] }
3325
}
3426
}
3527

36-
3728
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
3829
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
3930
#[derive(PartialEq)]
4031
pub struct Equatable(u32);
4132

42-
4333
impl Add<u32> for Equatable {
4434
type Output = u32;
4535

tests/codegen-units/item-collection/static-init.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#![feature(start)]
44

5-
pub static FN : fn() = foo::<i32>;
5+
pub static FN: fn() = foo::<i32>;
66

7-
pub fn foo<T>() { }
7+
pub fn foo<T>() {}
88

99
//~ MONO_ITEM fn foo::<T>
1010
//~ MONO_ITEM static FN

0 commit comments

Comments
 (0)