Skip to content

Commit 924f160

Browse files
committed
Run rustfmt on src/test/codegen/ folder
1 parent 298730e commit 924f160

17 files changed

+106
-134
lines changed

src/test/codegen/adjustments.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,27 @@
1616
// Hack to get the correct size for the length part in slices
1717
// CHECK: @helper([[USIZE:i[0-9]+]])
1818
#[no_mangle]
19-
fn helper(_: usize) {
20-
}
19+
fn helper(_: usize) {}
2120

2221
// CHECK-LABEL: @no_op_slice_adjustment
2322
#[no_mangle]
2423
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
2524
pub fn no_op_slice_adjustment(x: &[u8]) -> &[u8] {
2625
// We used to generate an extra alloca and memcpy for the block's trailing expression value, so
2726
// check that we copy directly to the return value slot
28-
// CHECK: [[SRC:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %x to
29-
// CHECK: [[DST:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %sret_slot to i8*
30-
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[DST]], i8* [[SRC]],
31-
{ x }
27+
// CHECK: [[SRC:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %x to
28+
// CHECK: [[DST:%[0-9]+]] = bitcast { i8*, [[USIZE]] }* %sret_slot to i8*
29+
// CHECK: call void @llvm.memcpy.{{.*}}(i8* [[DST]], i8* [[SRC]],
30+
{
31+
x
32+
}
3233
}
3334

3435
// CHECK-LABEL: @no_op_slice_adjustment2
3536
#[no_mangle]
3637
pub fn no_op_slice_adjustment2(x: &[u8]) -> &[u8] {
3738
// We used to generate an extra alloca and memcpy for the function's return value, so check
3839
// that there's no memcpy (the slice is written to sret_slot element-wise)
39-
// CHECK-NOT: call void @llvm.memcpy.
40+
// CHECK-NOT: call void @llvm.memcpy.
4041
no_op_slice_adjustment(x)
4142
}

src/test/codegen/coercions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ static X: i32 = 5;
1919
// CHECK-NOT: alloca
2020
#[no_mangle]
2121
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
22-
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32{
22+
pub fn raw_ptr_to_raw_ptr_noop() -> *const i32 {
2323
&X as *const i32
2424
}
2525

src/test/codegen/consts.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
// CHECK: @const{{[0-9]+}} = {{.*}}, align 4
2828

2929
#[derive(Copy, Clone)]
30-
3130
// repr(i16) is required for the {low,high}_align_const test
3231
#[repr(i16)]
3332
pub enum E<A, B> {
@@ -42,7 +41,7 @@ pub static STATIC: E<i16, i32> = E::A(0);
4241
#[no_mangle]
4342
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
4443
pub fn static_enum_const() -> E<i16, i32> {
45-
STATIC
44+
STATIC
4645
}
4746

4847
// CHECK-LABEL: @inline_enum_const
@@ -56,16 +55,16 @@ pub fn inline_enum_const() -> E<i8, i16> {
5655
#[no_mangle]
5756
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
5857
pub fn low_align_const() -> E<i16, [i16; 3]> {
59-
// Check that low_align_const and high_align_const use the same constant
60-
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]+}}, i8* {{.*}} [[LOW_HIGH:@const[0-9]+]]
58+
// Check that low_align_const and high_align_const use the same constant
59+
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]+}}, i8* {{.*}} [[LOW_HIGH:@const[0-9]+]]
6160
E::A(0)
6261
}
6362

6463
// CHECK-LABEL: @high_align_const
6564
#[no_mangle]
6665
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
6766
pub fn high_align_const() -> E<i16, i32> {
68-
// Check that low_align_const and high_align_const use the same constant
69-
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]}}, i8* {{.*}} [[LOW_HIGH]]
67+
// Check that low_align_const and high_align_const use the same constant
68+
// CHECK: call void @llvm.memcpy.{{.*}}(i8* %{{[0-9]}}, i8* {{.*}} [[LOW_HIGH]]
7069
E::A(0)
7170
}

