From 66e8751afce516a2ee9fb3324e755f7ad0c42629 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 19 Jun 2022 20:33:59 -0700 Subject: [PATCH] Format tests and benches with rustfmt (1-50 of 300) --- bench-cargo-miri/mse/src/main.rs | 1 - benches/helpers/repeat_manual.rs | 4 +++- test-cargo-miri/cdylib/src/lib.rs | 2 +- test-cargo-miri/issue-1567/src/lib.rs | 2 +- test-cargo-miri/issue-1705/src/lib.rs | 4 ++-- test-cargo-miri/issue-rust-86261/src/lib.rs | 2 +- test-cargo-miri/src/main.rs | 4 ++-- test-cargo-miri/tests/test.rs | 6 +----- tests/fail/abort-terminator.rs | 4 +++- tests/fail/alloc/global_system_mixup.rs | 6 ++++-- tests/fail/concurrency/too_few_args.rs | 3 ++- tests/fail/concurrency/too_many_args.rs | 3 ++- tests/fail/concurrency/unwind_top_of_stack.rs | 6 ++++-- .../fail/dangling_pointers/storage_dead_dangling.rs | 4 +++- tests/fail/data_race/alloc_read_race.rs | 6 +++--- tests/fail/data_race/alloc_write_race.rs | 7 ++++--- tests/fail/data_race/atomic_read_na_write_race1.rs | 4 ++-- tests/fail/data_race/atomic_read_na_write_race2.rs | 2 +- tests/fail/data_race/atomic_write_na_read_race1.rs | 2 +- tests/fail/data_race/atomic_write_na_read_race2.rs | 8 +++----- tests/fail/data_race/atomic_write_na_write_race1.rs | 4 ++-- tests/fail/data_race/atomic_write_na_write_race2.rs | 2 +- tests/fail/data_race/dangling_thread_async_race.rs | 6 ++---- tests/fail/data_race/dangling_thread_race.rs | 7 ++----- tests/fail/data_race/dealloc_read_race2.rs | 6 +++++- tests/fail/data_race/dealloc_read_race_stack.rs | 5 ++--- tests/fail/data_race/dealloc_write_race2.rs | 6 +++++- tests/fail/data_race/dealloc_write_race_stack.rs | 5 ++--- tests/fail/data_race/fence_after_load.rs | 4 ++-- tests/fail/data_race/read_write_race.rs | 4 +--- tests/fail/data_race/read_write_race_stack.rs | 4 ++-- tests/fail/data_race/relax_acquire_race.rs | 2 +- tests/fail/data_race/release_seq_race.rs | 2 +- tests/fail/data_race/release_seq_race_same_thread.rs | 2 +- tests/fail/data_race/rmw_race.rs | 2 +- tests/fail/data_race/write_write_race_stack.rs | 4 ++-- tests/fail/environ-gets-deallocated.rs | 12 ++++++------ .../fail/function_pointers/cast_box_int_to_fn_ptr.rs | 4 +--- tests/fail/function_pointers/cast_fn_ptr1.rs | 4 +--- tests/fail/function_pointers/cast_fn_ptr2.rs | 6 ++---- tests/fail/function_pointers/cast_fn_ptr3.rs | 7 ++----- tests/fail/function_pointers/cast_fn_ptr4.rs | 6 ++---- tests/fail/function_pointers/cast_fn_ptr5.rs | 8 ++++---- tests/fail/function_pointers/cast_int_to_fn_ptr.rs | 4 +--- tests/fail/function_pointers/fn_ptr_offset.rs | 6 +++--- tests/fail/intrinsics/simd-div-by-zero.rs | 12 +++++++----- tests/fail/intrinsics/simd-div-overflow.rs | 12 +++++++----- tests/fail/intrinsics/simd-float-to-int.rs | 8 +++++--- tests/fail/intrinsics/simd-gather.rs | 12 +++++++----- tests/fail/intrinsics/simd-reduce-invalid-bool.rs | 10 ++++++---- 50 files changed, 129 insertions(+), 127 deletions(-) diff --git a/bench-cargo-miri/mse/src/main.rs b/bench-cargo-miri/mse/src/main.rs index bb5fb80e48c..c09dc2484d3 100644 --- a/bench-cargo-miri/mse/src/main.rs +++ b/bench-cargo-miri/mse/src/main.rs @@ -30,4 +30,3 @@ fn mse(samples: usize, frame_buf: &[i16], buf_ref: &[u8]) -> f64 { } mse / max_samples as f64 } - diff --git a/benches/helpers/repeat_manual.rs b/benches/helpers/repeat_manual.rs index 6ef6f724efc..bd5d6b1e126 100644 --- a/benches/helpers/repeat_manual.rs +++ b/benches/helpers/repeat_manual.rs @@ -1,7 +1,9 @@ fn main() { let mut data: [u8; 1024] = unsafe { std::mem::uninitialized() }; for i in 0..data.len() { - unsafe { std::ptr::write(&mut data[i], 0); } + unsafe { + std::ptr::write(&mut data[i], 0); + } } assert_eq!(data.len(), 1024); } diff --git a/test-cargo-miri/cdylib/src/lib.rs b/test-cargo-miri/cdylib/src/lib.rs index dd89048284d..e47e588251e 100644 --- a/test-cargo-miri/cdylib/src/lib.rs +++ b/test-cargo-miri/cdylib/src/lib.rs @@ -2,5 +2,5 @@ use byteorder::{BigEndian, ByteOrder}; #[no_mangle] extern "C" fn use_the_dependency() { - let _n = ::read_u64(&[1,2,3,4,5,6,7,8]); + let _n = ::read_u64(&[1, 2, 3, 4, 5, 6, 7, 8]); } diff --git a/test-cargo-miri/issue-1567/src/lib.rs b/test-cargo-miri/issue-1567/src/lib.rs index 568617c3ba3..54792168323 100644 --- a/test-cargo-miri/issue-1567/src/lib.rs +++ b/test-cargo-miri/issue-1567/src/lib.rs @@ -1,5 +1,5 @@ use byteorder::{BigEndian, ByteOrder}; pub fn use_the_dependency() { - let _n = ::read_u32(&[1,2,3,4]); + let _n = ::read_u32(&[1, 2, 3, 4]); } diff --git a/test-cargo-miri/issue-1705/src/lib.rs b/test-cargo-miri/issue-1705/src/lib.rs index ef24d3f1a06..64633490f84 100644 --- a/test-cargo-miri/issue-1705/src/lib.rs +++ b/test-cargo-miri/issue-1705/src/lib.rs @@ -1,5 +1,5 @@ -use byteorder::{LittleEndian, ByteOrder}; +use byteorder::{ByteOrder, LittleEndian}; pub fn use_the_dependency() { - let _n = ::read_u32(&[1,2,3,4]); + let _n = ::read_u32(&[1, 2, 3, 4]); } diff --git a/test-cargo-miri/issue-rust-86261/src/lib.rs b/test-cargo-miri/issue-rust-86261/src/lib.rs index db725fdb64e..1947c38b774 100644 --- a/test-cargo-miri/issue-rust-86261/src/lib.rs +++ b/test-cargo-miri/issue-rust-86261/src/lib.rs @@ -3,7 +3,7 @@ // Regression test for https://github.com/rust-lang/rust/issues/86261: // `#[no_mangle]` on a `use` item. #[no_mangle] -use std::{thread,panic, io, boxed, any, string}; +use std::{any, boxed, io, panic, string, thread}; // `#[no_mangle]` on a struct has a similar problem. #[no_mangle] diff --git a/test-cargo-miri/src/main.rs b/test-cargo-miri/src/main.rs index cb1512d0502..5807d0765fb 100644 --- a/test-cargo-miri/src/main.rs +++ b/test-cargo-miri/src/main.rs @@ -8,7 +8,7 @@ fn main() { assert_eq!(env!("MIRITESTVAR"), "testval"); // Exercise external crate, printing to stdout. - let buf = &[1,2,3,4]; + let buf = &[1, 2, 3, 4]; let n = ::read_u32(buf); assert_eq!(n, 0x01020304); println!("{:#010x}", n); @@ -32,7 +32,7 @@ fn main() { #[cfg(unix)] for line in io::stdin().lock().lines() { let num: i32 = line.unwrap().parse().unwrap(); - println!("{}", 2*num); + println!("{}", 2 * num); } // On non-Unix, reading from stdin is not supported. So we hard-code the right answer. #[cfg(not(unix))] diff --git a/test-cargo-miri/tests/test.rs b/test-cargo-miri/tests/test.rs index 545c79db276..8a938ef3c25 100644 --- a/test-cargo-miri/tests/test.rs +++ b/test-cargo-miri/tests/test.rs @@ -67,9 +67,5 @@ fn page_size() { let page_size = page_size::get(); // In particular, this checks that it is not 0. - assert!( - page_size.is_power_of_two(), - "page size not a power of two: {}", - page_size - ); + assert!(page_size.is_power_of_two(), "page size not a power of two: {}", page_size); } diff --git a/tests/fail/abort-terminator.rs b/tests/fail/abort-terminator.rs index 8e6e2a76600..20859047c62 100644 --- a/tests/fail/abort-terminator.rs +++ b/tests/fail/abort-terminator.rs @@ -1,7 +1,9 @@ // error-pattern: the program aborted #![feature(c_unwind)] -extern "C" fn panic_abort() { panic!() } +extern "C" fn panic_abort() { + panic!() +} fn main() { panic_abort(); diff --git a/tests/fail/alloc/global_system_mixup.rs b/tests/fail/alloc/global_system_mixup.rs index bb87b132f32..735c52500af 100644 --- a/tests/fail/alloc/global_system_mixup.rs +++ b/tests/fail/alloc/global_system_mixup.rs @@ -8,10 +8,12 @@ #![feature(allocator_api, slice_ptr_get)] -use std::alloc::{Allocator, Global, System, Layout}; +use std::alloc::{Allocator, Global, Layout, System}; fn main() { let l = Layout::from_size_align(1, 1).unwrap(); let ptr = Global.allocate(l).unwrap().as_non_null_ptr(); - unsafe { System.deallocate(ptr, l); } + unsafe { + System.deallocate(ptr, l); + } } diff --git a/tests/fail/concurrency/too_few_args.rs b/tests/fail/concurrency/too_few_args.rs index e2dfa33af89..35412353ace 100644 --- a/tests/fail/concurrency/too_few_args.rs +++ b/tests/fail/concurrency/too_few_args.rs @@ -19,7 +19,8 @@ fn main() { let attr: libc::pthread_attr_t = mem::zeroed(); // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. let thread_start: extern "C" fn() -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = mem::transmute(thread_start); + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); } diff --git a/tests/fail/concurrency/too_many_args.rs b/tests/fail/concurrency/too_many_args.rs index 0ef12b07073..b6156091b0a 100644 --- a/tests/fail/concurrency/too_many_args.rs +++ b/tests/fail/concurrency/too_many_args.rs @@ -19,7 +19,8 @@ fn main() { let attr: libc::pthread_attr_t = mem::zeroed(); // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. let thread_start: extern "C" fn(*mut libc::c_void, i32) -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = mem::transmute(thread_start); + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); } diff --git a/tests/fail/concurrency/unwind_top_of_stack.rs b/tests/fail/concurrency/unwind_top_of_stack.rs index 138a43d9d73..e1c17d07b28 100644 --- a/tests/fail/concurrency/unwind_top_of_stack.rs +++ b/tests/fail/concurrency/unwind_top_of_stack.rs @@ -20,8 +20,10 @@ fn main() { let attr: libc::pthread_attr_t = mem::zeroed(); // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. // Cast to avoid inserting abort-on-unwind. - let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void = thread_start; - let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = mem::transmute(thread_start); + let thread_start: extern "C-unwind" fn(*mut libc::c_void) -> *mut libc::c_void = + thread_start; + let thread_start: extern "C" fn(*mut libc::c_void) -> *mut libc::c_void = + mem::transmute(thread_start); assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); } diff --git a/tests/fail/dangling_pointers/storage_dead_dangling.rs b/tests/fail/dangling_pointers/storage_dead_dangling.rs index 4d91498eac1..c87db4b0225 100644 --- a/tests/fail/dangling_pointers/storage_dead_dangling.rs +++ b/tests/fail/dangling_pointers/storage_dead_dangling.rs @@ -4,7 +4,9 @@ static mut LEAK: usize = 0; fn fill(v: &mut i32) { - unsafe { LEAK = v as *mut _ as usize; } + unsafe { + LEAK = v as *mut _ as usize; + } } fn evil() { diff --git a/tests/fail/data_race/alloc_read_race.rs b/tests/fail/data_race/alloc_read_race.rs index 4adb7071f29..12c1b6ec876 100644 --- a/tests/fail/data_race/alloc_read_race.rs +++ b/tests/fail/data_race/alloc_read_race.rs @@ -2,10 +2,10 @@ // compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 #![feature(new_uninit)] -use std::thread::spawn; -use std::ptr::null_mut; -use std::sync::atomic::{Ordering, AtomicPtr}; use std::mem::MaybeUninit; +use std::ptr::null_mut; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/alloc_write_race.rs b/tests/fail/data_race/alloc_write_race.rs index e4a1192f95b..c050d24bee1 100644 --- a/tests/fail/data_race/alloc_write_race.rs +++ b/tests/fail/data_race/alloc_write_race.rs @@ -2,9 +2,9 @@ // compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 #![feature(new_uninit)] -use std::thread::spawn; use std::ptr::null_mut; -use std::sync::atomic::{Ordering, AtomicPtr}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); @@ -30,7 +30,8 @@ pub fn main() { // Uses relaxed semantics to not generate // a release sequence. let pointer = &*ptr.0; - pointer.store(Box::into_raw(Box::::new_uninit()) as *mut usize, Ordering::Relaxed); + pointer + .store(Box::into_raw(Box::::new_uninit()) as *mut usize, Ordering::Relaxed); }); let j2 = spawn(move || { diff --git a/tests/fail/data_race/atomic_read_na_write_race1.rs b/tests/fail/data_race/atomic_read_na_write_race1.rs index 44860ee6280..5131e33fef8 100644 --- a/tests/fail/data_race/atomic_read_na_write_race1.rs +++ b/tests/fail/data_race/atomic_read_na_write_race1.rs @@ -1,9 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] -use std::thread::spawn; -use std::sync::atomic::AtomicUsize; use std::intrinsics::atomic_load; +use std::sync::atomic::AtomicUsize; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/atomic_read_na_write_race2.rs b/tests/fail/data_race/atomic_read_na_write_race2.rs index 6d28e18886c..1c0146367ad 100644 --- a/tests/fail/data_race/atomic_read_na_write_race2.rs +++ b/tests/fail/data_race/atomic_read_na_write_race2.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. -use std::thread::spawn; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/atomic_write_na_read_race1.rs b/tests/fail/data_race/atomic_write_na_read_race1.rs index 0b753f6710a..a63aafb0453 100644 --- a/tests/fail/data_race/atomic_write_na_read_race1.rs +++ b/tests/fail/data_race/atomic_write_na_read_race1.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. -use std::thread::spawn; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/atomic_write_na_read_race2.rs b/tests/fail/data_race/atomic_write_na_read_race2.rs index a9f5fb2fe5b..359970dfff8 100644 --- a/tests/fail/data_race/atomic_write_na_read_race2.rs +++ b/tests/fail/data_race/atomic_write_na_read_race2.rs @@ -1,9 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] -use std::thread::spawn; -use std::sync::atomic::AtomicUsize; use std::intrinsics::atomic_store; +use std::sync::atomic::AtomicUsize; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); @@ -16,9 +16,7 @@ pub fn main() { let b = &mut a as *mut AtomicUsize; let c = EvilSend(b); unsafe { - let j1 = spawn(move || { - *(c.0 as *mut usize) - }); + let j1 = spawn(move || *(c.0 as *mut usize)); let j2 = spawn(move || { //Equivalent to: (&*c.0).store(32, Ordering::SeqCst) diff --git a/tests/fail/data_race/atomic_write_na_write_race1.rs b/tests/fail/data_race/atomic_write_na_write_race1.rs index d5a828fa6e4..8268924e3c1 100644 --- a/tests/fail/data_race/atomic_write_na_write_race1.rs +++ b/tests/fail/data_race/atomic_write_na_write_race1.rs @@ -1,9 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. #![feature(core_intrinsics)] -use std::thread::spawn; -use std::sync::atomic::AtomicUsize; use std::intrinsics::atomic_store; +use std::sync::atomic::AtomicUsize; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/atomic_write_na_write_race2.rs b/tests/fail/data_race/atomic_write_na_write_race2.rs index 9812dcd7992..440c72a059d 100644 --- a/tests/fail/data_race/atomic_write_na_write_race2.rs +++ b/tests/fail/data_race/atomic_write_na_write_race2.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. -use std::thread::spawn; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/dangling_thread_async_race.rs b/tests/fail/data_race/dangling_thread_async_race.rs index 6aa5a469be3..2656f4b7af1 100644 --- a/tests/fail/data_race/dangling_thread_async_race.rs +++ b/tests/fail/data_race/dangling_thread_async_race.rs @@ -1,10 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -use std::thread::{spawn, sleep}; -use std::time::Duration; use std::mem; - +use std::thread::{sleep, spawn}; +use std::time::Duration; #[derive(Copy, Clone)] struct EvilSend(pub T); @@ -12,7 +11,6 @@ struct EvilSend(pub T); unsafe impl Send for EvilSend {} unsafe impl Sync for EvilSend {} - fn main() { let mut a = 0u32; let b = &mut a as *mut u32; diff --git a/tests/fail/data_race/dangling_thread_race.rs b/tests/fail/data_race/dangling_thread_race.rs index 755ba8efdae..f1174d8ff6e 100644 --- a/tests/fail/data_race/dangling_thread_race.rs +++ b/tests/fail/data_race/dangling_thread_race.rs @@ -1,10 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -use std::thread::{spawn, sleep}; -use std::time::Duration; use std::mem; - +use std::thread::{sleep, spawn}; +use std::time::Duration; #[derive(Copy, Clone)] struct EvilSend(pub T); @@ -12,7 +11,6 @@ struct EvilSend(pub T); unsafe impl Send for EvilSend {} unsafe impl Sync for EvilSend {} - fn main() { let mut a = 0u32; let b = &mut a as *mut u32; @@ -34,7 +32,6 @@ fn main() { // remains enabled nevertheless. spawn(|| ()).join().unwrap(); - unsafe { *c.0 = 64; //~ ERROR Data race detected between Write on Thread(id = 0, name = "main") and Write on Thread(id = 1) } diff --git a/tests/fail/data_race/dealloc_read_race2.rs b/tests/fail/data_race/dealloc_read_race2.rs index 9f9dbfc77ed..984268dca14 100644 --- a/tests/fail/data_race/dealloc_read_race2.rs +++ b/tests/fail/data_race/dealloc_read_race2.rs @@ -19,7 +19,11 @@ pub fn main() { unsafe { let j1 = spawn(move || { - __rust_dealloc(ptr.0 as *mut _, std::mem::size_of::(), std::mem::align_of::()) + __rust_dealloc( + ptr.0 as *mut _, + std::mem::size_of::(), + std::mem::align_of::(), + ) }); let j2 = spawn(move || { diff --git a/tests/fail/data_race/dealloc_read_race_stack.rs b/tests/fail/data_race/dealloc_read_race_stack.rs index f458d1126ef..cdb6c182307 100644 --- a/tests/fail/data_race/dealloc_read_race_stack.rs +++ b/tests/fail/data_race/dealloc_read_race_stack.rs @@ -1,9 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::{spawn, sleep}; use std::ptr::null_mut; -use std::sync::atomic::{Ordering, AtomicPtr}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::thread::{sleep, spawn}; use std::time::Duration; #[derive(Copy, Clone)] @@ -36,7 +36,6 @@ pub fn main() { sleep(Duration::from_millis(200)); // Now `stack_var` gets deallocated. - } //~ ERROR Data race detected between Deallocate on Thread(id = 1) and Read on Thread(id = 2) }); diff --git a/tests/fail/data_race/dealloc_write_race2.rs b/tests/fail/data_race/dealloc_write_race2.rs index 20c05fa8f17..2f4b9a194c0 100644 --- a/tests/fail/data_race/dealloc_write_race2.rs +++ b/tests/fail/data_race/dealloc_write_race2.rs @@ -18,7 +18,11 @@ pub fn main() { unsafe { let j1 = spawn(move || { - __rust_dealloc(ptr.0 as *mut _, std::mem::size_of::(), std::mem::align_of::()); + __rust_dealloc( + ptr.0 as *mut _, + std::mem::size_of::(), + std::mem::align_of::(), + ); }); let j2 = spawn(move || { diff --git a/tests/fail/data_race/dealloc_write_race_stack.rs b/tests/fail/data_race/dealloc_write_race_stack.rs index d1fe8c3e9a1..a209a2cd7db 100644 --- a/tests/fail/data_race/dealloc_write_race_stack.rs +++ b/tests/fail/data_race/dealloc_write_race_stack.rs @@ -1,9 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::{spawn, sleep}; use std::ptr::null_mut; -use std::sync::atomic::{Ordering, AtomicPtr}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::thread::{sleep, spawn}; use std::time::Duration; #[derive(Copy, Clone)] @@ -36,7 +36,6 @@ pub fn main() { sleep(Duration::from_millis(200)); // Now `stack_var` gets deallocated. - } //~ ERROR Data race detected between Deallocate on Thread(id = 1) and Write on Thread(id = 2) }); diff --git a/tests/fail/data_race/fence_after_load.rs b/tests/fail/data_race/fence_after_load.rs index 20cc691f88e..c209ef18125 100644 --- a/tests/fail/data_race/fence_after_load.rs +++ b/tests/fail/data_race/fence_after_load.rs @@ -1,10 +1,10 @@ // We want to control preemption here. // compile-flags: -Zmiri-disable-isolation -Zmiri-preemption-rate=0 // ignore-windows: Concurrency on Windows is not supported yet. +use std::sync::atomic::{fence, AtomicUsize, Ordering}; use std::sync::Arc; -use std::sync::atomic::{AtomicUsize, Ordering, fence}; -use std::time::Duration; use std::thread; +use std::time::Duration; fn main() { static mut V: u32 = 0; diff --git a/tests/fail/data_race/read_write_race.rs b/tests/fail/data_race/read_write_race.rs index 0df66d66ad0..976ace6e4b6 100644 --- a/tests/fail/data_race/read_write_race.rs +++ b/tests/fail/data_race/read_write_race.rs @@ -13,9 +13,7 @@ pub fn main() { let b = &mut a as *mut u32; let c = EvilSend(b); unsafe { - let j1 = spawn(move || { - *c.0 - }); + let j1 = spawn(move || *c.0); let j2 = spawn(move || { *c.0 = 64; //~ ERROR Data race detected between Write on Thread(id = 2) and Read on Thread(id = 1) diff --git a/tests/fail/data_race/read_write_race_stack.rs b/tests/fail/data_race/read_write_race_stack.rs index f5c4768296b..00c36176a9f 100644 --- a/tests/fail/data_race/read_write_race_stack.rs +++ b/tests/fail/data_race/read_write_race_stack.rs @@ -4,9 +4,9 @@ // Note: mir-opt-level set to 0 to prevent the read of stack_var in thread 1 // from being optimized away and preventing the detection of the data-race. -use std::thread::{spawn, sleep}; use std::ptr::null_mut; -use std::sync::atomic::{Ordering, AtomicPtr}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::thread::{sleep, spawn}; use std::time::Duration; #[derive(Copy, Clone)] diff --git a/tests/fail/data_race/relax_acquire_race.rs b/tests/fail/data_race/relax_acquire_race.rs index 64c0f95fa4b..3b350f5c89f 100644 --- a/tests/fail/data_race/relax_acquire_race.rs +++ b/tests/fail/data_race/relax_acquire_race.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::spawn; use std::sync::atomic::{AtomicUsize, Ordering}; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/release_seq_race.rs b/tests/fail/data_race/release_seq_race.rs index 964d1b4937b..ec03888c76b 100644 --- a/tests/fail/data_race/release_seq_race.rs +++ b/tests/fail/data_race/release_seq_race.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::{spawn, sleep}; use std::sync::atomic::{AtomicUsize, Ordering}; +use std::thread::{sleep, spawn}; use std::time::Duration; #[derive(Copy, Clone)] diff --git a/tests/fail/data_race/release_seq_race_same_thread.rs b/tests/fail/data_race/release_seq_race_same_thread.rs index 01d45a1b7cc..18762382894 100644 --- a/tests/fail/data_race/release_seq_race_same_thread.rs +++ b/tests/fail/data_race/release_seq_race_same_thread.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::spawn; use std::sync::atomic::{AtomicUsize, Ordering}; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/rmw_race.rs b/tests/fail/data_race/rmw_race.rs index fab6fabe5b6..51577b3b7b1 100644 --- a/tests/fail/data_race/rmw_race.rs +++ b/tests/fail/data_race/rmw_race.rs @@ -1,8 +1,8 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::spawn; use std::sync::atomic::{AtomicUsize, Ordering}; +use std::thread::spawn; #[derive(Copy, Clone)] struct EvilSend(pub T); diff --git a/tests/fail/data_race/write_write_race_stack.rs b/tests/fail/data_race/write_write_race_stack.rs index e6ae207d861..49de5db43b7 100644 --- a/tests/fail/data_race/write_write_race_stack.rs +++ b/tests/fail/data_race/write_write_race_stack.rs @@ -1,9 +1,9 @@ // ignore-windows: Concurrency on Windows is not supported yet. // compile-flags: -Zmiri-disable-isolation -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -use std::thread::{spawn, sleep}; use std::ptr::null_mut; -use std::sync::atomic::{Ordering, AtomicPtr}; +use std::sync::atomic::{AtomicPtr, Ordering}; +use std::thread::{sleep, spawn}; use std::time::Duration; #[derive(Copy, Clone)] diff --git a/tests/fail/environ-gets-deallocated.rs b/tests/fail/environ-gets-deallocated.rs index b5a4441d2f9..4df9be2bf24 100644 --- a/tests/fail/environ-gets-deallocated.rs +++ b/tests/fail/environ-gets-deallocated.rs @@ -1,14 +1,14 @@ // ignore-windows: Windows does not have a global environ list that the program can access directly -#[cfg(target_os="linux")] +#[cfg(target_os = "linux")] fn get_environ() -> *const *const u8 { - extern "C" { - static mut environ: *const *const u8; - } - unsafe { environ } + extern "C" { + static mut environ: *const *const u8; + } + unsafe { environ } } -#[cfg(target_os="macos")] +#[cfg(target_os = "macos")] fn get_environ() -> *const *const u8 { extern "C" { fn _NSGetEnviron() -> *mut *const *const u8; diff --git a/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs b/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs index 9eea9d92dcd..f7640cadcbc 100644 --- a/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs +++ b/tests/fail/function_pointers/cast_box_int_to_fn_ptr.rs @@ -3,9 +3,7 @@ fn main() { let b = Box::new(42); - let g = unsafe { - std::mem::transmute::<&Box, &fn(i32)>(&b) - }; + let g = unsafe { std::mem::transmute::<&Box, &fn(i32)>(&b) }; (*g)(42) //~ ERROR it does not point to a function } diff --git a/tests/fail/function_pointers/cast_fn_ptr1.rs b/tests/fail/function_pointers/cast_fn_ptr1.rs index 3702ec8c94c..e4463210dda 100644 --- a/tests/fail/function_pointers/cast_fn_ptr1.rs +++ b/tests/fail/function_pointers/cast_fn_ptr1.rs @@ -1,9 +1,7 @@ fn main() { fn f() {} - let g = unsafe { - std::mem::transmute::(f) - }; + let g = unsafe { std::mem::transmute::(f) }; g(42) //~ ERROR calling a function with more arguments than it expected } diff --git a/tests/fail/function_pointers/cast_fn_ptr2.rs b/tests/fail/function_pointers/cast_fn_ptr2.rs index 39f0867489a..5d3222548a7 100644 --- a/tests/fail/function_pointers/cast_fn_ptr2.rs +++ b/tests/fail/function_pointers/cast_fn_ptr2.rs @@ -1,9 +1,7 @@ fn main() { - fn f(_ : (i32,i32)) {} + fn f(_: (i32, i32)) {} - let g = unsafe { - std::mem::transmute::(f) - }; + let g = unsafe { std::mem::transmute::(f) }; g(42) //~ ERROR calling a function with argument of type (i32, i32) passing data of type i32 } diff --git a/tests/fail/function_pointers/cast_fn_ptr3.rs b/tests/fail/function_pointers/cast_fn_ptr3.rs index 3523db24fa3..943175c3470 100644 --- a/tests/fail/function_pointers/cast_fn_ptr3.rs +++ b/tests/fail/function_pointers/cast_fn_ptr3.rs @@ -1,10 +1,7 @@ fn main() { - fn f(_ : (i32,i32)) {} + fn f(_: (i32, i32)) {} - let g = unsafe { - std::mem::transmute::(f) - }; + let g = unsafe { std::mem::transmute::(f) }; g() //~ ERROR calling a function with fewer arguments than it requires } - diff --git a/tests/fail/function_pointers/cast_fn_ptr4.rs b/tests/fail/function_pointers/cast_fn_ptr4.rs index 22a36a71cef..238b09b162d 100644 --- a/tests/fail/function_pointers/cast_fn_ptr4.rs +++ b/tests/fail/function_pointers/cast_fn_ptr4.rs @@ -1,9 +1,7 @@ fn main() { - fn f(_ : *const [i32]) {} + fn f(_: *const [i32]) {} - let g = unsafe { - std::mem::transmute::(f) - }; + let g = unsafe { std::mem::transmute::(f) }; g(&42 as *const i32) //~ ERROR calling a function with argument of type *const [i32] passing data of type *const i32 } diff --git a/tests/fail/function_pointers/cast_fn_ptr5.rs b/tests/fail/function_pointers/cast_fn_ptr5.rs index fb2b4403363..effbd6db188 100644 --- a/tests/fail/function_pointers/cast_fn_ptr5.rs +++ b/tests/fail/function_pointers/cast_fn_ptr5.rs @@ -1,9 +1,9 @@ fn main() { - fn f() -> u32 { 42 } + fn f() -> u32 { + 42 + } - let g = unsafe { - std::mem::transmute:: u32, fn()>(f) - }; + let g = unsafe { std::mem::transmute:: u32, fn()>(f) }; g() //~ ERROR calling a function with return type u32 passing return place of type () } diff --git a/tests/fail/function_pointers/cast_int_to_fn_ptr.rs b/tests/fail/function_pointers/cast_int_to_fn_ptr.rs index b206cb9ab36..0adbda50bfe 100644 --- a/tests/fail/function_pointers/cast_int_to_fn_ptr.rs +++ b/tests/fail/function_pointers/cast_int_to_fn_ptr.rs @@ -2,9 +2,7 @@ // compile-flags: -Zmiri-disable-validation fn main() { - let g = unsafe { - std::mem::transmute::(42) - }; + let g = unsafe { std::mem::transmute::(42) }; g(42) //~ ERROR not a valid pointer } diff --git a/tests/fail/function_pointers/fn_ptr_offset.rs b/tests/fail/function_pointers/fn_ptr_offset.rs index 7e509d53c26..04c54c01592 100644 --- a/tests/fail/function_pointers/fn_ptr_offset.rs +++ b/tests/fail/function_pointers/fn_ptr_offset.rs @@ -6,9 +6,9 @@ use std::mem; fn f() {} fn main() { - let x : fn() = f; - let y : *mut u8 = unsafe { mem::transmute(x) }; + let x: fn() = f; + let y: *mut u8 = unsafe { mem::transmute(x) }; let y = y.wrapping_offset(1); - let x : fn() = unsafe { mem::transmute(y) }; + let x: fn() = unsafe { mem::transmute(y) }; x(); //~ ERROR function pointer but it does not point to a function } diff --git a/tests/fail/intrinsics/simd-div-by-zero.rs b/tests/fail/intrinsics/simd-div-by-zero.rs index 4244e63d23e..6fdcb875acc 100644 --- a/tests/fail/intrinsics/simd-div-by-zero.rs +++ b/tests/fail/intrinsics/simd-div-by-zero.rs @@ -8,8 +8,10 @@ extern "platform-intrinsic" { #[allow(non_camel_case_types)] struct i32x2(i32, i32); -fn main() { unsafe { - let x = i32x2(1, 1); - let y = i32x2(1, 0); - simd_div(x, y); //~ERROR Undefined Behavior: dividing by zero -} } +fn main() { + unsafe { + let x = i32x2(1, 1); + let y = i32x2(1, 0); + simd_div(x, y); //~ERROR Undefined Behavior: dividing by zero + } +} diff --git a/tests/fail/intrinsics/simd-div-overflow.rs b/tests/fail/intrinsics/simd-div-overflow.rs index 277b9e807ba..6d52a72e4c6 100644 --- a/tests/fail/intrinsics/simd-div-overflow.rs +++ b/tests/fail/intrinsics/simd-div-overflow.rs @@ -8,8 +8,10 @@ extern "platform-intrinsic" { #[allow(non_camel_case_types)] struct i32x2(i32, i32); -fn main() { unsafe { - let x = i32x2(1, i32::MIN); - let y = i32x2(1, -1); - simd_div(x, y); //~ERROR Undefined Behavior: overflow in signed division -} } +fn main() { + unsafe { + let x = i32x2(1, i32::MIN); + let y = i32x2(1, -1); + simd_div(x, y); //~ERROR Undefined Behavior: overflow in signed division + } +} diff --git a/tests/fail/intrinsics/simd-float-to-int.rs b/tests/fail/intrinsics/simd-float-to-int.rs index 88d5a7a466f..bb9adf07c9e 100644 --- a/tests/fail/intrinsics/simd-float-to-int.rs +++ b/tests/fail/intrinsics/simd-float-to-int.rs @@ -2,6 +2,8 @@ #![feature(portable_simd)] use std::simd::*; -fn main() { unsafe { - let _x : i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked(); -} } +fn main() { + unsafe { + let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked(); + } +} diff --git a/tests/fail/intrinsics/simd-gather.rs b/tests/fail/intrinsics/simd-gather.rs index ae6f048226d..ab9cb56ed0b 100644 --- a/tests/fail/intrinsics/simd-gather.rs +++ b/tests/fail/intrinsics/simd-gather.rs @@ -2,8 +2,10 @@ #![feature(portable_simd)] use std::simd::*; -fn main() { unsafe { - let vec: &[i8] = &[10, 11, 12, 13, 14, 15, 16, 17, 18]; - let idxs = Simd::from_array([9, 3, 0, 17]); - let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0)); -} } +fn main() { + unsafe { + let vec: &[i8] = &[10, 11, 12, 13, 14, 15, 16, 17, 18]; + let idxs = Simd::from_array([9, 3, 0, 17]); + let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0)); + } +} diff --git a/tests/fail/intrinsics/simd-reduce-invalid-bool.rs b/tests/fail/intrinsics/simd-reduce-invalid-bool.rs index 41dd7d74f4e..c697fd526f8 100644 --- a/tests/fail/intrinsics/simd-reduce-invalid-bool.rs +++ b/tests/fail/intrinsics/simd-reduce-invalid-bool.rs @@ -8,7 +8,9 @@ extern "platform-intrinsic" { #[allow(non_camel_case_types)] struct i32x2(i32, i32); -fn main() { unsafe { - let x = i32x2(0, 1); - simd_reduce_any(x); //~ERROR must be all-0-bits or all-1-bits -} } +fn main() { + unsafe { + let x = i32x2(0, 1); + simd_reduce_any(x); //~ERROR must be all-0-bits or all-1-bits + } +}