Skip to content

Commit 2a2c29a

Browse files
committed
Auto merge of rust-lang#125759 - nnethercote:format-some-tests, r=GuillaumeGomez
Format some tests There are more directories under `tests/` still to do, but this is enough for one PR. r? `@GuillaumeGomez`
2 parents 99cb42c + 0ea498a commit 2a2c29a

File tree

391 files changed

+2150
-2020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

391 files changed

+2150
-2020
lines changed

rustfmt.toml

+21-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,27 @@ ignore = [
1010
"/build-*/",
1111
"/vendor/",
1212

13-
# Tests for now are not formatted, as they are sometimes pretty-printing constrained
14-
# (and generally rustfmt can move around comments in UI-testing incompatible ways).
15-
"/tests/",
13+
# Some tests are not formatted, for multiple reasons:
14+
# - some contain syntax errors that cause rustfmt to give an error
15+
# - some UI tests are broken by different formatting
16+
# - some require special comments in a particular position (e.g. `EMIT_MIR` comments)
17+
"/tests/codegen/simd-intrinsic/", # Many types like `u8x64` are better hand-formatted.
18+
"/tests/crashes/", # Many tests contain syntax errors.
19+
"/tests/debuginfo/", # Tests are somewhat sensitive to source code layout.
20+
"/tests/incremental/", # Tests are somewhat sensitive to source code layout.
21+
"/tests/mir-opt/",
22+
"/tests/pretty/",
23+
"/tests/run-make/translation/test.rs", # Contains syntax errors.
24+
"/tests/run-make-fulldeps/",
25+
"/tests/run-pass-valgrind/",
26+
"/tests/rustdoc/",
27+
"/tests/rustdoc-gui/",
28+
"/tests/rustdoc-js/",
29+
"/tests/rustdoc-json/",
30+
"/tests/rustdoc-js-std/",
31+
"/tests/rustdoc-ui/",
32+
"/tests/ui/",
33+
"/tests/ui-fulldeps/",
1634

1735
# Do not format submodules.
1836
# FIXME: sync submodule list with tidy/bootstrap/etc

tests/assembly/align_offset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ assembly-output: emit-asm
22
//@ compile-flags: -Copt-level=1
33
//@ only-x86_64
4-
#![crate_type="rlib"]
4+
#![crate_type = "rlib"]
55

66
// CHECK-LABEL: align_offset_byte_ptr
77
// CHECK: leaq 31

tests/assembly/asm/inline-asm-avx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#![feature(portable_simd)]
77

8-
use std::simd::Simd;
98
use std::arch::asm;
9+
use std::simd::Simd;
1010

1111
#[target_feature(enable = "avx")]
1212
#[no_mangle]

tests/assembly/closure-inherit-target-feature.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
1818
// CHECK: {{call .*_mm_blend_ps.*}}
1919
// CHECK-NOT: blendps
2020
// CHECK: ret
21-
#[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101)
21+
#[inline(never)]
22+
|x, y| _mm_blend_ps(x, y, 0b0101)
2223
};
2324
f(x, y)
2425
}
@@ -33,9 +34,8 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
3334
// CHECK: blendps
3435
// CHECK-NOT: _mm_blend_ps
3536
// CHECK: ret
36-
#[inline(never)] |x, y| unsafe {
37-
_mm_blend_ps(x, y, 0b0101)
38-
}
37+
#[inline(never)]
38+
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
3939
};
4040
f(x, y)
4141
}
@@ -52,9 +52,8 @@ pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
5252
// CHECK-NOT: _mm_blend_ps
5353
// CHECK: ret
5454
let f = {
55-
#[inline] |x, y| unsafe {
56-
_mm_blend_ps(x, y, 0b0101)
57-
}
55+
#[inline]
56+
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
5857
};
5958
f(x, y)
6059
}

tests/assembly/is_aligned.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
//@ revisions: opt-speed opt-size
55
//@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no
66
//@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no
7-
#![crate_type="rlib"]
8-
7+
#![crate_type = "rlib"]
98
#![feature(core_intrinsics)]
109
#![feature(pointer_is_aligned_to)]
1110