src/test/codegen/drop.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,28 @@
1616
struct SomeUniqueName;
1717

1818
impl Drop for SomeUniqueName {
19-
fn drop(&mut self) {
20-
}
19+
fn drop(&mut self) {}
2120
}
2221

23-
pub fn possibly_unwinding() {
24-
}
22+
pub fn possibly_unwinding() {}
2523

2624
// CHECK-LABEL: @droppy
2725
#[no_mangle]
2826
#[rustc_no_mir] // FIXME #27840 MIR has different codegen.
2927
pub fn droppy() {
30-
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
31-
// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
32-
// regular function exit. We used to have problems with quadratic growths of drop calls in such
33-
// functions.
34-
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
35-
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
36-
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
37-
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
38-
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
39-
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
40-
// CHECK-NOT: call{{.*}}SomeUniqueName{{.*}}drop
41-
// The next line checks for the } that ends the function definition
42-
// CHECK-LABEL: {{^[}]}}
28+
// Check that there are exactly 6 drop calls. The cleanups for the unwinding should be reused, so
29+
// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
30+
// regular function exit. We used to have problems with quadratic growths of drop calls in such
31+
// functions.
32+
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
33+
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
34+
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
35+
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
36+
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
37+
// CHECK: call{{.*}}SomeUniqueName{{.*}}drop
38+
// CHECK-NOT: call{{.*}}SomeUniqueName{{.*}}drop
39+
// The next line checks for the } that ends the function definition
40+
// CHECK-LABEL: {{^[}]}}
4341
let _s = SomeUniqueName;
4442
possibly_unwinding();
4543
let _s = SomeUniqueName;

src/test/codegen/extern-functions.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#![crate_type = "lib"]
1414
#![feature(unwind_attributes)]
1515

16-
extern {
17-
// CHECK: Function Attrs: nounwind
18-
// CHECK-NEXT: declare void @extern_fn
16+
extern "C" {
17+
// CHECK: Function Attrs: nounwind
18+
// CHECK-NEXT: declare void @extern_fn
1919
fn extern_fn();
20-
// CHECK-NOT: Function Attrs: nounwind
21-
// CHECK: declare void @unwinding_extern_fn
20+
// CHECK-NOT: Function Attrs: nounwind
21+
// CHECK: declare void @unwinding_extern_fn
2222
#[unwind]
2323
fn unwinding_extern_fn();
2424
}

src/test/codegen/fatptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ pub trait T {}
1717
// CHECK-LABEL: @copy_fat_ptr
1818
#[no_mangle]
1919
pub fn copy_fat_ptr(x: &T) {
20-
// CHECK-NOT: extractvalue
20+
// CHECK-NOT: extractvalue
2121
let x2 = x;
2222
}

src/test/codegen/float_math.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,40 @@
1313
#![crate_type = "lib"]
1414
#![feature(core_intrinsics)]
1515

16-
use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast};
16+
use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};
1717

1818
// CHECK-LABEL: @add
1919
#[no_mangle]
2020
pub fn add(x: f32, y: f32) -> f32 {
21-
// CHECK: fadd float
22-
// CHECK-NOT fast
21+
// CHECK: fadd float
22+
// CHECK-NOT fast
2323
x + y
2424
}
2525

2626
// CHECK-LABEL: @addition
2727
#[no_mangle]
2828
pub fn addition(x: f32, y: f32) -> f32 {
29-
// CHECK: fadd fast float
30-
unsafe {
31-
fadd_fast(x, y)
32-
}
29+
// CHECK: fadd fast float
30+
unsafe { fadd_fast(x, y) }
3331
}
3432

3533
// CHECK-LABEL: @subtraction
3634
#[no_mangle]
3735
pub fn subtraction(x: f32, y: f32) -> f32 {
38-
// CHECK: fsub fast float
39-
unsafe {
40-
fsub_fast(x, y)
41-
}
36+
// CHECK: fsub fast float
37+
unsafe { fsub_fast(x, y) }
4238
}
4339

