From 8ae66db798ae61342442eaafca8cd4dddab47a91 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 9 May 2018 17:45:16 +0200 Subject: [PATCH] Convert some of the tests to the new format --- tests/compile-fail/alignment.rs | 3 ++- tests/compile-fail/assume.rs | 3 ++- tests/compile-fail/bitop-beyond-alignment.rs | 5 +++-- tests/compile-fail/cast_box_int_to_fn_ptr.rs | 3 ++- tests/compile-fail/cast_fn_ptr.rs | 3 ++- tests/compile-fail/cast_fn_ptr2.rs | 3 ++- tests/compile-fail/cast_int_to_fn_ptr.rs | 3 ++- tests/compile-fail/ctlz_nonzero.rs | 3 ++- tests/compile-fail/cttz_nonzero.rs | 3 ++- tests/compile-fail/dangling_pointer_deref.rs | 3 ++- tests/compile-fail/deref_fn_ptr.rs | 3 ++- tests/compile-fail/div-by-zero-2.rs | 3 ++- tests/compile-fail/execute_memory.rs | 3 ++- tests/compile-fail/fn_ptr_offset.rs | 3 ++- tests/compile-fail/invalid_bool.rs | 5 +++-- tests/compile-fail/invalid_enum_discriminant.rs | 5 +++-- tests/compile-fail/modifying_constants.rs | 3 ++- tests/compile-fail/never_say_never.rs | 3 ++- tests/compile-fail/never_transmute_humans.rs | 2 +- tests/compile-fail/never_transmute_void.rs | 5 +++-- tests/compile-fail/null_pointer_deref.rs | 3 ++- tests/compile-fail/oom.rs | 7 ------- tests/compile-fail/out_of_bounds_read.rs | 3 ++- tests/compile-fail/out_of_bounds_read2.rs | 3 ++- tests/compile-fail/overflowing-lsh-neg.rs | 3 ++- tests/compile-fail/overflowing-rsh.rs | 3 ++- ...rwriting_part_of_relocation_makes_the_rest_undefined.rs | 3 ++- tests/compile-fail/pointer_byte_read_1.rs | 3 ++- tests/compile-fail/pointer_byte_read_2.rs | 3 ++- .../pointers_to_different_allocations_are_unorderable.rs | 3 ++- tests/compile-fail/ptr_bitops.rs | 3 ++- tests/compile-fail/ptr_int_cast.rs | 3 ++- tests/compile-fail/reading_half_a_pointer.rs | 3 ++- tests/compile-fail/reallocate-change-alloc.rs | 3 ++- tests/compile-fail/reference_to_packed.rs | 3 ++- tests/compile-fail/static_memory_modification2.rs | 3 ++- tests/compile-fail/static_memory_modification3.rs | 3 ++- tests/compile-fail/transmute-pair-undef.rs | 3 ++- tests/compile-fail/transmute_fat.rs | 3 ++- tests/compile-fail/transmute_fat2.rs | 3 ++- tests/compile-fail/unaligned_ptr_cast.rs | 3 ++- tests/compile-fail/unaligned_ptr_cast2.rs | 3 ++- tests/compile-fail/unaligned_ptr_cast_zst.rs | 3 ++- tests/compile-fail/wild_pointer_deref.rs | 3 ++- tests/compile-fail/zst.rs | 3 ++- 45 files changed, 91 insertions(+), 55 deletions(-) delete mode 100644 tests/compile-fail/oom.rs diff --git a/tests/compile-fail/alignment.rs b/tests/compile-fail/alignment.rs index 4faaa359df62..9730fe473aa5 100644 --- a/tests/compile-fail/alignment.rs +++ b/tests/compile-fail/alignment.rs @@ -5,7 +5,8 @@ fn main() { let x_ptr: *mut u8 = &mut x[0]; let y_ptr = x_ptr as *mut u64; unsafe { - *y_ptr = 42; //~ ERROR tried to access memory with alignment 1, but alignment + *y_ptr = 42; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access memory with alignment 1, but alignment } panic!("unreachable in miri"); } diff --git a/tests/compile-fail/assume.rs b/tests/compile-fail/assume.rs index 69758a5d7fe8..cf0632393ad6 100644 --- a/tests/compile-fail/assume.rs +++ b/tests/compile-fail/assume.rs @@ -5,6 +5,7 @@ fn main() { unsafe { std::intrinsics::assume(x < 10); std::intrinsics::assume(x > 1); - std::intrinsics::assume(x > 42); //~ ERROR: `assume` argument was false + std::intrinsics::assume(x > 42); //~ ERROR constant evaluation error [E0080] + //~^ NOTE `assume` argument was false } } diff --git a/tests/compile-fail/bitop-beyond-alignment.rs b/tests/compile-fail/bitop-beyond-alignment.rs index a30c054ab5d0..89f5e048a36d 100644 --- a/tests/compile-fail/bitop-beyond-alignment.rs +++ b/tests/compile-fail/bitop-beyond-alignment.rs @@ -28,10 +28,11 @@ fn mk_rec() -> Rec { fn is_u64_aligned(u: &Tag) -> bool { let p: usize = unsafe { mem::transmute(u) }; let u64_align = std::mem::align_of::(); - return (p & (u64_align + 1)) == 0; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes + return (p & (u64_align + 1)) == 0; //~ ERROR constant evaluation error [E0080] + //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes } pub fn main() { let x = mk_rec(); - assert!(is_u64_aligned(&x.t)); + assert!(is_u64_aligned(&x.t)); //~ NOTE inside call to `is_u64_aligned } diff --git a/tests/compile-fail/cast_box_int_to_fn_ptr.rs b/tests/compile-fail/cast_box_int_to_fn_ptr.rs index 912b1bd7d91f..39b53da0b75c 100644 --- a/tests/compile-fail/cast_box_int_to_fn_ptr.rs +++ b/tests/compile-fail/cast_box_int_to_fn_ptr.rs @@ -7,5 +7,6 @@ fn main() { std::mem::transmute::<&usize, &fn(i32)>(&b) }; - (*g)(42) //~ ERROR a memory access tried to interpret some bytes as a pointer + (*g)(42) //~ ERROR constant evaluation error [E0080] + //~^ NOTE a memory access tried to interpret some bytes as a pointer } diff --git a/tests/compile-fail/cast_fn_ptr.rs b/tests/compile-fail/cast_fn_ptr.rs index 7509ae6ed77c..19344b13ba7c 100644 --- a/tests/compile-fail/cast_fn_ptr.rs +++ b/tests/compile-fail/cast_fn_ptr.rs @@ -5,5 +5,6 @@ fn main() { std::mem::transmute::(f) }; - g(42) //~ ERROR tried to call a function with sig fn() through a function pointer of type fn(i32) + g(42) //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to call a function with sig fn() through a function pointer of type fn(i32) } diff --git a/tests/compile-fail/cast_fn_ptr2.rs b/tests/compile-fail/cast_fn_ptr2.rs index 5d902e1f9aaa..23868c0e57db 100644 --- a/tests/compile-fail/cast_fn_ptr2.rs +++ b/tests/compile-fail/cast_fn_ptr2.rs @@ -5,5 +5,6 @@ fn main() { std::mem::transmute::(f) }; - g(42) //~ ERROR tried to call a function with sig fn((i32, i32)) through a function pointer of type fn(i32) + g(42) //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to call a function with sig fn((i32, i32)) through a function pointer of type fn(i32) } diff --git a/tests/compile-fail/cast_int_to_fn_ptr.rs b/tests/compile-fail/cast_int_to_fn_ptr.rs index 23f85dbaf3ec..c7556ae06b93 100644 --- a/tests/compile-fail/cast_int_to_fn_ptr.rs +++ b/tests/compile-fail/cast_int_to_fn_ptr.rs @@ -6,5 +6,6 @@ fn main() { std::mem::transmute::(42) }; - g(42) //~ ERROR a memory access tried to interpret some bytes as a pointer + g(42) //~ ERROR constant evaluation error [E0080] + //~^ NOTE a memory access tried to interpret some bytes as a pointer } diff --git a/tests/compile-fail/ctlz_nonzero.rs b/tests/compile-fail/ctlz_nonzero.rs index 704c4d4b7d46..d952187eba45 100644 --- a/tests/compile-fail/ctlz_nonzero.rs +++ b/tests/compile-fail/ctlz_nonzero.rs @@ -10,6 +10,7 @@ pub fn main() { unsafe { use rusti::*; - ctlz_nonzero(0u8); //~ ERROR: ctlz_nonzero called on 0 + ctlz_nonzero(0u8); //~ ERROR constant evaluation error [E0080] + //~^ NOTE ctlz_nonzero called on 0 } } diff --git a/tests/compile-fail/cttz_nonzero.rs b/tests/compile-fail/cttz_nonzero.rs index eda25c661521..b308484622bc 100644 --- a/tests/compile-fail/cttz_nonzero.rs +++ b/tests/compile-fail/cttz_nonzero.rs @@ -10,6 +10,7 @@ pub fn main() { unsafe { use rusti::*; - cttz_nonzero(0u8); //~ ERROR: cttz_nonzero called on 0 + cttz_nonzero(0u8); //~ ERROR constant evaluation error [E0080] + //~^ NOTE cttz_nonzero called on 0 } } diff --git a/tests/compile-fail/dangling_pointer_deref.rs b/tests/compile-fail/dangling_pointer_deref.rs index 0ede7c96f004..d42c1d33b530 100644 --- a/tests/compile-fail/dangling_pointer_deref.rs +++ b/tests/compile-fail/dangling_pointer_deref.rs @@ -3,6 +3,7 @@ fn main() { let b = Box::new(42); &*b as *const i32 }; - let x = unsafe { *p }; //~ ERROR: dangling pointer was dereferenced + let x = unsafe { *p }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE dangling pointer was dereferenced panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/deref_fn_ptr.rs b/tests/compile-fail/deref_fn_ptr.rs index c1eaf7eaa61d..a56df5bce408 100644 --- a/tests/compile-fail/deref_fn_ptr.rs +++ b/tests/compile-fail/deref_fn_ptr.rs @@ -2,7 +2,8 @@ fn f() {} fn main() { let x: i32 = unsafe { - *std::mem::transmute::(f) //~ ERROR: tried to dereference a function pointer + *std::mem::transmute::(f) //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to dereference a function pointer }; panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/div-by-zero-2.rs b/tests/compile-fail/div-by-zero-2.rs index 3e869ad4a507..c90ca8d15cce 100644 --- a/tests/compile-fail/div-by-zero-2.rs +++ b/tests/compile-fail/div-by-zero-2.rs @@ -11,5 +11,6 @@ #![allow(const_err)] fn main() { - let _n = 1 / 0; //~ ERROR: DivisionByZero + let _n = 1 / 0; //~ ERROR constant evaluation error [E0080] + //~^ NOTE attempt to divide by zero } diff --git a/tests/compile-fail/execute_memory.rs b/tests/compile-fail/execute_memory.rs index 87d975e1f9d4..014c551df0f1 100644 --- a/tests/compile-fail/execute_memory.rs +++ b/tests/compile-fail/execute_memory.rs @@ -7,6 +7,7 @@ fn main() { let x = box 42; unsafe { let f = std::mem::transmute::, fn()>(x); - f() //~ ERROR: tried to treat a memory pointer as a function pointer + f() //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to treat a memory pointer as a function pointer } } diff --git a/tests/compile-fail/fn_ptr_offset.rs b/tests/compile-fail/fn_ptr_offset.rs index 45e32142a8c4..20eb6573989c 100644 --- a/tests/compile-fail/fn_ptr_offset.rs +++ b/tests/compile-fail/fn_ptr_offset.rs @@ -10,5 +10,6 @@ fn main() { let y : *mut u8 = unsafe { mem::transmute(x) }; let y = y.wrapping_offset(1); let x : fn() = unsafe { mem::transmute(y) }; - x(); //~ ERROR: tried to use a function pointer after offsetting it + x(); //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to use a function pointer after offsetting it } diff --git a/tests/compile-fail/invalid_bool.rs b/tests/compile-fail/invalid_bool.rs index c30c9b439a46..07c407966a8f 100644 --- a/tests/compile-fail/invalid_bool.rs +++ b/tests/compile-fail/invalid_bool.rs @@ -1,4 +1,5 @@ fn main() { - let b = unsafe { std::mem::transmute::(2) }; //~ ERROR: invalid boolean value read - if b { unreachable!() } else { unreachable!() } + let b = unsafe { std::mem::transmute::(2) }; + if b { unreachable!() } else { unreachable!() } //~ ERROR constant evaluation error [E0080] + //~^ NOTE invalid boolean value read } diff --git a/tests/compile-fail/invalid_enum_discriminant.rs b/tests/compile-fail/invalid_enum_discriminant.rs index 9ce6d44ca460..69d7e3e427d4 100644 --- a/tests/compile-fail/invalid_enum_discriminant.rs +++ b/tests/compile-fail/invalid_enum_discriminant.rs @@ -9,9 +9,10 @@ pub enum Foo { fn main() { let f = unsafe { std::mem::transmute::(42) }; match f { - Foo::A => {}, //~ ERROR invalid enum discriminant value read + Foo::A => {}, Foo::B => {}, Foo::C => {}, Foo::D => {}, } -} +} //~ ERROR constant evaluation error [E0080] +//~^ NOTE entered unreachable code diff --git a/tests/compile-fail/modifying_constants.rs b/tests/compile-fail/modifying_constants.rs index cb2e7217d579..06920fa0acf1 100644 --- a/tests/compile-fail/modifying_constants.rs +++ b/tests/compile-fail/modifying_constants.rs @@ -1,6 +1,7 @@ fn main() { let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee let y = unsafe { &mut *(x as *const i32 as *mut i32) }; - *y = 42; //~ ERROR tried to modify constant memory + *y = 42; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to modify constant memory assert_eq!(*x, 42); } diff --git a/tests/compile-fail/never_say_never.rs b/tests/compile-fail/never_say_never.rs index 71306cc62bf7..de8815ffd9c4 100644 --- a/tests/compile-fail/never_say_never.rs +++ b/tests/compile-fail/never_say_never.rs @@ -7,7 +7,8 @@ fn main() { let y = &5; let x: ! = unsafe { - *(y as *const _ as *const !) //~ ERROR entered unreachable code + *(y as *const _ as *const !) //~ ERROR constant evaluation error [E0080] + //~^ NOTE entered unreachable code }; f(x) } diff --git a/tests/compile-fail/never_transmute_humans.rs b/tests/compile-fail/never_transmute_humans.rs index d0662c917ba7..3924dc7371e7 100644 --- a/tests/compile-fail/never_transmute_humans.rs +++ b/tests/compile-fail/never_transmute_humans.rs @@ -1,5 +1,5 @@ // This should fail even without validation -// compile-fail causes rustc ICE: rust-lang/rust#50570 +// ignore-test causes rustc ICE: rust-lang/rust#50570 // compile-flags: -Zmir-emit-validate=0 #![feature(never_type)] diff --git a/tests/compile-fail/never_transmute_void.rs b/tests/compile-fail/never_transmute_void.rs index 0b0897644409..4f1499483eda 100644 --- a/tests/compile-fail/never_transmute_void.rs +++ b/tests/compile-fail/never_transmute_void.rs @@ -8,12 +8,13 @@ enum Void {} fn f(v: Void) -> ! { - match v {} //~ ERROR entered unreachable code + match v {} //~ ERROR constant evaluation error [E0080] + //~^ NOTE entered unreachable code } fn main() { let v: Void = unsafe { std::mem::transmute::<(), Void>(()) }; - f(v); + f(v); //~ inside call to `f` } diff --git a/tests/compile-fail/null_pointer_deref.rs b/tests/compile-fail/null_pointer_deref.rs index 5a26856eba08..70df937c4c7c 100644 --- a/tests/compile-fail/null_pointer_deref.rs +++ b/tests/compile-fail/null_pointer_deref.rs @@ -1,4 +1,5 @@ fn main() { - let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: invalid use of NULL pointer + let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE invalid use of NULL pointer panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/oom.rs b/tests/compile-fail/oom.rs deleted file mode 100644 index d4aebb912ee1..000000000000 --- a/tests/compile-fail/oom.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(custom_attribute, attr_literals)] -#![miri(memory_size=4095)] - -fn main() { - let _x = [42; 1024]; - //~^ERROR tried to allocate 4096 more bytes, but only -} diff --git a/tests/compile-fail/out_of_bounds_read.rs b/tests/compile-fail/out_of_bounds_read.rs index 8c56b14bdf22..d8811e7abcd2 100644 --- a/tests/compile-fail/out_of_bounds_read.rs +++ b/tests/compile-fail/out_of_bounds_read.rs @@ -1,5 +1,6 @@ fn main() { let v: Vec = vec![1, 2]; - let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR: which has size 2 + let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE which has size 2 panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/out_of_bounds_read2.rs b/tests/compile-fail/out_of_bounds_read2.rs index d29b22ffb2a6..54738cf81fbd 100644 --- a/tests/compile-fail/out_of_bounds_read2.rs +++ b/tests/compile-fail/out_of_bounds_read2.rs @@ -1,5 +1,6 @@ fn main() { let v: Vec = vec![1, 2]; - let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR: memory access at offset 6, outside bounds of allocation + let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE memory access at offset 6, outside bounds of allocation panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/overflowing-lsh-neg.rs b/tests/compile-fail/overflowing-lsh-neg.rs index 3a889be741ef..e50e42503649 100644 --- a/tests/compile-fail/overflowing-lsh-neg.rs +++ b/tests/compile-fail/overflowing-lsh-neg.rs @@ -12,5 +12,6 @@ #![allow(const_err)] fn main() { - let _n = 2i64 << -1; //~ Overflow(Shl) + let _n = 2i64 << -1; //~ ERROR constant evaluation error [E0080] + //~^ NOTE attempt to shift left with overflow } diff --git a/tests/compile-fail/overflowing-rsh.rs b/tests/compile-fail/overflowing-rsh.rs index a7ac9d1d5039..c291815e2e79 100644 --- a/tests/compile-fail/overflowing-rsh.rs +++ b/tests/compile-fail/overflowing-rsh.rs @@ -11,5 +11,6 @@ #![allow(exceeding_bitshifts)] fn main() { - let _n = 1i64 >> 64; //~ Overflow(Shr) + let _n = 1i64 >> 64; //~ ERROR constant evaluation error [E0080] + //~^ NOTE attempt to shift right with overflow } diff --git a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs index 50f51d0ba9ca..fabbef5004d7 100644 --- a/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs +++ b/tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs @@ -6,6 +6,7 @@ fn main() { // "attempted to interpret some raw bytes as a pointer address" instead of // "attempted to read undefined bytes" } - let x = *p; //~ ERROR: attempted to read undefined bytes + let x = *p; //~ ERROR constant evaluation error [E0080] + //~^ NOTE attempted to read undefined bytes panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/pointer_byte_read_1.rs b/tests/compile-fail/pointer_byte_read_1.rs index 342eb28a970f..012af897e837 100644 --- a/tests/compile-fail/pointer_byte_read_1.rs +++ b/tests/compile-fail/pointer_byte_read_1.rs @@ -3,5 +3,6 @@ fn main() { let y = &x; let z = &y as *const &i32 as *const usize; let ptr_bytes = unsafe { *z }; // the actual deref is fine, because we read the entire pointer at once - let _ = ptr_bytes % 432; //~ ERROR: tried to access part of a pointer value as raw bytes + let _ = ptr_bytes % 432; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access part of a pointer value as raw bytes } diff --git a/tests/compile-fail/pointer_byte_read_2.rs b/tests/compile-fail/pointer_byte_read_2.rs index b0f619332e00..4d25a36a3c88 100644 --- a/tests/compile-fail/pointer_byte_read_2.rs +++ b/tests/compile-fail/pointer_byte_read_2.rs @@ -3,5 +3,6 @@ fn main() { let y = &x; let z = &y as *const &i32 as *const u8; // the deref fails, because we are reading only a part of the pointer - let _ = unsafe { *z }; //~ ERROR: tried to access part of a pointer value as raw bytes + let _ = unsafe { *z }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access part of a pointer value as raw bytes } diff --git a/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs b/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs index 245b7527c55b..72ae1b123e8a 100644 --- a/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs +++ b/tests/compile-fail/pointers_to_different_allocations_are_unorderable.rs @@ -1,7 +1,8 @@ fn main() { let x: *const u8 = &1; let y: *const u8 = &2; - if x < y { //~ ERROR: attempted to do invalid arithmetic on pointers + if x < y { //~ ERROR constant evaluation error [E0080] + //~^ NOTE attempted to do invalid arithmetic on pointers unreachable!() } } diff --git a/tests/compile-fail/ptr_bitops.rs b/tests/compile-fail/ptr_bitops.rs index 78fd8e912b5e..52bcf24cf6b8 100644 --- a/tests/compile-fail/ptr_bitops.rs +++ b/tests/compile-fail/ptr_bitops.rs @@ -2,6 +2,7 @@ fn main() { let bytes = [0i8, 1, 2, 3, 4, 5, 6, 7, 8, 9]; let one = bytes.as_ptr().wrapping_offset(1); let three = bytes.as_ptr().wrapping_offset(3); - let res = (one as usize) | (three as usize); //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes + let res = (one as usize) | (three as usize); //~ ERROR constant evaluation error [E0080] + //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes println!("{}", res); } diff --git a/tests/compile-fail/ptr_int_cast.rs b/tests/compile-fail/ptr_int_cast.rs index 396c71ebb03d..56403d619ffa 100644 --- a/tests/compile-fail/ptr_int_cast.rs +++ b/tests/compile-fail/ptr_int_cast.rs @@ -2,7 +2,8 @@ fn main() { let x = &1; // Casting down to u8 and back up to a pointer loses too much precision; this must not work. let x = x as *const i32; - let x = x as u8; //~ ERROR: a raw memory access tried to access part of a pointer value as raw bytes + let x = x as u8; //~ ERROR constant evaluation error [E0080] + //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes let x = x as *const i32; let _ = unsafe { *x }; } diff --git a/tests/compile-fail/reading_half_a_pointer.rs b/tests/compile-fail/reading_half_a_pointer.rs index cc41b52f3337..e44f26c4c4cf 100644 --- a/tests/compile-fail/reading_half_a_pointer.rs +++ b/tests/compile-fail/reading_half_a_pointer.rs @@ -24,6 +24,7 @@ fn main() { // starts 1 byte to the right, so using it would actually be wrong! let d_alias = &mut w.data as *mut _ as *mut *const u8; unsafe { - let _x = *d_alias; //~ ERROR: tried to access part of a pointer value as raw bytes + let _x = *d_alias; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access part of a pointer value as raw bytes } } diff --git a/tests/compile-fail/reallocate-change-alloc.rs b/tests/compile-fail/reallocate-change-alloc.rs index 8a788104d869..d8234e933300 100644 --- a/tests/compile-fail/reallocate-change-alloc.rs +++ b/tests/compile-fail/reallocate-change-alloc.rs @@ -9,6 +9,7 @@ fn main() { unsafe { let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)); let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1); - let _z = *(x as *mut u8); //~ ERROR: dangling pointer was dereferenced + let _z = *(x as *mut u8); //~ ERROR constant evaluation error [E0080] + //~^ NOTE dangling pointer was dereferenced } } diff --git a/tests/compile-fail/reference_to_packed.rs b/tests/compile-fail/reference_to_packed.rs index 064386b3d010..16b452ca0e3c 100644 --- a/tests/compile-fail/reference_to_packed.rs +++ b/tests/compile-fail/reference_to_packed.rs @@ -15,5 +15,6 @@ fn main() { y: 99, }; let p = unsafe { &foo.x }; - let i = *p; //~ ERROR tried to access memory with alignment 1, but alignment 4 is required + let i = *p; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access memory with alignment 1, but alignment 4 is required } diff --git a/tests/compile-fail/static_memory_modification2.rs b/tests/compile-fail/static_memory_modification2.rs index f030a9c281de..6abe6de1fcf4 100644 --- a/tests/compile-fail/static_memory_modification2.rs +++ b/tests/compile-fail/static_memory_modification2.rs @@ -7,6 +7,7 @@ use std::mem::transmute; fn main() { unsafe { let s = "this is a test"; - transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR: tried to modify constant memory + transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to modify constant memory } } diff --git a/tests/compile-fail/static_memory_modification3.rs b/tests/compile-fail/static_memory_modification3.rs index 743fbe60efff..0891756f0ec6 100644 --- a/tests/compile-fail/static_memory_modification3.rs +++ b/tests/compile-fail/static_memory_modification3.rs @@ -4,6 +4,7 @@ use std::mem::transmute; fn main() { unsafe { let bs = b"this is a test"; - transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR: tried to modify constant memory + transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to modify constant memory } } diff --git a/tests/compile-fail/transmute-pair-undef.rs b/tests/compile-fail/transmute-pair-undef.rs index acc6098af7ee..6b4fe2273a08 100644 --- a/tests/compile-fail/transmute-pair-undef.rs +++ b/tests/compile-fail/transmute-pair-undef.rs @@ -16,5 +16,6 @@ fn main() { assert_eq!(byte, 0); } let v = unsafe { *z.offset(first_undef) }; - if v == 0 {} //~ ERROR attempted to read undefined bytes + if v == 0 {} //~ ERROR constant evaluation error [E0080] + //~^ NOTE attempted to read undefined bytes } diff --git a/tests/compile-fail/transmute_fat.rs b/tests/compile-fail/transmute_fat.rs index a2ebb6b21aa2..81d783807c58 100644 --- a/tests/compile-fail/transmute_fat.rs +++ b/tests/compile-fail/transmute_fat.rs @@ -10,5 +10,6 @@ fn main() { let bad = unsafe { std::mem::transmute::<&[u8], u64>(&[1u8]) }; - let _ = bad + 1; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes + let _ = bad + 1; //~ ERROR constant evaluation error [E0080] + //~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes } diff --git a/tests/compile-fail/transmute_fat2.rs b/tests/compile-fail/transmute_fat2.rs index 3121a139d920..96a713305e6b 100644 --- a/tests/compile-fail/transmute_fat2.rs +++ b/tests/compile-fail/transmute_fat2.rs @@ -7,5 +7,6 @@ fn main() { let bad = unsafe { std::mem::transmute::(42) }; - bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0 + bad[0]; //~ ERROR constant evaluation error [E0080] + //~^ NOTE index out of bounds: the len is 0 but the index is 0 } diff --git a/tests/compile-fail/unaligned_ptr_cast.rs b/tests/compile-fail/unaligned_ptr_cast.rs index 8ad1b323250c..cb9523395391 100644 --- a/tests/compile-fail/unaligned_ptr_cast.rs +++ b/tests/compile-fail/unaligned_ptr_cast.rs @@ -2,5 +2,6 @@ fn main() { let x = &2u16; let x = x as *const _ as *const u32; // This must fail because alignment is violated - let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment 4 is required + let _x = unsafe { *x }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access memory with alignment 2, but alignment 4 is required } diff --git a/tests/compile-fail/unaligned_ptr_cast2.rs b/tests/compile-fail/unaligned_ptr_cast2.rs index 15fb7dd31368..dee2bbc9972f 100644 --- a/tests/compile-fail/unaligned_ptr_cast2.rs +++ b/tests/compile-fail/unaligned_ptr_cast2.rs @@ -3,5 +3,6 @@ fn main() { let x = x as *const _ as *const *const u8; // This must fail because alignment is violated. Test specifically for loading pointers, which have special code // in miri's memory. - let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment + let _x = unsafe { *x }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access memory with alignment 2, but alignment } diff --git a/tests/compile-fail/unaligned_ptr_cast_zst.rs b/tests/compile-fail/unaligned_ptr_cast_zst.rs index fc603840684e..eba17ab6c640 100644 --- a/tests/compile-fail/unaligned_ptr_cast_zst.rs +++ b/tests/compile-fail/unaligned_ptr_cast_zst.rs @@ -2,5 +2,6 @@ fn main() { let x = &2u16; let x = x as *const _ as *const [u32; 0]; // This must fail because alignment is violated. Test specifically for loading ZST. - let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment 4 is required + let _x = unsafe { *x }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access memory with alignment 2, but alignment 4 is required } diff --git a/tests/compile-fail/wild_pointer_deref.rs b/tests/compile-fail/wild_pointer_deref.rs index 57da8dfc01b2..035d979c5b07 100644 --- a/tests/compile-fail/wild_pointer_deref.rs +++ b/tests/compile-fail/wild_pointer_deref.rs @@ -1,5 +1,6 @@ fn main() { let p = 44 as *const i32; - let x = unsafe { *p }; //~ ERROR: a memory access tried to interpret some bytes as a pointer + let x = unsafe { *p }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE a memory access tried to interpret some bytes as a pointer panic!("this should never print: {}", x); } diff --git a/tests/compile-fail/zst.rs b/tests/compile-fail/zst.rs index 343982404794..d6518a48aa82 100644 --- a/tests/compile-fail/zst.rs +++ b/tests/compile-fail/zst.rs @@ -1,4 +1,5 @@ fn main() { let x = &() as *const () as *const i32; - let _ = unsafe { *x }; //~ ERROR: tried to access memory with alignment 1, but alignment 4 is required + let _ = unsafe { *x }; //~ ERROR constant evaluation error [E0080] + //~^ NOTE tried to access memory with alignment 1, but alignment 4 is required }