@@ -16,9 +15,7 @@
1615
// CHECK: retq
1716
#[no_mangle]
1817
pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool {
19-
unsafe {
20-
std::intrinsics::assume(align.is_power_of_two())
21-
}
18+
unsafe { std::intrinsics::assume(align.is_power_of_two()) }
2219
ptr.is_aligned_to(align)
2320
}
2421

tests/assembly/pic-relocation-model.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
44
//@ [x64] needs-llvm-components: x86
55

6-
76
#![feature(no_core, lang_items)]
87
#![no_core]
9-
#![crate_type="rlib"]
8+
#![crate_type = "rlib"]
109

1110
#[lang = "sized"]
1211
trait Sized {}
@@ -17,19 +16,17 @@ trait Copy {}
1716
// CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip)
1817
#[no_mangle]
1918
pub fn call_other_fn() -> u8 {
20-
unsafe {
21-
other_fn()
22-
}
19+
unsafe { other_fn() }
2320
}
2421

2522
// CHECK-LABEL: other_fn:
2623
// CHECK: callq *foreign_fn@GOTPCREL(%rip)
2724
#[no_mangle]
2825
#[inline(never)]
2926
pub fn other_fn() -> u8 {
30-
unsafe {
31-
foreign_fn()
32-
}
27+
unsafe { foreign_fn() }
3328
}
3429

35-
extern "C" {fn foreign_fn() -> u8;}
30+
extern "C" {
31+
fn foreign_fn() -> u8;
32+
}

tests/assembly/pie-relocation-model.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
44
//@ [x64] needs-llvm-components: x86
55

6-
76
#![feature(no_core, lang_items)]
87
#![no_core]
9-
#![crate_type="rlib"]
8+
#![crate_type = "rlib"]
109

1110
#[lang = "sized"]
1211
trait Sized {}
@@ -18,9 +17,7 @@ trait Copy {}
1817
// CHECK: {{(jmp|callq)}} other_fn
1918
#[no_mangle]
2019
pub fn call_other_fn() -> u8 {
21-
unsafe {
22-
other_fn()
23-
}
20+
unsafe { other_fn() }
2421
}
2522