4440
// CHECK-LABEL: @multiplication
4541
#[no_mangle]
4642
pub fn multiplication(x: f32, y: f32) -> f32 {
47-
// CHECK: fmul fast float
48-
unsafe {
49-
fmul_fast(x, y)
50-
}
43+
// CHECK: fmul fast float
44+
unsafe { fmul_fast(x, y) }
5145
}
5246

5347
// CHECK-LABEL: @division
5448
#[no_mangle]
5549
pub fn division(x: f32, y: f32) -> f32 {
56-
// CHECK: fdiv fast float
57-
unsafe {
58-
fdiv_fast(x, y)
59-
}
50+
// CHECK: fdiv fast float
51+
unsafe { fdiv_fast(x, y) }
6052
}

src/test/codegen/function-arguments.rs

+22-39
Original file line numberDiff line numberDiff line change
@@ -14,133 +14,116 @@
1414
#![feature(allocator)]
1515

1616
pub struct S {
17-
_field: [i64; 4],
17+
_field: [i64; 4],
1818
}
1919

2020
pub struct UnsafeInner {
21-
_field: std::cell::UnsafeCell<i16>,
21+
_field: std::cell::UnsafeCell<i16>,
2222
}
2323

2424
// CHECK: zeroext i1 @boolean(i1 zeroext)
2525
#[no_mangle]
2626
pub fn boolean(x: bool) -> bool {
27-
x
27+
x
2828
}
2929

3030
// CHECK: @readonly_borrow(i32* noalias readonly dereferenceable(4))
3131
// FIXME #25759 This should also have `nocapture`
3232
#[no_mangle]
33-
pub fn readonly_borrow(_: &i32) {
34-
}
33+
pub fn readonly_borrow(_: &i32) {}
3534

3635
// CHECK: @static_borrow(i32* noalias readonly dereferenceable(4))
3736
// static borrow may be captured
3837
#[no_mangle]
39-
pub fn static_borrow(_: &'static i32) {
40-
}
38+
pub fn static_borrow(_: &'static i32) {}
4139

4240
// CHECK: @named_borrow(i32* noalias readonly dereferenceable(4))
4341
// borrow with named lifetime may be captured
4442
#[no_mangle]
45-
pub fn named_borrow<'r>(_: &'r i32) {
46-
}
43+
pub fn named_borrow<'r>(_: &'r i32) {}
4744

4845
// CHECK: @unsafe_borrow(%UnsafeInner* dereferenceable(2))
4946
// unsafe interior means this isn't actually readonly and there may be aliases ...
5047
#[no_mangle]
51-
pub fn unsafe_borrow(_: &UnsafeInner) {
52-
}
48+
pub fn unsafe_borrow(_: &UnsafeInner) {}
5349

5450
// CHECK: @mutable_unsafe_borrow(%UnsafeInner* dereferenceable(2))
5551
// ... unless this is a mutable borrow, those never alias
5652
// ... except that there's this LLVM bug that forces us to not use noalias, see #29485
5753
#[no_mangle]
58-
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
59-
}
54+
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {}
6055

6156
// CHECK: @mutable_borrow(i32* dereferenceable(4))
6257
// FIXME #25759 This should also have `nocapture`
6358
// ... there's this LLVM bug that forces us to not use noalias, see #29485
6459
#[no_mangle]
65-
pub fn mutable_borrow(_: &mut i32) {
66-
}
60+
pub fn mutable_borrow(_: &mut i32) {}
6761

6862
// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32))
6963
#[no_mangle]
70-
pub fn indirect_struct(_: S) {
71-
}
64+
pub fn indirect_struct(_: S) {}
7265

7366
// CHECK: @borrowed_struct(%S* noalias readonly dereferenceable(32))
7467
// FIXME #25759 This should also have `nocapture`
7568
#[no_mangle]
76-
pub fn borrowed_struct(_: &S) {
77-
}
69+
pub fn borrowed_struct(_: &S) {}
7870

