Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4e67b63

Browse files
committedJun 26, 2022
Auto merge of rust-lang#2269 - RalfJung:fmt, r=RalfJung
make a bunch of tests look more like how they did before rustfmt
2 parents 9e2dac4 + 5aeba7f commit 4e67b63

32 files changed

+65
-104
lines changed
 

‎tests/fail/box-cell-alias.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use std::cell::Cell;
66

77
fn helper(val: Box<Cell<u8>>, ptr: *const Cell<u8>) -> u8 {
88
val.set(10);
9-
unsafe {
10-
(*ptr).set(20); //~ ERROR does not exist in the borrow stack
11-
}
9+
unsafe { (*ptr).set(20) }; //~ ERROR does not exist in the borrow stack
1210
val.get()
1311
}
1412

‎tests/fail/box-cell-alias.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: Undefined Behavior: trying to reborrow <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
22
--> $DIR/box-cell-alias.rs:LL:CC
33
|
4-
LL | (*ptr).set(20);
5-
| ^^^^^^^^^^^^^^
6-
| |
7-
| trying to reborrow <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8-
| this error occurs as part of a reborrow at ALLOC[0x0..0x1]
4+
LL | unsafe { (*ptr).set(20) };
5+
| ^^^^^^^^^^^^^^
6+
| |
7+
| trying to reborrow <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8+
| this error occurs as part of a reborrow at ALLOC[0x0..0x1]
99
|
1010
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
1111
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

‎tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@ fn main() {
77
// Also not assigning directly as that's array initialization, not assignment.
88
let zst_val = [1u8; 0];
99
let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *mut [u8; 0];
10-
unsafe {
11-
*ptr = zst_val; //~ ERROR out-of-bounds
12-
}
10+
unsafe { *ptr = zst_val }; //~ ERROR out-of-bounds
1311
}

‎tests/fail/dangling_pointers/maybe_null_pointer_write_zst.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds
22
--> $DIR/maybe_null_pointer_write_zst.rs:LL:CC
33
|
4-
LL | *ptr = zst_val;
5-
| ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds
4+
LL | unsafe { *ptr = zst_val };
5+
| ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds
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/intrinsics/exact_div1.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// divison by 0
4-
unsafe {
5-
std::intrinsics::exact_div(2, 0); //~ ERROR divisor of zero
6-
}
4+
unsafe { std::intrinsics::exact_div(2, 0) }; //~ ERROR divisor of zero
75
}

‎tests/fail/intrinsics/exact_div1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: calculating the remainder with a divisor of zero
22
--> $DIR/exact_div1.rs:LL:CC
33
|
4-
LL | std::intrinsics::exact_div(2, 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
4+
LL | unsafe { std::intrinsics::exact_div(2, 0) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
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/intrinsics/exact_div2.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// divison with a remainder
4-
unsafe {
5-
std::intrinsics::exact_div(2u16, 3); //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder
6-
}
4+
unsafe { std::intrinsics::exact_div(2u16, 3) }; //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder
75
}

‎tests/fail/intrinsics/exact_div2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: exact_div: 2_u16 cannot be divided by 3_u16 without remainder
22
--> $DIR/exact_div2.rs:LL:CC
33
|
4-
LL | std::intrinsics::exact_div(2u16, 3);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder
4+
LL | unsafe { std::intrinsics::exact_div(2u16, 3) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder
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/intrinsics/exact_div3.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// signed divison with a remainder
4-
unsafe {
5-
std::intrinsics::exact_div(-19i8, 2); //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder
6-
}
4+
unsafe { std::intrinsics::exact_div(-19i8, 2) }; //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder
75
}

‎tests/fail/intrinsics/exact_div3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: exact_div: -19_i8 cannot be divided by 2_i8 without remainder
22
--> $DIR/exact_div3.rs:LL:CC
33
|
4-
LL | std::intrinsics::exact_div(-19i8, 2);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder
4+
LL | unsafe { std::intrinsics::exact_div(-19i8, 2) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder
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/intrinsics/exact_div4.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// divison of MIN by -1
4-
unsafe {
5-
std::intrinsics::exact_div(i64::MIN, -1); //~ ERROR overflow in signed remainder (dividing MIN by -1)
6-
}
4+
unsafe { std::intrinsics::exact_div(i64::MIN, -1) }; //~ ERROR overflow in signed remainder (dividing MIN by -1)
75
}

‎tests/fail/intrinsics/exact_div4.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: overflow in signed remainder (dividing MIN by -1)
22
--> $DIR/exact_div4.rs:LL:CC
33
|
4-
LL | std::intrinsics::exact_div(i64::MIN, -1);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1)
4+
LL | unsafe { std::intrinsics::exact_div(i64::MIN, -1) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1)
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/stacked_borrows/illegal_write1.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ fn main() {
33
let xref = &*target;
44
{
55
let x: *mut u32 = xref as *const _ as *mut _;
6-
unsafe {
7-
*x = 42; // invalidates shared ref, activates raw
8-
}
6+
unsafe { *x = 42 }; // invalidates shared ref, activates raw
97
}
108
let _x = *xref; //~ ERROR borrow stack
119
}

