Skip to content

Commit 5fa39d9

Browse files
committed
Clarify why we are talking about a failed const eval at a random place
1 parent 8ec0bd2 commit 5fa39d9

File tree

214 files changed

+969
-969
lines changed

Some content is hidden

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

214 files changed

+969
-969
lines changed

compiler/rustc_const_eval/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ const_eval_dyn_call_not_a_method =
8989
`dyn` call trying to call something that is not a method
9090
9191
const_eval_error = {$error_kind ->
92-
[static] could not evaluate static initializer
93-
[const] evaluation of constant value failed
94-
[const_with_path] evaluation of `{$instance}` failed
92+
[static] evaluation of static initializer failed here
93+
[const] evaluation of constant value failed here
94+
[const_with_path] evaluation of `{$instance}` failed here
9595
*[other] {""}
9696
}
9797

tests/ui/array-slice-vec/array_const_index-0.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: index out of bounds: the length is 0 but the index is 1
22
--> $DIR/array_const_index-0.rs:2:16
33
|
44
LL | const B: i32 = (&A)[1];
5-
| ^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^ evaluation of constant value failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/array-slice-vec/array_const_index-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: index out of bounds: the length is 0 but the index is 1
22
--> $DIR/array_const_index-1.rs:2:16
33
|
44
LL | const B: i32 = A[1];
5-
| ^^^^ evaluation of constant value failed
5+
| ^^^^ evaluation of constant value failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/asm/fail-const-eval-issue-121099.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0080]: attempt to shift left by `500_i32`, which would overflow
22
--> $DIR/fail-const-eval-issue-121099.rs:8:31
33
|
44
LL | global_asm!("/* {} */", const 1 << 500);
5-
| ^^^^^^^^ evaluation of `{global_asm#0}::{constant#0}` failed
5+
| ^^^^^^^^ evaluation of `{global_asm#0}::{constant#0}` failed here
66

77
error[E0080]: attempt to divide `1_i32` by zero
88
--> $DIR/fail-const-eval-issue-121099.rs:10:31
99
|
1010
LL | global_asm!("/* {} */", const 1 / 0);
11-
| ^^^^^ evaluation of `{global_asm#1}::{constant#0}` failed
11+
| ^^^^^ evaluation of `{global_asm#1}::{constant#0}` failed here
1212

1313
error: aborting due to 2 previous errors
1414

tests/ui/associated-consts/defaults-not-assumed-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
22
--> $DIR/defaults-not-assumed-fail.rs:9:19
33
|
44
LL | const B: u8 = Self::A + 1;
5-
| ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed
5+
| ^^^^^^^^^^^ evaluation of `<() as Tr>::B` failed here
66

77
note: erroneous constant encountered
88
--> $DIR/defaults-not-assumed-fail.rs:34:16

tests/ui/borrowck/issue-81899.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation panicked: explicit panic
22
--> $DIR/issue-81899.rs:6:24
33
|
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
5-
| ^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^ evaluation of constant value failed here
66
|
77
note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>`
88
--> $DIR/issue-81899.rs:13:5

tests/ui/borrowck/issue-88434-minimal-example.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation panicked: explicit panic
22
--> $DIR/issue-88434-minimal-example.rs:5:22
33
|
44
LL | const _CONST: &() = &f(&|_| {});
5-
| ^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^ evaluation of constant value failed here
66
|
77
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>`
88
--> $DIR/issue-88434-minimal-example.rs:12:5

tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation panicked: explicit panic
22
--> $DIR/issue-88434-removal-index-should-be-less.rs:5:24
33
|
44
LL | const _CONST: &[u8] = &f(&[], |_| {});
5-
| ^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^ evaluation of constant value failed here
66
|
77
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>`
88
--> $DIR/issue-88434-removal-index-should-be-less.rs:12:5

tests/ui/coherence/const-errs-dont-conflict-103369.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: evaluation panicked: Some error occurred
22
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
33
|
44
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
5-
| ^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^ evaluation of constant value failed here
66
|
77
note: inside `my_fn`
88
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
@@ -14,7 +14,7 @@ error[E0080]: evaluation panicked: Some error occurred
1414
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
1515
|
1616
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
17-
| ^^^^^^^^ evaluation of constant value failed
17+
| ^^^^^^^^ evaluation of constant value failed here
1818
|
1919
note: inside `my_fn`
2020
--> $DIR/const-errs-dont-conflict-103369.rs:10:5

tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
22
--> $DIR/default-param-wf-concrete.rs:4:28
33
|
44
LL | struct Foo<const N: u8 = { 255 + 1 }>;
5-
| ^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^ evaluation of constant value failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
22
--> $DIR/default-param-wf-concrete.rs:4:28
33
|
44
LL | struct Foo<const N: u8 = { 255 + 1 }>;
5-
| ^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^ evaluation of constant value failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/const-generics/defaults/wfness.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
22
--> $DIR/wfness.rs:1:33
33
|
44
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
5-
| ^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^ evaluation of constant value failed here
66

77
error[E0277]: the trait bound `(): Trait<2>` is not satisfied
88
--> $DIR/wfness.rs:8:9

tests/ui/const-generics/generic_const_exprs/from-sig-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
22
--> $DIR/from-sig-fail.rs:4:35
33
|
44
LL | fn test<const N: usize>() -> [u8; N - 1] {
5-
| ^^^^^ evaluation of `test::<0>::{constant#0}` failed
5+
| ^^^^^ evaluation of `test::<0>::{constant#0}` failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/const-generics/generic_const_exprs/simple_fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
22
--> $DIR/simple_fail.rs:9:10
33
|
44
LL | [u8; N - 1]: Sized,
5-
| ^^^^^ evaluation of `test::<0>::{constant#0}` failed
5+
| ^^^^^ evaluation of `test::<0>::{constant#0}` failed here
66

77
error[E0080]: attempt to compute `0_usize - 1_usize`, which would overflow
88
--> $DIR/simple_fail.rs:4:33
99
|
1010
LL | type Arr<const N: usize> = [u8; N - 1];
11-
| ^^^^^ evaluation of `Arr::<0>::{constant#0}` failed
11+
| ^^^^^ evaluation of `Arr::<0>::{constant#0}` failed here
1212

1313
error: aborting due to 2 previous errors
1414

tests/ui/const-generics/issues/issue-100313.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: writing to ALLOC0 which is read-only
22
--> $DIR/issue-100313.rs:18:5
33
|
44
LL | x.set_false();
5-
| ^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^ evaluation of constant value failed here
66
|
77
note: inside `T::<&true>::set_false`
88
--> $DIR/issue-100313.rs:11:13

tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: using uninitialized data, but this operation requires initialized
22
--> $DIR/invalid-patterns.rs:40:32
33
|
44
LL | get_flag::<false, { unsafe { char_raw.character } }>();
5-
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
66

77
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
88
--> $DIR/invalid-patterns.rs:42:14
@@ -30,7 +30,7 @@ error[E0080]: using uninitialized data, but this operation requires initialized
3030
--> $DIR/invalid-patterns.rs:44:58
3131
|
3232
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
33-
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
33+
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
3434

3535
error[E0308]: mismatched types
3636
--> $DIR/invalid-patterns.rs:31:21

tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: using uninitialized data, but this operation requires initialized
22
--> $DIR/invalid-patterns.rs:40:32
33
|
44
LL | get_flag::<false, { unsafe { char_raw.character } }>();
5-
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
66

77
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
88
--> $DIR/invalid-patterns.rs:42:14
@@ -30,7 +30,7 @@ error[E0080]: using uninitialized data, but this operation requires initialized
3030
--> $DIR/invalid-patterns.rs:44:58
3131
|
3232
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
33-
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
33+
| ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
3434

3535
error[E0308]: mismatched types
3636
--> $DIR/invalid-patterns.rs:31:21

tests/ui/const-ptr/forbidden_slices.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee
103103
--> $DIR/forbidden_slices.rs:50:33
104104
|
105105
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
106-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
106+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
107107

108108
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
109109
--> $DIR/forbidden_slices.rs:54:25
110110
|
111111
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
112-
| ^^^^^^^^^^ could not evaluate static initializer
112+
| ^^^^^^^^^^ evaluation of static initializer failed here
113113

114114
error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
115115
--> $DIR/forbidden_slices.rs:57:1
@@ -161,19 +161,19 @@ error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer
161161
--> $DIR/forbidden_slices.rs:79:25
162162
|
163163
LL | from_ptr_range(ptr..ptr.add(1))
164-
| ^^^^^^^^^^ could not evaluate static initializer
164+
| ^^^^^^^^^^ evaluation of static initializer failed here
165165

166166
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
167167
--> $DIR/forbidden_slices.rs:85:34
168168
|
169169
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
170-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
170+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
171171

172172
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
173173
--> $DIR/forbidden_slices.rs:87:35
174174
|
175175
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
176-
| ^^^^^^^^^^^^^^^^^^^^^^^^ could not evaluate static initializer
176+
| ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
177177

178178
error: aborting due to 18 previous errors
179179

tests/ui/const-ptr/out_of_bounds_read.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0
22
--> $DIR/out_of_bounds_read.rs:8:33
33
|
44
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
66

77
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
88
--> $DIR/out_of_bounds_read.rs:10:39
99
|
1010
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
11-
| ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
11+
| ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
1212

1313
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
1414
--> $DIR/out_of_bounds_read.rs:12:37
1515
|
1616
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
1818

1919
error: aborting due to 3 previous errors
2020

tests/ui/consts/assert-type-intrinsics.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ error[E0080]: evaluation panicked: aborted execution: attempted to instantiate u
22
--> $DIR/assert-type-intrinsics.rs:11:9
33
|
44
LL | MaybeUninit::<!>::uninit().assume_init();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
66

77
error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid
88
--> $DIR/assert-type-intrinsics.rs:15:9
99
|
1010
LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>();
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
1212

1313
error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid
1414
--> $DIR/assert-type-intrinsics.rs:19:9
1515
|
1616
LL | intrinsics::assert_zero_valid::<&'static i32>();
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
1818

1919
error: aborting due to 3 previous errors
2020

tests/ui/consts/assoc_const_generic_impl.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: index out of bounds: the length is 1 but the index is 4
22
--> $DIR/assoc_const_generic_impl.rs:9:33
33
|
44
LL | const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()];
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed here
66

