Skip to content

Commit 1ad9b90

Browse files
committed
Convert some of the tests to the new format
1 parent 42e341d commit 1ad9b90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+91
-55
lines changed

tests/compile-fail/alignment.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ fn main() {
55
let x_ptr: *mut u8 = &mut x[0];
66
let y_ptr = x_ptr as *mut u64;
77
unsafe {
8-
*y_ptr = 42; //~ ERROR tried to access memory with alignment 1, but alignment
8+
*y_ptr = 42; //~ ERROR constant evaluation error [E0080]
9+
//~^ NOTE tried to access memory with alignment 1, but alignment
910
}
1011
panic!("unreachable in miri");
1112
}

tests/compile-fail/assume.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fn main() {
55
unsafe {
66
std::intrinsics::assume(x < 10);
77
std::intrinsics::assume(x > 1);
8-
std::intrinsics::assume(x > 42); //~ ERROR: `assume` argument was false
8+
std::intrinsics::assume(x > 42); //~ ERROR constant evaluation error [E0080]
9+
//~^ NOTE `assume` argument was false
910
}
1011
}

tests/compile-fail/bitop-beyond-alignment.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ fn mk_rec() -> Rec {
2828
fn is_u64_aligned(u: &Tag<u64>) -> bool {
2929
let p: usize = unsafe { mem::transmute(u) };
3030
let u64_align = std::mem::align_of::<u64>();
31-
return (p & (u64_align + 1)) == 0; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
31+
return (p & (u64_align + 1)) == 0; //~ ERROR constant evaluation error [E0080]
32+
//~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes
3233
}
3334

3435
pub fn main() {
3536
let x = mk_rec();
36-
assert!(is_u64_aligned(&x.t));
37+
assert!(is_u64_aligned(&x.t)); //~ NOTE inside call to `is_u64_aligned
3738
}

tests/compile-fail/cast_box_int_to_fn_ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ fn main() {
77
std::mem::transmute::<&usize, &fn(i32)>(&b)
88
};
99

10-
(*g)(42) //~ ERROR a memory access tried to interpret some bytes as a pointer
10+
(*g)(42) //~ ERROR constant evaluation error [E0080]
11+
//~^ NOTE a memory access tried to interpret some bytes as a pointer
1112
}

tests/compile-fail/cast_fn_ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ fn main() {
55
std::mem::transmute::<fn(), fn(i32)>(f)
66
};
77

8-
g(42) //~ ERROR tried to call a function with sig fn() through a function pointer of type fn(i32)
8+
g(42) //~ ERROR constant evaluation error [E0080]
9+
//~^ NOTE tried to call a function with sig fn() through a function pointer of type fn(i32)
910
}

tests/compile-fail/cast_fn_ptr2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ fn main() {
55
std::mem::transmute::<fn((i32,i32)), fn(i32)>(f)
66
};
77

8-
g(42) //~ ERROR tried to call a function with sig fn((i32, i32)) through a function pointer of type fn(i32)
8+
g(42) //~ ERROR constant evaluation error [E0080]
9+
//~^ NOTE tried to call a function with sig fn((i32, i32)) through a function pointer of type fn(i32)
910
}

tests/compile-fail/cast_int_to_fn_ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ fn main() {
66
std::mem::transmute::<usize, fn(i32)>(42)
77
};
88

9-
g(42) //~ ERROR a memory access tried to interpret some bytes as a pointer
9+
g(42) //~ ERROR constant evaluation error [E0080]
10+
//~^ NOTE a memory access tried to interpret some bytes as a pointer
1011
}

tests/compile-fail/ctlz_nonzero.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub fn main() {
1010
unsafe {
1111
use rusti::*;
1212

13-
ctlz_nonzero(0u8); //~ ERROR: ctlz_nonzero called on 0
13+
ctlz_nonzero(0u8); //~ ERROR constant evaluation error [E0080]
14+
//~^ NOTE ctlz_nonzero called on 0
1415
}
1516
}

tests/compile-fail/cttz_nonzero.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub fn main() {
1010
unsafe {
1111
use rusti::*;
1212

13-
cttz_nonzero(0u8); //~ ERROR: cttz_nonzero called on 0
13+
cttz_nonzero(0u8); //~ ERROR constant evaluation error [E0080]
14+
//~^ NOTE cttz_nonzero called on 0
1415
}
1516
}

tests/compile-fail/dangling_pointer_deref.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ fn main() {
33
let b = Box::new(42);
44
&*b as *const i32
55
};
6-
let x = unsafe { *p }; //~ ERROR: dangling pointer was dereferenced
6+
let x = unsafe { *p }; //~ ERROR constant evaluation error [E0080]
7+
//~^ NOTE dangling pointer was dereferenced
78
panic!("this should never print: {}", x);
89
}