‎tests/fail/stacked_borrows/illegal_write1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ LL | let xref = &*target;
1717
help: <TAG> was later invalidated at offsets [0x0..0x4]
1818
--> $DIR/illegal_write1.rs:LL:CC
1919
|
20-
LL | *x = 42; // invalidates shared ref, activates raw
21-
| ^^^^^^^
20+
LL | unsafe { *x = 42 }; // invalidates shared ref, activates raw
21+
| ^^^^^^^
2222
= note: inside `main` at $DIR/illegal_write1.rs:LL:CC
2323

2424
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

‎tests/fail/stacked_borrows/illegal_write2.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ fn main() {
33
let target2 = target as *mut _;
44
drop(&mut *target); // reborrow
55
// Now make sure our ref is still the only one.
6-
unsafe {
7-
*target2 = 13; //~ ERROR borrow stack
8-
}
6+
unsafe { *target2 = 13 }; //~ ERROR borrow stack
97
let _val = *target;
108
}

‎tests/fail/stacked_borrows/illegal_write2.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: Undefined Behavior: attempting a write access using <untagged> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
22
--> $DIR/illegal_write2.rs:LL:CC
33
|
4-
LL | *target2 = 13;
5-
| ^^^^^^^^^^^^^
6-
| |
7-
| attempting a write access using <untagged> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8-
| this error occurs as part of an access at ALLOC[0x0..0x4]
4+
LL | unsafe { *target2 = 13 };
5+
| ^^^^^^^^^^^^^
6+
| |
7+
| attempting a write access using <untagged> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8+
| this error occurs as part of an access at ALLOC[0x0..0x4]
99
|
1010
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
1111
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

‎tests/fail/stacked_borrows/illegal_write3.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ fn main() {
33
// Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref.
44
let r#ref = &target; // freeze
55
let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag
6-
unsafe {
7-
*ptr = 42; //~ ERROR only grants SharedReadOnly permission
8-
}
6+
unsafe { *ptr = 42 }; //~ ERROR only grants SharedReadOnly permission
97
let _val = *r#ref;
108
}

‎tests/fail/stacked_borrows/illegal_write3.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: Undefined Behavior: attempting a write access using <untagged> at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location
22
--> $DIR/illegal_write3.rs:LL:CC
33
|
4-
LL | *ptr = 42;
5-
| ^^^^^^^^^
6-
| |
7-
| attempting a write access using <untagged> at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location
8-
| this error occurs as part of an access at ALLOC[0x0..0x4]
4+
LL | unsafe { *ptr = 42 };
5+
| ^^^^^^^^^
6+
| |
7+
| attempting a write access using <untagged> at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location
8+
| this error occurs as part of an access at ALLOC[0x0..0x4]
99
|
1010
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
1111
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

‎tests/fail/stacked_borrows/illegal_write6.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ fn main() {
77
fn foo(a: &mut u32, y: *mut u32) -> u32 {
88
*a = 1;
99
let _b = &*a;
10-
unsafe {
11-
*y = 2; //~ ERROR: not granting access to tag
12-
}
10+
unsafe { *y = 2 }; //~ ERROR: not granting access to tag
1311
return *a;
1412
}

‎tests/fail/stacked_borrows/illegal_write6.stderr

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: not granting access to tag <untagged> because incompatible item is protected: [Unique for <TAG> (call ID)]
22
--> $DIR/illegal_write6.rs:LL:CC
33
|
4-
LL | *y = 2;
5-
| ^^^^^^ not granting access to tag <untagged> because incompatible item is protected: [Unique for <TAG> (call ID)]
4+
LL | unsafe { *y = 2 };
5+
| ^^^^^^ not granting access to tag <untagged> because incompatible item is protected: [Unique for <TAG> (call ID)]
66
|
77
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
88
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
@@ -22,8 +22,7 @@ help: this protector is live for this call
2222
LL | / fn foo(a: &mut u32, y: *mut u32) -> u32 {
2323
LL | | *a = 1;
2424
LL | | let _b = &*a;
25-
LL | | unsafe {
26-
... |
25+
LL | | unsafe { *y = 2 };
2726
LL | | return *a;
2827
LL | | }
2928
| |_^

‎tests/fail/stacked_borrows/raw_tracking.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ fn main() {
77
let raw2 = &mut l as *mut _; // invalidates raw1
88
// Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
99
// fails to realize that raw1 should not be used any more.
10-
unsafe {
11-
*raw1 = 13; //~ ERROR does not exist in the borrow stack
12-
}
13-
unsafe {
14-
*raw2 = 13;
15-
}
10+
unsafe { *raw1 = 13 }; //~ ERROR does not exist in the borrow stack
11+
unsafe { *raw2 = 13 };
1612
}

‎tests/fail/stacked_borrows/raw_tracking.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: Undefined Behavior: attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
22
--> $DIR/raw_tracking.rs:LL:CC
33
|
4-
LL | *raw1 = 13;
5-
| ^^^^^^^^^^
6-
| |
7-
| attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8-
| this error occurs as part of an access at ALLOC[0x0..0x4]
4+
LL | unsafe { *raw1 = 13 };
5+
| ^^^^^^^^^^
6+
| |
7+
| attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8+
| this error occurs as part of an access at ALLOC[0x0..0x4]
99
|
1010
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
1111
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

‎tests/fail/stacked_borrows/transmute-is-no-escape.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ fn main() {
1010
let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) };
1111
// `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag
1212
let raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
13-
unsafe {
14-
*raw = 13; //~ ERROR borrow stack
15-
}
13+
unsafe { *raw = 13 }; //~ ERROR borrow stack
1614
}