7971
// CHECK: noalias dereferenceable(4) i32* @_box(i32* noalias dereferenceable(4))
8072
#[no_mangle]
8173
pub fn _box(x: Box<i32>) -> Box<i32> {
82-
x
74+
x
8375
}
8476

8577
// CHECK: @struct_return(%S* noalias nocapture sret dereferenceable(32))
8678
#[no_mangle]
8779
pub fn struct_return() -> S {
88-
S {
89-
_field: [0, 0, 0, 0]
90-
}
80+
S { _field: [0, 0, 0, 0] }
9181
}
9282

9383
// Hack to get the correct size for the length part in slices
9484
// CHECK: @helper([[USIZE:i[0-9]+]])
9585
#[no_mangle]
96-
fn helper(_: usize) {
97-
}
86+
fn helper(_: usize) {}
9887

9988
// CHECK: @slice(i8* noalias nonnull readonly, [[USIZE]])
10089
// FIXME #25759 This should also have `nocapture`
10190
#[no_mangle]
102-
fn slice(_: &[u8]) {
103-
}
91+
fn slice(_: &[u8]) {}
10492

10593
// CHECK: @mutable_slice(i8* nonnull, [[USIZE]])
10694
// FIXME #25759 This should also have `nocapture`
10795
// ... there's this LLVM bug that forces us to not use noalias, see #29485
10896
#[no_mangle]
109-
fn mutable_slice(_: &mut [u8]) {
110-
}
97+
fn mutable_slice(_: &mut [u8]) {}
11198

11299
// CHECK: @unsafe_slice(%UnsafeInner* nonnull, [[USIZE]])
113100
// unsafe interior means this isn't actually readonly and there may be aliases ...
114101
#[no_mangle]
115-
pub fn unsafe_slice(_: &[UnsafeInner]) {
116-
}
102+
pub fn unsafe_slice(_: &[UnsafeInner]) {}
117103

118104
// CHECK: @str(i8* noalias nonnull readonly, [[USIZE]])
119105
// FIXME #25759 This should also have `nocapture`
120106
#[no_mangle]
121-
fn str(_: &[u8]) {
122-
}
107+
fn str(_: &[u8]) {}
123108

124109
// CHECK: @trait_borrow(i8* nonnull, void (i8*)** nonnull)
125110
// FIXME #25759 This should also have `nocapture`
126111
#[no_mangle]
127-
fn trait_borrow(_: &Drop) {
128-
}
112+
fn trait_borrow(_: &Drop) {}
129113

130114
// CHECK: @trait_box(i8* noalias nonnull, void (i8*)** nonnull)
131115
#[no_mangle]
132-
fn trait_box(_: Box<Drop>) {
133-
}
116+
fn trait_box(_: Box<Drop>) {}
134117

135118
// CHECK: { i16*, [[USIZE]] } @return_slice(i16* noalias nonnull readonly, [[USIZE]])
136119
#[no_mangle]
137120
fn return_slice(x: &[u16]) -> &[u16] {
138-
x
121+
x
139122
}
140123

141124
// CHECK: noalias i8* @allocator()
142125
#[no_mangle]
143126
#[allocator]
144127
pub fn allocator() -> *const i8 {
145-
std::ptr::null()
128+
std::ptr::null()
146129
}

src/test/codegen/intrinsic-no-unnamed-attr.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ extern "rust-intrinsic" {
1818
// CHECK: @llvm.sqrt.f32(float) #{{[0-9]*}}
1919

2020
fn main() {
21-
unsafe { sqrtf32(0.0f32); }
21+
unsafe {
22+
sqrtf32(0.0f32);
23+
}
2224
}

src/test/codegen/link_section.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub static VAR1: u32 = 1;
1919

2020
pub enum E {
2121
A(u32),
22-
B(f32)
22+
B(f32),
2323
}
2424

2525
// CHECK: @VAR2 = constant {{.*}} { i32 0, i32 666, {{.*}} }, section ".test_two"

0 commit comments

Comments
 (0)