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

0 commit comments

Comments
 (0)