Auto merge of #2269 - RalfJung:fmt, r=RalfJung
make a bunch of tests look more like how they did before rustfmt
This commit is contained in:
commit
4e67b63ad3
@ -6,9 +6,7 @@ use std::cell::Cell;
|
||||
|
||||
fn helper(val: Box<Cell<u8>>, ptr: *const Cell<u8>) -> 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()
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,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
|
||||
--> $DIR/box-cell-alias.rs:LL:CC
|
||||
|
|
||||
LL | (*ptr).set(20);
|
||||
| ^^^^^^^^^^^^^^
|
||||
| |
|
||||
| trying to reborrow <TAG> 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 <TAG> 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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ LL | let xref = &*target;
|
||||
help: <TAG> 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,11 +1,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
|
||||
--> $DIR/illegal_write2.rs:LL:CC
|
||||
|
|
||||
LL | *target2 = 13;
|
||||
| ^^^^^^^^^^^^^
|
||||
| |
|
||||
| attempting a write access using <untagged> 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 <untagged> 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: Undefined Behavior: attempting a write access using <untagged> 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 <untagged> 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 <untagged> 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
error: Undefined Behavior: not granting access to tag <untagged> because incompatible item is protected: [Unique for <TAG> (call ID)]
|
||||
--> $DIR/illegal_write6.rs:LL:CC
|
||||
|
|
||||
LL | *y = 2;
|
||||
| ^^^^^^ not granting access to tag <untagged> because incompatible item is protected: [Unique for <TAG> (call ID)]
|
||||
LL | unsafe { *y = 2 };
|
||||
| ^^^^^^ not granting access to tag <untagged> because incompatible item is protected: [Unique for <TAG> (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 | | }
|
||||
| |_^
|
||||
|
@ -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 };
|
||||
}
|
||||
|
@ -1,11 +1,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
|
||||
--> $DIR/raw_tracking.rs:LL:CC
|
||||
|
|
||||
LL | *raw1 = 13;
|
||||
| ^^^^^^^^^^
|
||||
| |
|
||||
| attempting a write access using <TAG> 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 <TAG> 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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -1,11 +1,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
|
||||
--> $DIR/transmute-is-no-escape.rs:LL:CC
|
||||
|
|
||||
LL | *raw = 13;
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| attempting a write access using <untagged> 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 <untagged> 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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user