Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 769c6c7

Browse files
committed
Auto merge of rust-lang#2254 - dtolnay-contrib:rustfmt6, r=oli-obk
Format tests with rustfmt (276-287 of 299) Extracted from rust-lang#2097. This is one half of the last 24 files (left for last because they require more unique attention than the first 275 "easy" files). I'll comment below to call attention to cases where I exercised my own judgement in how to format the test. rust-lang/rustfmt#3255 is especially annoying: rustfmt does not like `…( //` and `…{ //`.
2 parents 7a1b08e + 05893d9 commit 769c6c7

20 files changed

+280
-242
lines changed

tests/fail/branchless-select-i128-pointer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ fn main() {
1111
// This is branchless code to select one or the other pointer.
1212
// However, it drops provenance when transmuting to TwoPtrs, so this is UB.
1313
let val = unsafe {
14-
transmute::<_, &str>( //~ERROR type validation failed: encountered a dangling reference
15-
!mask & transmute::<_, TwoPtrs>("false !") | mask & transmute::<_, TwoPtrs>("true !"),
14+
transmute::<_, &str>(
15+
//~^ ERROR type validation failed: encountered a dangling reference
16+
!mask & transmute::<_, TwoPtrs>("false !")
17+
| mask & transmute::<_, TwoPtrs>("true !"),
1618
)
1719
};
1820
println!("{}", val);

tests/fail/branchless-select-i128-pointer.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ error: Undefined Behavior: type validation failed: encountered a dangling refere
22
--> $DIR/branchless-select-i128-pointer.rs:LL:CC
33
|
44
LL | / transmute::<_, &str>(
5-
LL | | !mask & transmute::<_, TwoPtrs>("false !") | mask & transmute::<_, TwoPtrs>("true !"),
5+
LL | |
6+
LL | | !mask & transmute::<_, TwoPtrs>("false !")
7+
LL | | | mask & transmute::<_, TwoPtrs>("true !"),
68
LL | | )
79
| |_____________^ type validation failed: encountered a dangling reference (address $HEX is unallocated)
810
|

tests/fail/data_race/dealloc_read_race1.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ pub fn main() {
1919

2020
unsafe {
2121
let j1 = spawn(move || {
22-
*ptr.0
22+
let _val = *ptr.0;
2323
});
2424

2525
let j2 = spawn(move || {
26-
__rust_dealloc(ptr.0 as *mut _, std::mem::size_of::<usize>(), std::mem::align_of::<usize>()); //~ ERROR Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1)
26+
__rust_dealloc(
27+
//~^ ERROR Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1)
28+
ptr.0 as *mut _,
29+
std::mem::size_of::<usize>(),
30+
std::mem::align_of::<usize>(),
31+
);
2732
});
2833

2934
j1.join().unwrap();

tests/fail/data_race/dealloc_read_race1.stderr

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
error: Undefined Behavior: Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
22
--> $DIR/dealloc_read_race1.rs:LL:CC
33
|
4-
LL | __rust_dealloc(ptr.0 as *mut _, std::mem::size_of::<usize>(), std::mem::align_of::<usize>());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
4+
LL | / __rust_dealloc(
5+
LL | |
6+
LL | | ptr.0 as *mut _,
7+
LL | | std::mem::size_of::<usize>(),
8+
LL | | std::mem::align_of::<usize>(),
9+
LL | | );
10+
| |_____________^ Data race detected between Deallocate on Thread(id = 2) and Read on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
611
|
712
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
813
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/data_race/dealloc_write_race1.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ pub fn main() {
2222
});
2323

2424
let j2 = spawn(move || {
25-
__rust_dealloc(ptr.0 as *mut _, std::mem::size_of::<usize>(), std::mem::align_of::<usize>()); //~ ERROR Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1)
25+
__rust_dealloc(
26+
//~^ ERROR Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1)
27+
ptr.0 as *mut _,
28+
std::mem::size_of::<usize>(),
29+
std::mem::align_of::<usize>(),
30+
);
2631
});
2732

2833
j1.join().unwrap();

tests/fail/data_race/dealloc_write_race1.stderr

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
error: Undefined Behavior: Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
22
--> $DIR/dealloc_write_race1.rs:LL:CC
33
|
4-
LL | __rust_dealloc(ptr.0 as *mut _, std::mem::size_of::<usize>(), std::mem::align_of::<usize>());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
4+
LL | / __rust_dealloc(
5+
LL | |
6+
LL | | ptr.0 as *mut _,
7+
LL | | std::mem::size_of::<usize>(),
8+
LL | | std::mem::align_of::<usize>(),
9+
LL | | );
10+
| |_____________^ Data race detected between Deallocate on Thread(id = 2) and Write on Thread(id = 1) at ALLOC (current vector clock = VClock, conflicting timestamp = VClock)
611
|
712
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
813
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/function_calls/check_callback_abi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ fn main() {
88
unsafe {
99
// Make sure we check the ABI when Miri itself invokes a function
1010
// as part of a shim implementation.
11-
std::intrinsics::r#try( //~ ERROR calling a function with ABI C using caller ABI Rust
11+
std::intrinsics::r#try(
12+
//~^ ERROR calling a function with ABI C using caller ABI Rust
1213
std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
1314
std::ptr::null_mut(),
1415
|_, _| unreachable!(),

tests/fail/function_calls/check_callback_abi.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ error: Undefined Behavior: calling a function with ABI C using caller ABI Rust
22
--> $DIR/check_callback_abi.rs:LL:CC
33
|
44
LL | / std::intrinsics::r#try(
5+
LL | |
56
LL | | std::mem::transmute::<extern "C" fn(*mut u8), _>(try_fn),
67
LL | | std::ptr::null_mut(),
78
LL | | |_, _| unreachable!(),

tests/fail/function_calls/exported_symbol_abi_mismatch.cache.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: calling a function with calling convention Rust using calling convention C
22
--> $DIR/exported_symbol_abi_mismatch.rs:LL:CC
33
|
4-
LL | unsafe { foo() }
5-
| ^^^^^ calling a function with calling convention Rust using calling convention C
4+
LL | foo();
5+
| ^^^^^ calling a function with calling convention Rust using calling convention C
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/function_calls/exported_symbol_abi_mismatch.fn_ptr.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: calling a function with calling convention Rust using calling convention C
22
--> $DIR/exported_symbol_abi_mismatch.rs:LL:CC
33
|
4-
LL | unsafe { std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)() }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention Rust using calling convention C
4+
LL | std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention Rust using calling convention C
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/function_calls/exported_symbol_abi_mismatch.no_cache.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: calling a function with calling convention Rust using calling convention C
22
--> $DIR/exported_symbol_abi_mismatch.rs:LL:CC
33
|
4-
LL | unsafe { foo() }
5-
| ^^^^^ calling a function with calling convention Rust using calling convention C
4+
LL | foo();
5+
| ^^^^^ calling a function with calling convention Rust using calling convention C
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/function_calls/exported_symbol_abi_mismatch.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@ fn main() {
1010
}
1111

1212
#[cfg(fn_ptr)]
13-
unsafe { std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)() }
14-
//[fn_ptr]~^ ERROR calling a function with calling convention Rust using calling convention C
13+
unsafe {
14+
std::mem::transmute::<unsafe fn(), unsafe extern "C" fn()>(foo)();
15+
//[fn_ptr]~^ ERROR calling a function with calling convention Rust using calling convention C
16+
}
1517

1618
// `Instance` caching should not suppress ABI check.
1719
#[cfg(cache)]
18-
unsafe { foo() }
20+
unsafe {
21+
foo();
22+
}
1923

2024
{
2125
#[cfg_attr(any(cache, fn_ptr), allow(clashing_extern_declarations))]
2226
extern "C" {
2327
fn foo();
2428
}
25-
unsafe { foo() }
26-
//[no_cache]~^ ERROR calling a function with calling convention Rust using calling convention C
27-
//[cache]~^^ ERROR calling a function with calling convention Rust using calling convention C
29+
unsafe {
30+
foo();
31+
//[no_cache]~^ ERROR calling a function with calling convention Rust using calling convention C
32+
//[cache]~| ERROR calling a function with calling convention Rust using calling convention C
33+
}
2834
}
2935
}

tests/fail/type-too-large.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ignore-32bit
22

33
fn main() {
4-
let _fat: [u8; (1<<61)+(1<<31)] =
5-
[0; (1u64<<61) as usize +(1u64<<31) as usize]; //~ ERROR post-monomorphization error
4+
let _fat: [u8; (1 << 61) + (1 << 31)];
5+
_fat = [0; (1u64 << 61) as usize + (1u64 << 31) as usize]; //~ ERROR post-monomorphization error
66
}

tests/fail/type-too-large.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: post-monomorphization error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture
22
--> $DIR/type-too-large.rs:LL:CC
33
|
4-
LL | [0; (1u64<<61) as usize +(1u64<<31) as usize];
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843011361177600]` are too big for the current architecture
4+
LL | _fat = [0; (1u64 << 61) as usize + (1u64 << 31) as usize];
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843011361177600]` are too big for the current architecture
66
|
77
= note: inside `main` at $DIR/type-too-large.rs:LL:CC
88

tests/fail/validity/invalid_char.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
fn main() {
22
assert!(std::char::from_u32(-1_i32 as u32).is_none());
3-
let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR encountered 0xffffffff, but expected a valid unicode scalar value
4-
'a' => {true},
5-
'b' => {false},
6-
_ => {true},
3+
let _val = match unsafe { std::mem::transmute::<i32, char>(-1) } {
4+
//~^ ERROR encountered 0xffffffff, but expected a valid unicode scalar value
5+
'a' => true,
6+
'b' => false,
7+
_ => true,
78
};
89
}

tests/pass/0weak_memory_consistency.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ fn test_corr() {
5454
x.store(2, Relaxed);
5555
});
5656

