diff --git a/tests/fail/box-cell-alias.rs b/tests/fail/box-cell-alias.rs index c1fec28ae3b..d3f505d2da5 100644 --- a/tests/fail/box-cell-alias.rs +++ b/tests/fail/box-cell-alias.rs @@ -6,9 +6,7 @@ use std::cell::Cell; fn helper(val: Box>, ptr: *const Cell) -> u8 { val.set(10); - unsafe { - (*ptr).set(20); //~ ERROR does not exist in the borrow stack - } + unsafe { (*ptr).set(20) }; //~ ERROR does not exist in the borrow stack val.get() } diff --git a/tests/fail/box-cell-alias.stderr b/tests/fail/box-cell-alias.stderr index e5a3ad3d33a..446aafe6401 100644 --- a/tests/fail/box-cell-alias.stderr +++ b/tests/fail/box-cell-alias.stderr @@ -1,11 +1,11 @@ error: Undefined Behavior: trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location --> $DIR/box-cell-alias.rs:LL:CC | -LL | (*ptr).set(20); - | ^^^^^^^^^^^^^^ - | | - | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location - | this error occurs as part of a reborrow at ALLOC[0x0..0x1] +LL | unsafe { (*ptr).set(20) }; + | ^^^^^^^^^^^^^^ + | | + | trying to reborrow for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of a reborrow at ALLOC[0x0..0x1] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information diff --git a/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs b/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs index 3115da436be..4a8d498aa1f 100644 --- a/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs +++ b/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs @@ -7,7 +7,5 @@ fn main() { // Also not assigning directly as that's array initialization, not assignment. let zst_val = [1u8; 0]; let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *mut [u8; 0]; - unsafe { - *ptr = zst_val; //~ ERROR out-of-bounds - } + unsafe { *ptr = zst_val }; //~ ERROR out-of-bounds } diff --git a/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.stderr b/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.stderr index 79fd2ba0868..41e54735ca9 100644 --- a/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.stderr +++ b/tests/fail/dangling_pointers/maybe_null_pointer_write_zst.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds --> $DIR/maybe_null_pointer_write_zst.rs:LL:CC | -LL | *ptr = zst_val; - | ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds +LL | unsafe { *ptr = zst_val }; + | ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/intrinsics/exact_div1.rs b/tests/fail/intrinsics/exact_div1.rs index d8af789e99a..f926424a4b6 100644 --- a/tests/fail/intrinsics/exact_div1.rs +++ b/tests/fail/intrinsics/exact_div1.rs @@ -1,7 +1,5 @@ #![feature(core_intrinsics)] fn main() { // divison by 0 - unsafe { - std::intrinsics::exact_div(2, 0); //~ ERROR divisor of zero - } + unsafe { std::intrinsics::exact_div(2, 0) }; //~ ERROR divisor of zero } diff --git a/tests/fail/intrinsics/exact_div1.stderr b/tests/fail/intrinsics/exact_div1.stderr index 66f8168fade..59e853d0ece 100644 --- a/tests/fail/intrinsics/exact_div1.stderr +++ b/tests/fail/intrinsics/exact_div1.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: calculating the remainder with a divisor of zero --> $DIR/exact_div1.rs:LL:CC | -LL | std::intrinsics::exact_div(2, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero +LL | unsafe { std::intrinsics::exact_div(2, 0) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/intrinsics/exact_div2.rs b/tests/fail/intrinsics/exact_div2.rs index 80f9131bab7..fc252aa7985 100644 --- a/tests/fail/intrinsics/exact_div2.rs +++ b/tests/fail/intrinsics/exact_div2.rs @@ -1,7 +1,5 @@ #![feature(core_intrinsics)] fn main() { // divison with a remainder - unsafe { - std::intrinsics::exact_div(2u16, 3); //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder - } + unsafe { std::intrinsics::exact_div(2u16, 3) }; //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder } diff --git a/tests/fail/intrinsics/exact_div2.stderr b/tests/fail/intrinsics/exact_div2.stderr index 2c102dd0b55..dfbcdd1f34f 100644 --- a/tests/fail/intrinsics/exact_div2.stderr +++ b/tests/fail/intrinsics/exact_div2.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: exact_div: 2_u16 cannot be divided by 3_u16 without remainder --> $DIR/exact_div2.rs:LL:CC | -LL | std::intrinsics::exact_div(2u16, 3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder +LL | unsafe { std::intrinsics::exact_div(2u16, 3) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/intrinsics/exact_div3.rs b/tests/fail/intrinsics/exact_div3.rs index 976fca29f9b..4d2511adc1f 100644 --- a/tests/fail/intrinsics/exact_div3.rs +++ b/tests/fail/intrinsics/exact_div3.rs @@ -1,7 +1,5 @@ #![feature(core_intrinsics)] fn main() { // signed divison with a remainder - unsafe { - std::intrinsics::exact_div(-19i8, 2); //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder - } + unsafe { std::intrinsics::exact_div(-19i8, 2) }; //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder } diff --git a/tests/fail/intrinsics/exact_div3.stderr b/tests/fail/intrinsics/exact_div3.stderr index 61eacdc65ff..c3b908ce0ad 100644 --- a/tests/fail/intrinsics/exact_div3.stderr +++ b/tests/fail/intrinsics/exact_div3.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: exact_div: -19_i8 cannot be divided by 2_i8 without remainder --> $DIR/exact_div3.rs:LL:CC | -LL | std::intrinsics::exact_div(-19i8, 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder +LL | unsafe { std::intrinsics::exact_div(-19i8, 2) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/intrinsics/exact_div4.rs b/tests/fail/intrinsics/exact_div4.rs index 5f4ca587e6d..df6433d1cb2 100644 --- a/tests/fail/intrinsics/exact_div4.rs +++ b/tests/fail/intrinsics/exact_div4.rs @@ -1,7 +1,5 @@ #![feature(core_intrinsics)] fn main() { // divison of MIN by -1 - unsafe { - std::intrinsics::exact_div(i64::MIN, -1); //~ ERROR overflow in signed remainder (dividing MIN by -1) - } + unsafe { std::intrinsics::exact_div(i64::MIN, -1) }; //~ ERROR overflow in signed remainder (dividing MIN by -1) } diff --git a/tests/fail/intrinsics/exact_div4.stderr b/tests/fail/intrinsics/exact_div4.stderr index a3f5aafbe2d..b82950674fb 100644 --- a/tests/fail/intrinsics/exact_div4.stderr +++ b/tests/fail/intrinsics/exact_div4.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: overflow in signed remainder (dividing MIN by -1) --> $DIR/exact_div4.rs:LL:CC | -LL | std::intrinsics::exact_div(i64::MIN, -1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) +LL | unsafe { std::intrinsics::exact_div(i64::MIN, -1) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1) | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/stacked_borrows/illegal_write1.rs b/tests/fail/stacked_borrows/illegal_write1.rs index 3b67accbbd2..1f566f18c1f 100644 --- a/tests/fail/stacked_borrows/illegal_write1.rs +++ b/tests/fail/stacked_borrows/illegal_write1.rs @@ -3,9 +3,7 @@ fn main() { let xref = &*target; { let x: *mut u32 = xref as *const _ as *mut _; - unsafe { - *x = 42; // invalidates shared ref, activates raw - } + unsafe { *x = 42 }; // invalidates shared ref, activates raw } let _x = *xref; //~ ERROR borrow stack } diff --git a/tests/fail/stacked_borrows/illegal_write1.stderr b/tests/fail/stacked_borrows/illegal_write1.stderr index a70a45f2235..1731e3c1de1 100644 --- a/tests/fail/stacked_borrows/illegal_write1.stderr +++ b/tests/fail/stacked_borrows/illegal_write1.stderr @@ -17,8 +17,8 @@ LL | let xref = &*target; help: was later invalidated at offsets [0x0..0x4] --> $DIR/illegal_write1.rs:LL:CC | -LL | *x = 42; // invalidates shared ref, activates raw - | ^^^^^^^ +LL | unsafe { *x = 42 }; // invalidates shared ref, activates raw + | ^^^^^^^ = note: inside `main` at $DIR/illegal_write1.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/tests/fail/stacked_borrows/illegal_write2.rs b/tests/fail/stacked_borrows/illegal_write2.rs index a106b4240c3..32dc474385d 100644 --- a/tests/fail/stacked_borrows/illegal_write2.rs +++ b/tests/fail/stacked_borrows/illegal_write2.rs @@ -3,8 +3,6 @@ fn main() { let target2 = target as *mut _; drop(&mut *target); // reborrow // Now make sure our ref is still the only one. - unsafe { - *target2 = 13; //~ ERROR borrow stack - } + unsafe { *target2 = 13 }; //~ ERROR borrow stack let _val = *target; } diff --git a/tests/fail/stacked_borrows/illegal_write2.stderr b/tests/fail/stacked_borrows/illegal_write2.stderr index d2a06cc386a..7e896c530ac 100644 --- a/tests/fail/stacked_borrows/illegal_write2.stderr +++ b/tests/fail/stacked_borrows/illegal_write2.stderr @@ -1,11 +1,11 @@ error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location --> $DIR/illegal_write2.rs:LL:CC | -LL | *target2 = 13; - | ^^^^^^^^^^^^^ - | | - | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location - | this error occurs as part of an access at ALLOC[0x0..0x4] +LL | unsafe { *target2 = 13 }; + | ^^^^^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information diff --git a/tests/fail/stacked_borrows/illegal_write3.rs b/tests/fail/stacked_borrows/illegal_write3.rs index 5bf651b33aa..87fdbae7019 100644 --- a/tests/fail/stacked_borrows/illegal_write3.rs +++ b/tests/fail/stacked_borrows/illegal_write3.rs @@ -3,8 +3,6 @@ fn main() { // Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref. let r#ref = ⌖ // freeze let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag - unsafe { - *ptr = 42; //~ ERROR only grants SharedReadOnly permission - } + unsafe { *ptr = 42 }; //~ ERROR only grants SharedReadOnly permission let _val = *r#ref; } diff --git a/tests/fail/stacked_borrows/illegal_write3.stderr b/tests/fail/stacked_borrows/illegal_write3.stderr index fc87557ea9b..7e9c82769d6 100644 --- a/tests/fail/stacked_borrows/illegal_write3.stderr +++ b/tests/fail/stacked_borrows/illegal_write3.stderr @@ -1,11 +1,11 @@ error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location --> $DIR/illegal_write3.rs:LL:CC | -LL | *ptr = 42; - | ^^^^^^^^^ - | | - | attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location - | this error occurs as part of an access at ALLOC[0x0..0x4] +LL | unsafe { *ptr = 42 }; + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag only grants SharedReadOnly permission for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information diff --git a/tests/fail/stacked_borrows/illegal_write6.rs b/tests/fail/stacked_borrows/illegal_write6.rs index 07d57241205..c50b7c5816f 100644 --- a/tests/fail/stacked_borrows/illegal_write6.rs +++ b/tests/fail/stacked_borrows/illegal_write6.rs @@ -7,8 +7,6 @@ fn main() { fn foo(a: &mut u32, y: *mut u32) -> u32 { *a = 1; let _b = &*a; - unsafe { - *y = 2; //~ ERROR: not granting access to tag - } + unsafe { *y = 2 }; //~ ERROR: not granting access to tag return *a; } diff --git a/tests/fail/stacked_borrows/illegal_write6.stderr b/tests/fail/stacked_borrows/illegal_write6.stderr index 3a7fc0ef811..11757cca9b6 100644 --- a/tests/fail/stacked_borrows/illegal_write6.stderr +++ b/tests/fail/stacked_borrows/illegal_write6.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: not granting access to tag because incompatible item is protected: [Unique for (call ID)] --> $DIR/illegal_write6.rs:LL:CC | -LL | *y = 2; - | ^^^^^^ not granting access to tag because incompatible item is protected: [Unique for (call ID)] +LL | unsafe { *y = 2 }; + | ^^^^^^ not granting access to tag because incompatible item is protected: [Unique for (call ID)] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental = 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 LL | / fn foo(a: &mut u32, y: *mut u32) -> u32 { LL | | *a = 1; LL | | let _b = &*a; -LL | | unsafe { -... | +LL | | unsafe { *y = 2 }; LL | | return *a; LL | | } | |_^ diff --git a/tests/fail/stacked_borrows/raw_tracking.rs b/tests/fail/stacked_borrows/raw_tracking.rs index 0a99e4ce47e..0b9c058f06e 100644 --- a/tests/fail/stacked_borrows/raw_tracking.rs +++ b/tests/fail/stacked_borrows/raw_tracking.rs @@ -7,10 +7,6 @@ fn main() { let raw2 = &mut l as *mut _; // invalidates raw1 // Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus // fails to realize that raw1 should not be used any more. - unsafe { - *raw1 = 13; //~ ERROR does not exist in the borrow stack - } - unsafe { - *raw2 = 13; - } + unsafe { *raw1 = 13 }; //~ ERROR does not exist in the borrow stack + unsafe { *raw2 = 13 }; } diff --git a/tests/fail/stacked_borrows/raw_tracking.stderr b/tests/fail/stacked_borrows/raw_tracking.stderr index 60a277ee057..d3674893fab 100644 --- a/tests/fail/stacked_borrows/raw_tracking.stderr +++ b/tests/fail/stacked_borrows/raw_tracking.stderr @@ -1,11 +1,11 @@ error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location --> $DIR/raw_tracking.rs:LL:CC | -LL | *raw1 = 13; - | ^^^^^^^^^^ - | | - | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location - | this error occurs as part of an access at ALLOC[0x0..0x4] +LL | unsafe { *raw1 = 13 }; + | ^^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information diff --git a/tests/fail/stacked_borrows/transmute-is-no-escape.rs b/tests/fail/stacked_borrows/transmute-is-no-escape.rs index e23c893d6aa..45035683d5c 100644 --- a/tests/fail/stacked_borrows/transmute-is-no-escape.rs +++ b/tests/fail/stacked_borrows/transmute-is-no-escape.rs @@ -10,7 +10,5 @@ fn main() { let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) }; // `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag let raw = (&mut x[1] as *mut i32).wrapping_offset(-1); - unsafe { - *raw = 13; //~ ERROR borrow stack - } + unsafe { *raw = 13 }; //~ ERROR borrow stack } diff --git a/tests/fail/stacked_borrows/transmute-is-no-escape.stderr b/tests/fail/stacked_borrows/transmute-is-no-escape.stderr index c077e37844d..a9682f806ba 100644 --- a/tests/fail/stacked_borrows/transmute-is-no-escape.stderr +++ b/tests/fail/stacked_borrows/transmute-is-no-escape.stderr @@ -1,11 +1,11 @@ error: Undefined Behavior: attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location --> $DIR/transmute-is-no-escape.rs:LL:CC | -LL | *raw = 13; - | ^^^^^^^^^ - | | - | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location - | this error occurs as part of an access at ALLOC[0x0..0x4] +LL | unsafe { *raw = 13 }; + | ^^^^^^^^^ + | | + | attempting a write access using at ALLOC[0x0], but that tag does not exist in the borrow stack for this location + | this error occurs as part of an access at ALLOC[0x0..0x4] | = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information diff --git a/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs b/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs index e96f08fc9a7..0a326a453e9 100644 --- a/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs +++ b/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs @@ -12,8 +12,6 @@ fn main() { // Manually make sure the pointer is properly aligned. let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr + 1 }; let u16_ptr = base_addr_aligned as *mut u16; - unsafe { - *u16_ptr = 2; //~ERROR memory with alignment 1, but alignment 2 is required - } + unsafe { *u16_ptr = 2 }; //~ERROR memory with alignment 1, but alignment 2 is required println!("{:?}", x); } diff --git a/tests/fail/unaligned_pointers/intptrcast_alignment_check.stderr b/tests/fail/unaligned_pointers/intptrcast_alignment_check.stderr index fe63b05a550..347486187e1 100644 --- a/tests/fail/unaligned_pointers/intptrcast_alignment_check.stderr +++ b/tests/fail/unaligned_pointers/intptrcast_alignment_check.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required --> $DIR/intptrcast_alignment_check.rs:LL:CC | -LL | *u16_ptr = 2; - | ^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required +LL | unsafe { *u16_ptr = 2 }; + | ^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required | = help: this usually indicates that your program performed an invalid operation and caused Undefined Behavior = help: but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives diff --git a/tests/fail/validity/transmute_through_ptr.rs b/tests/fail/validity/transmute_through_ptr.rs index 4af3b8aef6a..049c57e6193 100644 --- a/tests/fail/validity/transmute_through_ptr.rs +++ b/tests/fail/validity/transmute_through_ptr.rs @@ -6,9 +6,7 @@ enum Bool { fn evil(x: &mut Bool) { let x = x as *mut _ as *mut u32; - unsafe { - *x = 44; // out-of-bounds enum tag - } + unsafe { *x = 44 }; // out-of-bounds enum tag } #[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391 diff --git a/tests/fail/zst2.rs b/tests/fail/zst2.rs index 2499f79142d..9f92e8994d2 100644 --- a/tests/fail/zst2.rs +++ b/tests/fail/zst2.rs @@ -11,7 +11,5 @@ fn main() { let mut x_box = Box::new(1u8); let x = &mut *x_box as *mut _ as *mut [u8; 0]; drop(x_box); - unsafe { - *x = zst_val; //~ ERROR dereferenced after this allocation got freed - } + unsafe { *x = zst_val }; //~ ERROR dereferenced after this allocation got freed } diff --git a/tests/fail/zst2.stderr b/tests/fail/zst2.stderr index 0df2098d2e1..3112a87489a 100644 --- a/tests/fail/zst2.stderr +++ b/tests/fail/zst2.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed --> $DIR/zst2.rs:LL:CC | -LL | *x = zst_val; - | ^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed +LL | unsafe { *x = zst_val }; + | ^^^^^^^^^^^^ pointer to ALLOC was dereferenced after this allocation got freed | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/fail/zst3.rs b/tests/fail/zst3.rs index 741374c7ad9..3f3b0af14db 100644 --- a/tests/fail/zst3.rs +++ b/tests/fail/zst3.rs @@ -11,12 +11,8 @@ fn main() { let mut x_box = Box::new(1u8); let x = (&mut *x_box as *mut u8).wrapping_offset(1); // This one is just "at the edge", but still okay - unsafe { - *(x as *mut [u8; 0]) = zst_val; - } + unsafe { *(x as *mut [u8; 0]) = zst_val }; // One byte further is OOB. let x = x.wrapping_offset(1); - unsafe { - *(x as *mut [u8; 0]) = zst_val; //~ ERROR out-of-bounds - } + unsafe { *(x as *mut [u8; 0]) = zst_val }; //~ ERROR out-of-bounds } diff --git a/tests/fail/zst3.stderr b/tests/fail/zst3.stderr index dce0d7b3891..bc3436b14ac 100644 --- a/tests/fail/zst3.stderr +++ b/tests/fail/zst3.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds --> $DIR/zst3.rs:LL:CC | -LL | *(x as *mut [u8; 0]) = zst_val; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds +LL | unsafe { *(x as *mut [u8; 0]) = zst_val }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset 2 is out-of-bounds | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/pass/concurrency/data_race.rs b/tests/pass/concurrency/data_race.rs index 071f5bbcdf3..812003ef4d9 100644 --- a/tests/pass/concurrency/data_race.rs +++ b/tests/pass/concurrency/data_race.rs @@ -18,9 +18,7 @@ fn test_fence_sync() { let evil_ptr = EvilSend(ptr); let j1 = spawn(move || { - unsafe { - *evil_ptr.0 = 1; - } + unsafe { *evil_ptr.0 = 1 }; fence(Ordering::Release); SYNC.store(1, Ordering::Relaxed) });