Manual adjustments

This commit is contained in:
David Tolnay 2022-06-21 11:40:02 -07:00
parent 6827ac2f37
commit 7326da7ce3
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
51 changed files with 102 additions and 102 deletions

View File

@ -7,8 +7,8 @@ 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
(*ptr).set(20); //~ ERROR does not exist in the borrow stack
}
val.get()
}

View File

@ -8,6 +8,6 @@ fn main() {
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
*ptr = zst_val; //~ ERROR out-of-bounds
}
}

View File

@ -10,6 +10,6 @@ fn main() {
let ptr = &mut data[0] as *mut u16;
// Even copying 0 elements from NULL should error.
unsafe {
copy_nonoverlapping(std::ptr::null(), ptr, 0);
} //~ ERROR: memory access failed: null pointer is not a valid pointer
copy_nonoverlapping(std::ptr::null(), ptr, 0); //~ ERROR: memory access failed: null pointer is not a valid pointer
}
}

View File

@ -10,6 +10,6 @@ fn main() {
let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
// Even copying 0 elements to something unaligned should error
unsafe {
copy_nonoverlapping(&data[5], ptr, 0);
} //~ ERROR accessing memory with alignment 1, but alignment 2 is required
copy_nonoverlapping(&data[5], ptr, 0); //~ ERROR accessing memory with alignment 1, but alignment 2 is required
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// divison by 0
unsafe {
std::intrinsics::exact_div(2, 0);
} //~ ERROR divisor of zero
std::intrinsics::exact_div(2, 0); //~ ERROR divisor of zero
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// divison with a remainder
unsafe {
std::intrinsics::exact_div(2u16, 3);
} //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder
std::intrinsics::exact_div(2u16, 3); //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder
}
}

View File