57+
#[rustfmt::skip]
5758
let j2 = spawn(move || {
5859
let r2 = x.load(Relaxed); // -------------------------------------+
5960
y.store(1, Release); // ---------------------+ |
6061
r2 // | |
6162
}); // | |
62-
// |synchronizes-with |happens-before
63+
#[rustfmt::skip] // |synchronizes-with |happens-before
6364
let j3 = spawn(move || { // | |
6465
acquires_value(&y, 1); // <------------------+ |
6566
x.load(Relaxed) // <----------------------------------------------+
@@ -80,15 +81,16 @@ fn test_wrc() {
8081
let x = static_atomic(0);
8182
let y = static_atomic(0);
8283

84+
#[rustfmt::skip]
8385
let j1 = spawn(move || {
8486
x.store(1, Release); // ---------------------+---------------------+
8587
}); // | |
86-
// |synchronizes-with |
88+
#[rustfmt::skip] // |synchronizes-with |
8789
let j2 = spawn(move || { // | |
8890
acquires_value(&x, 1); // <------------------+ |
8991
y.store(1, Release); // ---------------------+ |happens-before
9092
}); // | |
91-
// |synchronizes-with |
93+
#[rustfmt::skip] // |synchronizes-with |
9294
let j3 = spawn(move || { // | |
9395
acquires_value(&y, 1); // <------------------+ |
9496
x.load(Relaxed) // <-----------------------------------------------+
@@ -107,11 +109,12 @@ fn test_message_passing() {
107109
let x = EvilSend(ptr);
108110
let y = static_atomic(0);
109111

112+
#[rustfmt::skip]
110113
let j1 = spawn(move || {
111114
unsafe { *x.0 = 1 }; // -----------------------------------------+
112115
y.store(1, Release); // ---------------------+ |
113116
}); // | |
114-
// |synchronizes-with | happens-before
117+
#[rustfmt::skip] // |synchronizes-with | happens-before
115118
let j2 = spawn(move || { // | |
116119
acquires_value(&y, 1); // <------------------+ |
117120
unsafe { *x.0 } // <---------------------------------------------+

0 commit comments

Comments
 (0)