77
note: erroneous constant encountered
88
--> $DIR/assoc_const_generic_impl.rs:11:9

tests/ui/consts/const-array-oob.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0080]: index out of bounds: the length is 3 but the index is 4
22
--> $DIR/const-array-oob.rs:5:19
33
|
44
LL | const BLUB: [u32; FOO[4]] = [5, 6];
5-
| ^^^^^^ evaluation of constant value failed
5+
| ^^^^^^ evaluation of constant value failed here
66

77
error[E0080]: index out of bounds: the length is 3 but the index is 5
88
--> $DIR/const-array-oob.rs:2:20
99
|
1010
LL | const BAR: usize = FOO[5];
11-
| ^^^^^^ evaluation of constant value failed
11+
| ^^^^^^ evaluation of constant value failed here
1212

1313
error: aborting due to 2 previous errors
1414

tests/ui/consts/const-assert-unchecked-ub.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: `assume` called with `false`
22
--> $DIR/const-assert-unchecked-ub.rs:3:5
33
|
44
LL | std::hint::assert_unchecked(n < 32);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
66

77
error: aborting due to 1 previous error
88

tests/ui/consts/const-compare-bytes-ub.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@ error[E0080]: memory access failed: attempting to access 1 byte, but got null po
22
--> $DIR/const-compare-bytes-ub.rs:9:9
33
|
44
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
66

77
error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
88
--> $DIR/const-compare-bytes-ub.rs:13:9
99
|
1010
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
1212

1313
error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
1414
--> $DIR/const-compare-bytes-ub.rs:17:9
1515
|
1616
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
1818

1919
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation
2020
--> $DIR/const-compare-bytes-ub.rs:21:9
2121
|
2222
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
23-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
2424

2525
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation
2626
--> $DIR/const-compare-bytes-ub.rs:25:9
2727
|
2828
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
29-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
3030

3131
error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
3232
--> $DIR/const-compare-bytes-ub.rs:29:9
3333
|
3434
LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1)
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
3636

3737
error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
3838
--> $DIR/const-compare-bytes-ub.rs:33:9
3939
|
4040
LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1)
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
4242

4343
error[E0080]: unable to turn pointer into integer
4444
--> $DIR/const-compare-bytes-ub.rs:37:9
4545
|
4646
LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>())
47-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
4848
|
4949
= help: this code performed an operation that depends on the underlying bytes representing a pointer
5050
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported

0 commit comments

Comments
 (0)