@ -2,6 +2,6 @@
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
std::intrinsics::exact_div(-19i8, 2); //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// divison of MIN by -1
unsafe {
std::intrinsics::exact_div(i64::MIN, -1);
} //~ ERROR overflow in signed remainder (dividing MIN by -1)
std::intrinsics::exact_div(i64::MIN, -1); //~ ERROR overflow in signed remainder (dividing MIN by -1)
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, i32>(f32::INFINITY);
} //~ ERROR: cannot be represented in target type `i32`
float_to_int_unchecked::<f32, i32>(f32::INFINITY); //~ ERROR: cannot be represented in target type `i32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, i32>(f32::NEG_INFINITY);
} //~ ERROR: cannot be represented in target type `i32`
float_to_int_unchecked::<f32, i32>(f32::NEG_INFINITY); //~ ERROR: cannot be represented in target type `i32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, u32>(f32::NAN);
} //~ ERROR: cannot be represented in target type `u32`
float_to_int_unchecked::<f32, u32>(f32::NAN); //~ ERROR: cannot be represented in target type `u32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, u32>(-f32::NAN);
} //~ ERROR: cannot be represented in target type `u32`
float_to_int_unchecked::<f32, u32>(-f32::NAN); //~ ERROR: cannot be represented in target type `u32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, u32>(-1.000000001f32);
} //~ ERROR: cannot be represented in target type `u32`
float_to_int_unchecked::<f32, u32>(-1.000000001f32); //~ ERROR: cannot be represented in target type `u32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, i32>(2147483648.0f32);
} //~ ERROR: cannot be represented in target type `i32`
float_to_int_unchecked::<f32, i32>(2147483648.0f32); //~ ERROR: cannot be represented in target type `i32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, u32>((u32::MAX - 127) as f32);
} //~ ERROR: cannot be represented in target type `u32`
float_to_int_unchecked::<f32, u32>((u32::MAX - 127) as f32); //~ ERROR: cannot be represented in target type `u32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f32, i32>(-2147483904.0f32);
} //~ ERROR: cannot be represented in target type `i32`
float_to_int_unchecked::<f32, i32>(-2147483904.0f32); //~ ERROR: cannot be represented in target type `i32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u128>(f64::INFINITY);
} //~ ERROR: cannot be represented in target type `u128`
float_to_int_unchecked::<f64, u128>(f64::INFINITY); //~ ERROR: cannot be represented in target type `u128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u128>(f64::NEG_INFINITY);
} //~ ERROR: cannot be represented in target type `u128`
float_to_int_unchecked::<f64, u128>(f64::NEG_INFINITY); //~ ERROR: cannot be represented in target type `u128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i128>(f64::NEG_INFINITY);
} //~ ERROR: cannot be represented in target type `i128`
float_to_int_unchecked::<f64, i128>(f64::NEG_INFINITY); //~ ERROR: cannot be represented in target type `i128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u32>(f64::NAN);
} //~ ERROR: cannot be represented in target type `u32`
float_to_int_unchecked::<f64, u32>(f64::NAN); //~ ERROR: cannot be represented in target type `u32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u128>(-1.0000000000001f64);
} //~ ERROR: cannot be represented in target type `u128`
float_to_int_unchecked::<f64, u128>(-1.0000000000001f64); //~ ERROR: cannot be represented in target type `u128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i32>(2147483648.0f64);
} //~ ERROR: cannot be represented in target type `i32`
float_to_int_unchecked::<f64, i32>(2147483648.0f64); //~ ERROR: cannot be represented in target type `i32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i64>(9223372036854775808.0f64);
} //~ ERROR: cannot be represented in target type `i64`
float_to_int_unchecked::<f64, i64>(9223372036854775808.0f64); //~ ERROR: cannot be represented in target type `i64`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u64>(18446744073709551616.0f64);
} //~ ERROR: cannot be represented in target type `u64`
float_to_int_unchecked::<f64, u64>(18446744073709551616.0f64); //~ ERROR: cannot be represented in target type `u64`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u128>(u128::MAX as f64);
} //~ ERROR: cannot be represented in target type `u128`
float_to_int_unchecked::<f64, u128>(u128::MAX as f64); //~ ERROR: cannot be represented in target type `u128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i128>(240282366920938463463374607431768211455.0f64);
} //~ ERROR: cannot be represented in target type `i128`
float_to_int_unchecked::<f64, i128>(240282366920938463463374607431768211455.0f64); //~ ERROR: cannot be represented in target type `i128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, u128>(f64::MAX);
} //~ ERROR: cannot be represented in target type `u128`
float_to_int_unchecked::<f64, u128>(f64::MAX); //~ ERROR: cannot be represented in target type `u128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i128>(f64::MIN);
} //~ ERROR: cannot be represented in target type `i128`
float_to_int_unchecked::<f64, i128>(f64::MIN); //~ ERROR: cannot be represented in target type `i128`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i32>(-2147483649.0f64);
} //~ ERROR: cannot be represented in target type `i32`
float_to_int_unchecked::<f64, i32>(-2147483649.0f64); //~ ERROR: cannot be represented in target type `i32`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i64>(-9223372036854777856.0f64);
} //~ ERROR: cannot be represented in target type `i64`
float_to_int_unchecked::<f64, i64>(-9223372036854777856.0f64); //~ ERROR: cannot be represented in target type `i64`
}
}

View File

@ -7,6 +7,6 @@ extern "rust-intrinsic" {
fn main() {
unsafe {
float_to_int_unchecked::<f64, i128>(-240282366920938463463374607431768211455.0f64);
} //~ ERROR: cannot be represented in target type `i128`
float_to_int_unchecked::<f64, i128>(-240282366920938463463374607431768211455.0f64); //~ ERROR: cannot be represented in target type `i128`
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MAX overflow
unsafe {
std::intrinsics::unchecked_add(40000u16, 30000);
} //~ ERROR overflow executing `unchecked_add`
std::intrinsics::unchecked_add(40000u16, 30000); //~ ERROR overflow executing `unchecked_add`
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MIN overflow
unsafe {
std::intrinsics::unchecked_add(-30000i16, -8000);
} //~ ERROR overflow executing `unchecked_add`
std::intrinsics::unchecked_add(-30000i16, -8000); //~ ERROR overflow executing `unchecked_add`
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MIN/-1 cannot be represented
unsafe {
std::intrinsics::unchecked_div(i16::MIN, -1);
} //~ ERROR overflow in signed division (dividing MIN by -1)
std::intrinsics::unchecked_div(i16::MIN, -1); //~ ERROR overflow in signed division (dividing MIN by -1)
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MAX overflow
unsafe {
std::intrinsics::unchecked_mul(300u16, 250u16);
} //~ ERROR overflow executing `unchecked_mul`
std::intrinsics::unchecked_mul(300u16, 250u16); //~ ERROR overflow executing `unchecked_mul`
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MIN overflow
unsafe {
std::intrinsics::unchecked_mul(1_000_000_000i32, -4);
} //~ ERROR overflow executing `unchecked_mul`
std::intrinsics::unchecked_mul(1_000_000_000i32, -4); //~ ERROR overflow executing `unchecked_mul`
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MIN overflow
unsafe {
std::intrinsics::unchecked_sub(14u32, 22);
} //~ ERROR overflow executing `unchecked_sub`
std::intrinsics::unchecked_sub(14u32, 22); //~ ERROR overflow executing `unchecked_sub`
}
}

