Skip to content

Commit a2d258e

Browse files
authored
Rollup merge of #141698 - oli-obk:ctfe-err-flip, r=RalfJung
Use the informative error as the main const eval error message r? `@RalfJung` I only did the minimal changes necessary to the const eval error machinery. I'd prefer not to mix test changes with refactorings 😆
2 parents 00f24f5 + 0029823 commit a2d258e

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

tests/fail/const-ub-checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const UNALIGNED_READ: () = unsafe {
22
let x = &[0u8; 4];
33
let ptr = x.as_ptr().cast::<u32>();
4-
ptr.read(); //~ERROR: evaluation of constant value failed
4+
ptr.read(); //~ERROR: accessing memory based on pointer with alignment 1, but alignment 4 is required
55
};
66

77
fn main() {

tests/fail/const-ub-checks.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0080]: evaluation of constant value failed
1+
error[E0080]: accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required
22
--> tests/fail/const-ub-checks.rs:LL:CC
33
|
44
LL | ptr.read();
5-
| ^^^^^^^^^^ accessing memory based on pointer with alignment ALIGN, but alignment ALIGN is required
5+
| ^^^^^^^^^^ evaluation of constant value failed here
66

77
note: erroneous constant encountered
88
--> tests/fail/const-ub-checks.rs:LL:CC

tests/fail/erroneous_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
struct PrintName<T>(T);
66
impl<T> PrintName<T> {
7-
const VOID: ! = panic!(); //~ERROR: evaluation of `PrintName::<i32>::VOID` failed
7+
const VOID: ! = panic!(); //~ERROR: explicit panic
88
}
99

1010
fn no_codegen<T>() {

tests/fail/erroneous_const.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0080]: evaluation of `PrintName::<i32>::VOID` failed
1+
error[E0080]: evaluation panicked: explicit panic
22
--> tests/fail/erroneous_const.rs:LL:CC
33
|
44
LL | const VOID: ! = panic!();
5-
| ^^^^^^^^ evaluation panicked: explicit panic
5+
| ^^^^^^^^ evaluation of `PrintName::<i32>::VOID` failed here
66

77
note: erroneous constant encountered
88
--> tests/fail/erroneous_const.rs:LL:CC

tests/fail/erroneous_const2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const X: u32 = 5;
22
const Y: u32 = 6;
33
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
4-
//~^ERROR: evaluation of constant value failed
4+
//~^ERROR: overflow
55

66
#[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391
77
fn main() {

tests/fail/erroneous_const2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
error[E0080]: evaluation of constant value failed
1+
error[E0080]: attempt to compute `5_u32 - 6_u32`, which would overflow
22
--> tests/fail/erroneous_const2.rs:LL:CC
33
|
44
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
5-
| ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow
5+
| ^^^^^ evaluation of constant value failed here
66

77
note: erroneous constant encountered
88
--> tests/fail/erroneous_const2.rs:LL:CC

0 commit comments

Comments
 (0)