tests/compile-fail/deref_fn_ptr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ fn f() {}
22

33
fn main() {
44
let x: i32 = unsafe {
5-
*std::mem::transmute::<fn(), *const i32>(f) //~ ERROR: tried to dereference a function pointer
5+
*std::mem::transmute::<fn(), *const i32>(f) //~ ERROR constant evaluation error [E0080]
6+
//~^ NOTE tried to dereference a function pointer
67
};
78
panic!("this should never print: {}", x);
89
}

tests/compile-fail/div-by-zero-2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
#![allow(const_err)]
1212

1313
fn main() {
14-
let _n = 1 / 0; //~ ERROR: DivisionByZero
14+
let _n = 1 / 0; //~ ERROR constant evaluation error [E0080]
15+
//~^ NOTE attempt to divide by zero
1516
}

tests/compile-fail/execute_memory.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ fn main() {
77
let x = box 42;
88
unsafe {
99
let f = std::mem::transmute::<Box<i32>, fn()>(x);
10-
f() //~ ERROR: tried to treat a memory pointer as a function pointer
10+
f() //~ ERROR constant evaluation error [E0080]
11+
//~^ NOTE tried to treat a memory pointer as a function pointer
1112
}
1213
}

tests/compile-fail/fn_ptr_offset.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ fn main() {
1010
let y : *mut u8 = unsafe { mem::transmute(x) };
1111
let y = y.wrapping_offset(1);
1212
let x : fn() = unsafe { mem::transmute(y) };
13-
x(); //~ ERROR: tried to use a function pointer after offsetting it
13+
x(); //~ ERROR constant evaluation error [E0080]
14+
//~^ NOTE tried to use a function pointer after offsetting it
1415
}

tests/compile-fail/invalid_bool.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
fn main() {
2-
let b = unsafe { std::mem::transmute::<u8, bool>(2) }; //~ ERROR: invalid boolean value read
3-
if b { unreachable!() } else { unreachable!() }
2+
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
3+
if b { unreachable!() } else { unreachable!() } //~ ERROR constant evaluation error [E0080]
4+
//~^ NOTE invalid boolean value read
45
}

tests/compile-fail/invalid_enum_discriminant.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ pub enum Foo {
99
fn main() {
1010
let f = unsafe { std::mem::transmute::<i32, Foo>(42) };
1111
match f {
12-
Foo::A => {}, //~ ERROR invalid enum discriminant value read
12+
Foo::A => {},
1313
Foo::B => {},
1414
Foo::C => {},
1515
Foo::D => {},
1616
}
17-
}
17+
} //~ ERROR constant evaluation error [E0080]
18+
//~^ NOTE entered unreachable code
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
fn main() {
22
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
33
let y = unsafe { &mut *(x as *const i32 as *mut i32) };
4-
*y = 42; //~ ERROR tried to modify constant memory
4+
*y = 42; //~ ERROR constant evaluation error [E0080]
5+
//~^ NOTE tried to modify constant memory
56
assert_eq!(*x, 42);
67
}

tests/compile-fail/never_say_never.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
fn main() {
88
let y = &5;
99
let x: ! = unsafe {
10-
*(y as *const _ as *const !) //~ ERROR entered unreachable code
10+
*(y as *const _ as *const !) //~ ERROR constant evaluation error [E0080]
11+
//~^ NOTE entered unreachable code
1112
};
1213
f(x)
1314
}

tests/compile-fail/never_transmute_humans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// This should fail even without validation
2-
// compile-fail causes rustc ICE: rust-lang/rust#50570
2+
// ignore-test causes rustc ICE: rust-lang/rust#50570
33
// compile-flags: -Zmir-emit-validate=0
44

55
#![feature(never_type)]

tests/compile-fail/never_transmute_void.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
enum Void {}
99

1010
fn f(v: Void) -> ! {
11-
match v {} //~ ERROR entered unreachable code
11+
match v {} //~ ERROR constant evaluation error [E0080]
12+
//~^ NOTE entered unreachable code
1213
}
1314