View File

@ -2,6 +2,6 @@
fn main() {
// MAX overflow
unsafe {
std::intrinsics::unchecked_sub(30000i16, -7000);
} //~ ERROR overflow executing `unchecked_sub`
std::intrinsics::unchecked_sub(30000i16, -7000); //~ ERROR overflow executing `unchecked_sub`
}
}

View File

@ -8,6 +8,6 @@ extern "Rust" {
fn main() {
unsafe {
miri_start_panic(&mut 0);
} //~ ERROR unwinding past a stack frame that does not allow unwinding
miri_start_panic(&mut 0); //~ ERROR unwinding past a stack frame that does not allow unwinding
}
}

View File

@ -4,8 +4,8 @@ fn main() {
{
let x: *mut u32 = xref as *const _ as *mut _;
unsafe {
*x = 42;
} // invalidates shared ref, activates raw
*x = 42; // invalidates shared ref, activates raw
}
}
let _x = *xref; //~ ERROR borrow stack
}

View File

@ -4,7 +4,7 @@ fn main() {
drop(&mut *target); // reborrow
// Now make sure our ref is still the only one.
unsafe {
*target2 = 13;
} //~ ERROR borrow stack
*target2 = 13; //~ ERROR borrow stack
}
let _val = *target;
}

View File

@ -4,7 +4,7 @@ fn main() {
let r#ref = &target; // freeze
let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag
unsafe {
*ptr = 42;
} //~ ERROR only grants SharedReadOnly permission
*ptr = 42; //~ ERROR only grants SharedReadOnly permission
}
let _val = *r#ref;
}

View File

@ -8,7 +8,7 @@ fn foo(a: &mut u32, y: *mut u32) -> u32 {
*a = 1;
let _b = &*a;
unsafe {
*y = 2;
} //~ ERROR: not granting access to tag
*y = 2; //~ ERROR: not granting access to tag
}
return *a;
}

View File

@ -8,8 +8,8 @@ fn main() {
// 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
*raw1 = 13; //~ ERROR does not exist in the borrow stack
}
unsafe {
*raw2 = 13;
}

View File

@ -10,6 +10,6 @@ fn main() {
fn unknown_code(x: &i32) {
unsafe {
*(x as *const i32 as *mut i32) = 7;
} //~ ERROR only grants SharedReadOnly permission
*(x as *const i32 as *mut i32) = 7; //~ ERROR only grants SharedReadOnly permission
}
}

View File

@ -11,6 +11,6 @@ fn main() {
// `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
*raw = 13; //~ ERROR borrow stack
}
}

View File

@ -5,6 +5,6 @@ fn main() {
let raw = &mut x as *mut i32 as usize as *mut i32;
let _ptr = &mut x;
unsafe {
*raw = 13;
} //~ ERROR borrow stack
*raw = 13; //~ ERROR borrow stack
}
}

View File

@ -13,7 +13,7 @@ fn main() {
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
*u16_ptr = 2; //~ERROR memory with alignment 1, but alignment 2 is required
}
println!("{:?}", x);
}

View File

@ -7,8 +7,8 @@ enum Bool {
fn evil(x: &mut Bool) {
let x = x as *mut _ as *mut u32;
unsafe {
*x = 44;
} // out-of-bounds enum tag
*x = 44; // out-of-bounds enum tag
}
}
#[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391

View File

@ -12,6 +12,6 @@ fn main() {
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
*x = zst_val; //~ ERROR dereferenced after this allocation got freed
}
}

View File

@ -17,6 +17,6 @@ fn main() {
// One byte further is OOB.
let x = x.wrapping_offset(1);
unsafe {
*(x as *mut [u8; 0]) = zst_val;
} //~ ERROR out-of-bounds
*(x as *mut [u8; 0]) = zst_val; //~ ERROR out-of-bounds
}
}