2623
// CHECK-LABEL: other_fn:
@@ -30,9 +27,9 @@ pub fn call_other_fn() -> u8 {
3027
#[no_mangle]
3128
#[inline(never)]
3229
pub fn other_fn() -> u8 {
33-
unsafe {
34-
foreign_fn()
35-
}
30+
unsafe { foreign_fn() }
3631
}
3732

38-
extern "C" {fn foreign_fn() -> u8;}
33+
extern "C" {
34+
fn foreign_fn() -> u8;
35+
}

tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
1111

1212
#![crate_type = "lib"]
13-
1413
#![allow(incomplete_features)]
15-
1614
#![feature(unsized_locals, unsized_fn_params)]
1715

18-
1916
// CHECK-LABEL: emptyfn:
2017
#[no_mangle]
2118
pub fn emptyfn() {
@@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
139136
// missing-NOT: __security_check_cookie
140137
}
141138

142-
143139
// CHECK-LABEL: local_string_addr_taken
144140
#[no_mangle]
145141
pub fn local_string_addr_taken(f: fn(&String)) {
@@ -205,7 +201,7 @@ pub struct Gigastruct {
205201
not: u64,
206202
have: u64,
207203
array: u64,
208-
members: u64
204+
members: u64,
209205
}
210206

211207
// CHECK-LABEL: local_large_var_moved
@@ -259,15 +255,13 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
259255
// EOF
260256
// ```
261257

262-
263258
// all: __security_check_cookie
264259
// strong: __security_check_cookie
265260
// basic: __security_check_cookie
266261
// none-NOT: __security_check_cookie
267262
// missing-NOT: __security_check_cookie
268263
}
269264

270-
271265
extern "C" {
272266
// A call to an external `alloca` function is *not* recognized as an
273267
// `alloca(3)` operation. This function is a compiler built-in, as the
@@ -320,7 +314,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
320314
// missing-NOT: __security_check_cookie
321315
}
322316

323-
324317
// CHECK-LABEL: alloca_dynamic_arg
325318
#[no_mangle]
326319
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@@ -340,7 +333,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
340333
// this is support for the "unsized locals" unstable feature:
341334
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
342335

343-
344336
// CHECK-LABEL: unsized_fn_param
345337
#[no_mangle]
346338
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
@@ -354,7 +346,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
354346
// alloca, and is therefore not protected by the `strong` or `basic`
355347
// heuristics.
356348

357-
358349
// We should have a __security_check_cookie call in `all` and `strong` modes but
359350
// LLVM does not support generating stack protectors in functions with funclet
360351
// based EH personalities.

tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled
1111

1212
#![crate_type = "lib"]
13-
1413
#![allow(incomplete_features)]
15-
1614
#![feature(unsized_locals, unsized_fn_params)]
1715

18-
1916
// CHECK-LABEL: emptyfn:
2017
#[no_mangle]
2118
pub fn emptyfn() {
@@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
139136
// missing-NOT: __security_check_cookie
140137
}
141138

142-
143139
// CHECK-LABEL: local_string_addr_taken
144140
#[no_mangle]
145141
pub fn local_string_addr_taken(f: fn(&String)) {
@@ -213,7 +209,7 @@ pub struct Gigastruct {
213209
not: u64,
214210
have: u64,
215211
array: u64,
216-
members: u64
212+
members: u64,
217213
}
218214

219215
// CHECK-LABEL: local_large_var_moved
@@ -267,15 +263,13 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
267263
// EOF
268264
// ```
269265

270-
271266
// all: __security_check_cookie
272267
// strong: __security_check_cookie
273268
// basic: __security_check_cookie
274269
// none-NOT: __security_check_cookie
275270
// missing-NOT: __security_check_cookie
276271
}
277272

278-
279273
extern "C" {
280274
// A call to an external `alloca` function is *not* recognized as an
281275
// `alloca(3)` operation. This function is a compiler built-in, as the
@@ -328,7 +322,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
328322
// missing-NOT: __security_check_cookie
329323
}
330324

331-
332325
// CHECK-LABEL: alloca_dynamic_arg
333326
#[no_mangle]
334327
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@@ -348,7 +341,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
348341
// this is support for the "unsized locals" unstable feature:
349342
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
350343

351-
352344
// CHECK-LABEL: unsized_fn_param
353345
#[no_mangle]
354346
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
@@ -362,7 +354,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
362354
// alloca, and is therefore not protected by the `strong` or `basic`
363355
// heuristics.
364356

365-
366357
// We should have a __security_check_cookie call in `all` and `strong` modes but
367358
// LLVM does not support generating stack protectors in functions with funclet
368359
// based EH personalities.

tests/assembly/stack-protector/stack-protector-heuristics-effect.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
143143
// missing-NOT: __stack_chk_fail
144144
}
145145

146-
147146
// CHECK-LABEL: local_string_addr_taken
148147
#[no_mangle]
149148
pub fn local_string_addr_taken(f: fn(&String)) {
@@ -194,7 +193,7 @@ pub struct Gigastruct {
194193
not: u64,
195194
have: u64,
196195
array: u64,
197-
members: u64
196+
members: u64,
198197
}
199198

200199
// CHECK-LABEL: local_large_var_moved
@@ -255,7 +254,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
255254
// missing-NOT: __stack_chk_fail
256255
}
257256

258-
259257
extern "C" {
260258
// A call to an external `alloca` function is *not* recognized as an
261259
// `alloca(3)` operation. This function is a compiler built-in, as the
@@ -308,7 +306,6 @@ pub fn alloca_large_compile_time_constant_arg(f: fn(*mut ())) {
308306
// missing-NOT: __stack_chk_fail
309307
}
310308

311-
312309
// CHECK-LABEL: alloca_dynamic_arg
313310
#[no_mangle]
314311
pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
@@ -328,7 +325,6 @@ pub fn alloca_dynamic_arg(f: fn(*mut ()), n: usize) {
328325
// this is support for the "unsized locals" unstable feature:
329326
// https://doc.rust-lang.org/unstable-book/language-features/unsized-locals.html.
330327

331-
332328
// CHECK-LABEL: unsized_fn_param
333329
#[no_mangle]
334330
pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
@@ -342,7 +338,6 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
342338
// alloca, and is therefore not protected by the `strong` or `basic`
343339
// heuristics.
344340

345-
346341
// all: __stack_chk_fail
347342
// strong-NOT: __stack_chk_fail
348343
// basic-NOT: __stack_chk_fail

0 commit comments

Comments
 (0)