Skip to content

Commit 906b75e

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

16 files changed

+35
-19
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

0 commit comments

Comments
 (0)