Skip to content

Commit

Permalink
Auto merge of rust-lang#125759 - nnethercote:format-some-tests, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

Format some tests

There are more directories under `tests/` still to do, but this is enough for one PR.

r? `@GuillaumeGomez`
  • Loading branch information
bors committed May 31, 2024
2 parents 99cb42c + 0ea498a commit 2a2c29a
Show file tree
Hide file tree
Showing 391 changed files with 2,150 additions and 2,020 deletions.
24 changes: 21 additions & 3 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,27 @@ ignore = [
"/build-*/",
"/vendor/",

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

# Do not format submodules.
# FIXME: sync submodule list with tidy/bootstrap/etc
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/align_offset.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=1
//@ only-x86_64
#![crate_type="rlib"]
#![crate_type = "rlib"]

// CHECK-LABEL: align_offset_byte_ptr
// CHECK: leaq 31
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly/asm/inline-asm-avx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#![feature(portable_simd)]

use std::simd::Simd;
use std::arch::asm;
use std::simd::Simd;

#[target_feature(enable = "avx")]
#[no_mangle]
Expand Down
13 changes: 6 additions & 7 deletions tests/assembly/closure-inherit-target-feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 {
// CHECK: {{call .*_mm_blend_ps.*}}
// CHECK-NOT: blendps
// CHECK: ret
#[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101)
#[inline(never)]
|x, y| _mm_blend_ps(x, y, 0b0101)
};
f(x, y)
}
Expand All @@ -33,9 +34,8 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 {
// CHECK: blendps
// CHECK-NOT: _mm_blend_ps
// CHECK: ret
#[inline(never)] |x, y| unsafe {
_mm_blend_ps(x, y, 0b0101)
}
#[inline(never)]
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
};
f(x, y)
}
Expand All @@ -52,9 +52,8 @@ pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 {
// CHECK-NOT: _mm_blend_ps
// CHECK: ret
let f = {
#[inline] |x, y| unsafe {
_mm_blend_ps(x, y, 0b0101)
}
#[inline]
|x, y| unsafe { _mm_blend_ps(x, y, 0b0101) }
};
f(x, y)
}
7 changes: 2 additions & 5 deletions tests/assembly/is_aligned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
//@ revisions: opt-speed opt-size
//@ [opt-speed] compile-flags: -Copt-level=2 -Cdebug-assertions=no
//@ [opt-size] compile-flags: -Copt-level=s -Cdebug-assertions=no
#![crate_type="rlib"]

#![crate_type = "rlib"]
#![feature(core_intrinsics)]
#![feature(pointer_is_aligned_to)]

Expand All @@ -16,9 +15,7 @@
// CHECK: retq
#[no_mangle]
pub unsafe fn is_aligned_to_unchecked(ptr: *const u8, align: usize) -> bool {
unsafe {
std::intrinsics::assume(align.is_power_of_two())
}
unsafe { std::intrinsics::assume(align.is_power_of_two()) }
ptr.is_aligned_to(align)
}

Expand Down
15 changes: 6 additions & 9 deletions tests/assembly/pic-relocation-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
//@ [x64] needs-llvm-components: x86


#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]

#[lang = "sized"]
trait Sized {}
Expand All @@ -17,19 +16,17 @@ trait Copy {}
// CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip)
#[no_mangle]
pub fn call_other_fn() -> u8 {
unsafe {
other_fn()
}
unsafe { other_fn() }
}

// CHECK-LABEL: other_fn:
// CHECK: callq *foreign_fn@GOTPCREL(%rip)
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {
unsafe {
foreign_fn()
}
unsafe { foreign_fn() }
}

extern "C" {fn foreign_fn() -> u8;}
extern "C" {
fn foreign_fn() -> u8;
}
15 changes: 6 additions & 9 deletions tests/assembly/pie-relocation-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
//@ [x64] needs-llvm-components: x86


#![feature(no_core, lang_items)]
#![no_core]
#![crate_type="rlib"]
#![crate_type = "rlib"]

#[lang = "sized"]
trait Sized {}
Expand All @@ -18,9 +17,7 @@ trait Copy {}
// CHECK: {{(jmp|callq)}} other_fn
#[no_mangle]
pub fn call_other_fn() -> u8 {
unsafe {
other_fn()
}
unsafe { other_fn() }
}

// CHECK-LABEL: other_fn:
Expand All @@ -30,9 +27,9 @@ pub fn call_other_fn() -> u8 {
#[no_mangle]
#[inline(never)]
pub fn other_fn() -> u8 {
unsafe {
foreign_fn()
}
unsafe { foreign_fn() }
}

extern "C" {fn foreign_fn() -> u8;}
extern "C" {
fn foreign_fn() -> u8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled

#![crate_type = "lib"]

#![allow(incomplete_features)]

#![feature(unsized_locals, unsized_fn_params)]


// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
Expand Down Expand Up @@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie
}


// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
Expand Down Expand Up @@ -205,7 +201,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}

// CHECK-LABEL: local_large_var_moved
Expand Down Expand Up @@ -259,15 +255,13 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF
// ```


// all: __security_check_cookie
// strong: __security_check_cookie
// basic: __security_check_cookie
// none-NOT: __security_check_cookie
// missing-NOT: __security_check_cookie
}


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


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


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


// We should have a __security_check_cookie call in `all` and `strong` modes but
// LLVM does not support generating stack protectors in functions with funclet
// based EH personalities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
//@ compile-flags: -C opt-level=2 -Z merge-functions=disabled

#![crate_type = "lib"]

#![allow(incomplete_features)]

#![feature(unsized_locals, unsized_fn_params)]


// CHECK-LABEL: emptyfn:
#[no_mangle]
pub fn emptyfn() {
Expand Down Expand Up @@ -139,7 +136,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __security_check_cookie
}


// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
Expand Down Expand Up @@ -213,7 +209,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}

// CHECK-LABEL: local_large_var_moved
Expand Down Expand Up @@ -267,15 +263,13 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// EOF
// ```


// all: __security_check_cookie
// strong: __security_check_cookie
// basic: __security_check_cookie
// none-NOT: __security_check_cookie
// missing-NOT: __security_check_cookie
}


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


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


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


// We should have a __security_check_cookie call in `all` and `strong` modes but
// LLVM does not support generating stack protectors in functions with funclet
// based EH personalities.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ pub fn local_var_addr_used_indirectly(f: fn(bool)) {
// missing-NOT: __stack_chk_fail
}


// CHECK-LABEL: local_string_addr_taken
#[no_mangle]
pub fn local_string_addr_taken(f: fn(&String)) {
Expand Down Expand Up @@ -194,7 +193,7 @@ pub struct Gigastruct {
not: u64,
have: u64,
array: u64,
members: u64
members: u64,
}

// CHECK-LABEL: local_large_var_moved
Expand Down Expand Up @@ -255,7 +254,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
// missing-NOT: __stack_chk_fail
}


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


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


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


// all: __stack_chk_fail
// strong-NOT: __stack_chk_fail
// basic-NOT: __stack_chk_fail
Expand Down
Loading

0 comments on commit 2a2c29a

Please sign in to comment.