1415
fn main() {
1516
let v: Void = unsafe {
1617
std::mem::transmute::<(), Void>(())
1718
};
18-
f(v);
19+
f(v); //~ inside call to `f`
1920
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
fn main() {
2-
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR: invalid use of NULL pointer
2+
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR constant evaluation error [E0080]
3+
//~^ NOTE invalid use of NULL pointer
34
panic!("this should never print: {}", x);
45
}

tests/compile-fail/oom.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fn main() {
22
let v: Vec<u8> = vec![1, 2];
3-
let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR: which has size 2
3+
let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR constant evaluation error [E0080]
4+
//~^ NOTE which has size 2
45
panic!("this should never print: {}", x);
56
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fn main() {
22
let v: Vec<u8> = vec![1, 2];
3-
let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR: memory access at offset 6, outside bounds of allocation
3+
let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR constant evaluation error [E0080]
4+
//~^ NOTE memory access at offset 6, outside bounds of allocation
45
panic!("this should never print: {}", x);
56
}

tests/compile-fail/overflowing-lsh-neg.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
#![allow(const_err)]
1313

1414
fn main() {
15-
let _n = 2i64 << -1; //~ Overflow(Shl)
15+
let _n = 2i64 << -1; //~ ERROR constant evaluation error [E0080]
16+
//~^ NOTE attempt to shift left with overflow
1617
}

tests/compile-fail/overflowing-rsh.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
#![allow(exceeding_bitshifts)]
1212

1313
fn main() {
14-
let _n = 1i64 >> 64; //~ Overflow(Shr)
14+
let _n = 1i64 >> 64; //~ ERROR constant evaluation error [E0080]
15+
//~^ NOTE attempt to shift right with overflow
1516
}

tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn main() {
66
// "attempted to interpret some raw bytes as a pointer address" instead of
77
// "attempted to read undefined bytes"
88
}
9-
let x = *p; //~ ERROR: attempted to read undefined bytes
9+
let x = *p; //~ ERROR constant evaluation error [E0080]
10+
//~^ NOTE attempted to read undefined bytes
1011
panic!("this should never print: {}", x);
1112
}

tests/compile-fail/pointer_byte_read_1.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ fn main() {
33
let y = &x;
44
let z = &y as *const &i32 as *const usize;
55
let ptr_bytes = unsafe { *z }; // the actual deref is fine, because we read the entire pointer at once
6-
let _ = ptr_bytes % 432; //~ ERROR: tried to access part of a pointer value as raw bytes
6+
let _ = ptr_bytes % 432; //~ ERROR constant evaluation error [E0080]
7+
//~^ NOTE tried to access part of a pointer value as raw bytes
78
}

tests/compile-fail/pointer_byte_read_2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ fn main() {
33
let y = &x;
44
let z = &y as *const &i32 as *const u8;
55
// the deref fails, because we are reading only a part of the pointer
6-
let _ = unsafe { *z }; //~ ERROR: tried to access part of a pointer value as raw bytes
6+
let _ = unsafe { *z }; //~ ERROR constant evaluation error [E0080]
7+
//~^ NOTE tried to access part of a pointer value as raw bytes
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
fn main() {
22
let x: *const u8 = &1;
33
let y: *const u8 = &2;
4-
if x < y { //~ ERROR: attempted to do invalid arithmetic on pointers
4+
if x < y { //~ ERROR constant evaluation error [E0080]
5+
//~^ NOTE attempted to do invalid arithmetic on pointers
56
unreachable!()
67
}
78
}

tests/compile-fail/ptr_bitops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ fn main() {
22
let bytes = [0i8, 1, 2, 3, 4, 5, 6, 7, 8, 9];
33
let one = bytes.as_ptr().wrapping_offset(1);
44
let three = bytes.as_ptr().wrapping_offset(3);
5-
let res = (one as usize) | (three as usize); //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
5+
let res = (one as usize) | (three as usize); //~ ERROR constant evaluation error [E0080]
6+
//~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes
67
println!("{}", res);
78
}

tests/compile-fail/ptr_int_cast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ fn main() {
22
let x = &1;
33
// Casting down to u8 and back up to a pointer loses too much precision; this must not work.
44
let x = x as *const i32;
5-
let x = x as u8; //~ ERROR: a raw memory access tried to access part of a pointer value as raw bytes
5+
let x = x as u8; //~ ERROR constant evaluation error [E0080]
6+
//~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes
67
let x = x as *const i32;
78
let _ = unsafe { *x };
89
}

tests/compile-fail/reading_half_a_pointer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn main() {
2424
// starts 1 byte to the right, so using it would actually be wrong!
2525
let d_alias = &mut w.data as *mut _ as *mut *const u8;
2626
unsafe {
27-
let _x = *d_alias; //~ ERROR: tried to access part of a pointer value as raw bytes
27+
let _x = *d_alias; //~ ERROR constant evaluation error [E0080]
28+
//~^ NOTE tried to access part of a pointer value as raw bytes
2829
}
2930
}

tests/compile-fail/reallocate-change-alloc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn main() {
99
unsafe {
1010
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
1111
let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
12-
let _z = *(x as *mut u8); //~ ERROR: dangling pointer was dereferenced
12+
let _z = *(x as *mut u8); //~ ERROR constant evaluation error [E0080]
13+
//~^ NOTE dangling pointer was dereferenced
1314
}
1415
}

tests/compile-fail/reference_to_packed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ fn main() {
1515
y: 99,
1616
};
1717
let p = unsafe { &foo.x };
18-
let i = *p; //~ ERROR tried to access memory with alignment 1, but alignment 4 is required
18+
let i = *p; //~ ERROR constant evaluation error [E0080]
19+
//~^ NOTE tried to access memory with alignment 1, but alignment 4 is required
1920
}

tests/compile-fail/static_memory_modification2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::mem::transmute;
77
fn main() {
88
unsafe {
99
let s = "this is a test";
10-
transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR: tried to modify constant memory
10+
transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR constant evaluation error [E0080]
11+
//~^ NOTE tried to modify constant memory
1112
}
1213
}

tests/compile-fail/static_memory_modification3.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::mem::transmute;
44
fn main() {
55
unsafe {
66
let bs = b"this is a test";
7-
transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR: tried to modify constant memory
7+
transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR constant evaluation error [E0080]
8+
//~^ NOTE tried to modify constant memory
89
}
910
}

tests/compile-fail/transmute-pair-undef.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ fn main() {
1616
assert_eq!(byte, 0);
1717
}
1818
let v = unsafe { *z.offset(first_undef) };
19-
if v == 0 {} //~ ERROR attempted to read undefined bytes
19+
if v == 0 {} //~ ERROR constant evaluation error [E0080]
20+
//~^ NOTE attempted to read undefined bytes
2021
}

tests/compile-fail/transmute_fat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ fn main() {
1010
let bad = unsafe {
1111
std::mem::transmute::<&[u8], u64>(&[1u8])
1212
};
13-
let _ = bad + 1; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
13+
let _ = bad + 1; //~ ERROR constant evaluation error [E0080]
14+
//~^ NOTE a raw memory access tried to access part of a pointer value as raw bytes
1415
}

tests/compile-fail/transmute_fat2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ fn main() {
77
let bad = unsafe {
88
std::mem::transmute::<u64, &[u8]>(42)
99
};
10-
bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0
10+
bad[0]; //~ ERROR constant evaluation error [E0080]
11+
//~^ NOTE index out of bounds: the len is 0 but the index is 0
1112
}

tests/compile-fail/unaligned_ptr_cast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ fn main() {
22
let x = &2u16;
33
let x = x as *const _ as *const u32;
44
// This must fail because alignment is violated
5-
let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment 4 is required
5+
let _x = unsafe { *x }; //~ ERROR constant evaluation error [E0080]
6+
//~^ NOTE tried to access memory with alignment 2, but alignment 4 is required
67
}

tests/compile-fail/unaligned_ptr_cast2.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ fn main() {
33
let x = x as *const _ as *const *const u8;
44
// This must fail because alignment is violated. Test specifically for loading pointers, which have special code
55
// in miri's memory.
6-
let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment
6+
let _x = unsafe { *x }; //~ ERROR constant evaluation error [E0080]
7+
//~^ NOTE tried to access memory with alignment 2, but alignment
78
}

tests/compile-fail/unaligned_ptr_cast_zst.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ fn main() {
22
let x = &2u16;
33
let x = x as *const _ as *const [u32; 0];
44
// This must fail because alignment is violated. Test specifically for loading ZST.
5-
let _x = unsafe { *x }; //~ ERROR: tried to access memory with alignment 2, but alignment 4 is required
5+
let _x = unsafe { *x }; //~ ERROR constant evaluation error [E0080]
6+
//~^ NOTE tried to access memory with alignment 2, but alignment 4 is required
67
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fn main() {
22
let p = 44 as *const i32;
3-
let x = unsafe { *p }; //~ ERROR: a memory access tried to interpret some bytes as a pointer
3+
let x = unsafe { *p }; //~ ERROR constant evaluation error [E0080]
4+
//~^ NOTE a memory access tried to interpret some bytes as a pointer
45
panic!("this should never print: {}", x);
56
}

tests/compile-fail/zst.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
fn main() {
22
let x = &() as *const () as *const i32;
3-
let _ = unsafe { *x }; //~ ERROR: tried to access memory with alignment 1, but alignment 4 is required
3+
let _ = unsafe { *x }; //~ ERROR constant evaluation error [E0080]
4+
//~^ NOTE tried to access memory with alignment 1, but alignment 4 is required
45
}

0 commit comments

Comments
 (0)