‎tests/fail/stacked_borrows/transmute-is-no-escape.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: Undefined Behavior: attempting a write access using <untagged> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
22
--> $DIR/transmute-is-no-escape.rs:LL:CC
33
|
4-
LL | *raw = 13;
5-
| ^^^^^^^^^
6-
| |
7-
| attempting a write access using <untagged> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8-
| this error occurs as part of an access at ALLOC[0x0..0x4]
4+
LL | unsafe { *raw = 13 };
5+
| ^^^^^^^^^
6+
| |
7+
| attempting a write access using <untagged> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8+
| this error occurs as part of an access at ALLOC[0x0..0x4]
99
|
1010
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
1111
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

‎tests/fail/unaligned_pointers/intptrcast_alignment_check.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ fn main() {
1212
// Manually make sure the pointer is properly aligned.
1313
let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr + 1 };
1414
let u16_ptr = base_addr_aligned as *mut u16;
15-
unsafe {
16-
*u16_ptr = 2; //~ERROR memory with alignment 1, but alignment 2 is required
17-
}
15+
unsafe { *u16_ptr = 2 }; //~ERROR memory with alignment 1, but alignment 2 is required
1816
println!("{:?}", x);
1917
}

‎tests/fail/unaligned_pointers/intptrcast_alignment_check.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required
22
--> $DIR/intptrcast_alignment_check.rs:LL:CC
33
|
4-
LL | *u16_ptr = 2;
5-
| ^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
4+
LL | unsafe { *u16_ptr = 2 };
5+
| ^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
66
|
77
= help: this usually indicates that your program performed an invalid operation and caused Undefined Behavior
88
= help: but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives

‎tests/fail/validity/transmute_through_ptr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ enum Bool {
66

77
fn evil(x: &mut Bool) {
88
let x = x as *mut _ as *mut u32;
9-
unsafe {
10-
*x = 44; // out-of-bounds enum tag
11-
}
9+
unsafe { *x = 44 }; // out-of-bounds enum tag
1210
}
1311

1412
#[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391

‎tests/fail/zst2.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ fn main() {
1111
let mut x_box = Box::new(1u8);
1212
let x = &mut *x_box as *mut _ as *mut [u8; 0];
1313
drop(x_box);
14-
unsafe {
15-
*x = zst_val; //~ ERROR dereferenced after this allocation got freed
16-
}
14+
unsafe { *x = zst_val }; //~ ERROR dereferenced after this allocation got freed
1715
}

‎tests/fail/zst2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed
22
--> $DIR/zst2.rs:LL:CC
33
|
4-
LL | *x = zst_val;
5-
| ^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed
4+
LL | unsafe { *x = zst_val };
5+
| ^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed
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/zst3.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ fn main() {
1111
let mut x_box = Box::new(1u8);
1212
let x = (&mut *x_box as *mut u8).wrapping_offset(1);
1313
// This one is just "at the edge", but still okay
14-
unsafe {
15-
*(x as *mut [u8; 0]) = zst_val;
16-
}
14+
unsafe { *(x as *mut [u8; 0]) = zst_val };
1715
// One byte further is OOB.
1816
let x = x.wrapping_offset(1);
19-
unsafe {
20-
*(x as *mut [u8; 0]) = zst_val; //~ ERROR out-of-bounds
21-
}
17+
unsafe { *(x as *mut [u8; 0]) = zst_val }; //~ ERROR out-of-bounds
2218
}

‎tests/fail/zst3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds
22
--> $DIR/zst3.rs:LL:CC
33
|
4-
LL | *(x as *mut [u8; 0]) = zst_val;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds
4+
LL | unsafe { *(x as *mut [u8; 0]) = zst_val };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds
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/pass/concurrency/data_race.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ fn test_fence_sync() {
1818
let evil_ptr = EvilSend(ptr);
1919

2020
let j1 = spawn(move || {
21-
unsafe {
22-
*evil_ptr.0 = 1;
23-
}
21+
unsafe { *evil_ptr.0 = 1 };
2422
fence(Ordering::Release);
2523
SYNC.store(1, Ordering::Relaxed)
2624
});

0 commit comments

Comments
 (0)
Failed to load comments.