summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-eval
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /tests/ui/consts/const-eval
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/consts/const-eval')
-rw-r--r--tests/ui/consts/const-eval/const-eval-overflow-3b.stderr4
-rw-r--r--tests/ui/consts/const-eval/const-eval-overflow-4b.stderr4
-rw-r--r--tests/ui/consts/const-eval/const_raw_ptr_ops.rs4
-rw-r--r--tests/ui/consts/const-eval/const_raw_ptr_ops.stderr27
-rw-r--r--tests/ui/consts/const-eval/format.stderr56
-rw-r--r--tests/ui/consts/const-eval/generic-slice.stderr4
-rw-r--r--tests/ui/consts/const-eval/issue-100878.rs2
-rw-r--r--tests/ui/consts/const-eval/raw-bytes.32bit.stderr4
-rw-r--r--tests/ui/consts/const-eval/raw-bytes.64bit.stderr4
-rw-r--r--tests/ui/consts/const-eval/ub-ref-ptr.rs1
-rw-r--r--tests/ui/consts/const-eval/ub-ref-ptr.stderr34
-rw-r--r--tests/ui/consts/const-eval/ub-slice-get-unchecked.rs2
-rw-r--r--tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr19
13 files changed, 49 insertions, 116 deletions
diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr
index f19917001..05f33c339 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr
@@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | = [0; (i8::MAX + 1u8) as usize];
| ^^^ expected `i8`, found `u8`
-error[E0277]: cannot add `u8` to `i8` in const contexts
+error[E0277]: cannot add `u8` to `i8`
--> $DIR/const-eval-overflow-3b.rs:16:20
|
LL | = [0; (i8::MAX + 1u8) as usize];
| ^ no implementation for `i8 + u8`
|
- = help: the trait `~const Add<u8>` is not implemented for `i8`
+ = help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr
index 1f8e40231..d019f5920 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr
@@ -4,13 +4,13 @@ error[E0308]: mismatched types
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^^^ expected `i8`, found `u8`
-error[E0277]: cannot add `u8` to `i8` in const contexts
+error[E0277]: cannot add `u8` to `i8`
--> $DIR/const-eval-overflow-4b.rs:9:28
|
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^ no implementation for `i8 + u8`
|
- = help: the trait `~const Add<u8>` is not implemented for `i8`
+ = help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops.rs b/tests/ui/consts/const-eval/const_raw_ptr_ops.rs
index cd7c98007..432a05756 100644
--- a/tests/ui/consts/const-eval/const_raw_ptr_ops.rs
+++ b/tests/ui/consts/const-eval/const_raw_ptr_ops.rs
@@ -1,6 +1,6 @@
fn main() {}
// unconst and bad, will thus error in miri
-const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR can't compare
+const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; //~ ERROR pointers cannot
// unconst and bad, will thus error in miri
-const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR can't compare
+const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 }; //~ ERROR pointers cannot
diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr
index 12244450e..1f5bca273 100644
--- a/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr
+++ b/tests/ui/consts/const-eval/const_raw_ptr_ops.stderr
@@ -1,29 +1,18 @@
-error[E0277]: can't compare `*const i32` with `_` in const contexts
- --> $DIR/const_raw_ptr_ops.rs:4:43
+error: pointers cannot be reliably compared during const eval
+ --> $DIR/const_raw_ptr_ops.rs:4:26
|
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
- | ^^ no implementation for `*const i32 == _`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: the trait `~const PartialEq<_>` is not implemented for `*const i32`
-note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
- --> $DIR/const_raw_ptr_ops.rs:4:43
- |
-LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
- | ^^
+ = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
-error[E0277]: can't compare `*const i32` with `_` in const contexts
- --> $DIR/const_raw_ptr_ops.rs:6:44
+error: pointers cannot be reliably compared during const eval
+ --> $DIR/const_raw_ptr_ops.rs:6:27
|
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
- | ^^ no implementation for `*const i32 == _`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = help: the trait `~const PartialEq<_>` is not implemented for `*const i32`
-note: the trait `PartialEq<_>` is implemented for `*const i32`, but that implementation is not `const`
- --> $DIR/const_raw_ptr_ops.rs:6:44
- |
-LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
- | ^^
+ = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
error: aborting due to 2 previous errors
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr
index 70a1abb0a..434b07443 100644
--- a/tests/ui/consts/const-eval/format.stderr
+++ b/tests/ui/consts/const-eval/format.stderr
@@ -43,62 +43,6 @@ LL | println!("{:?}", 0);
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
-note: erroneous constant used
- --> $DIR/format.rs:2:12
- |
-LL | panic!("{:?}", 0);
- | ^^^^^^
-
-note: erroneous constant used
- --> $DIR/format.rs:2:12
- |
-LL | panic!("{:?}", 0);
- | ^^^^^^
-
-note: erroneous constant used
- --> $DIR/format.rs:2:20
- |
-LL | panic!("{:?}", 0);
- | ^
- |
- = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-note: erroneous constant used
- --> $DIR/format.rs:2:20
- |
-LL | panic!("{:?}", 0);
- | ^
- |
- = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-note: erroneous constant used
- --> $DIR/format.rs:8:14
- |
-LL | println!("{:?}", 0);
- | ^^^^^^
-
-note: erroneous constant used
- --> $DIR/format.rs:8:14
- |
-LL | println!("{:?}", 0);
- | ^^^^^^
-
-note: erroneous constant used
- --> $DIR/format.rs:8:22
- |
-LL | println!("{:?}", 0);
- | ^
- |
- = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-note: erroneous constant used
- --> $DIR/format.rs:8:22
- |
-LL | println!("{:?}", 0);
- | ^
- |
- = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
-
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0015`.
diff --git a/tests/ui/consts/const-eval/generic-slice.stderr b/tests/ui/consts/const-eval/generic-slice.stderr
index c38088df4..ff1dc29cc 100644
--- a/tests/ui/consts/const-eval/generic-slice.stderr
+++ b/tests/ui/consts/const-eval/generic-slice.stderr
@@ -4,6 +4,8 @@ error[E0597]: `x` does not live long enough
LL | impl<'a, T: 'static> Generic<'a, T> {
| -- lifetime `'a` defined here
...
+LL | let x: &'static [T] = &[];
+ | - binding `x` declared here
LL | &x
| ^^
| |
@@ -16,6 +18,8 @@ LL | };
error[E0597]: `x` does not live long enough
--> $DIR/generic-slice.rs:27:5
|
+LL | let x: &[_] = &[];
+ | - binding `x` declared here
LL | &x
| ^^
| |
diff --git a/tests/ui/consts/const-eval/issue-100878.rs b/tests/ui/consts/const-eval/issue-100878.rs
index 353ce5050..bd56f854c 100644
--- a/tests/ui/consts/const-eval/issue-100878.rs
+++ b/tests/ui/consts/const-eval/issue-100878.rs
@@ -1,6 +1,8 @@
// This checks that the const-eval ICE in issue #100878 does not recur.
//
// build-pass
+
+#[allow(arithmetic_overflow)]
pub fn bitshift_data(data: [u8; 1]) -> u8 {
data[0] << 8
}
diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr
index a0f8dd097..a93b561e5 100644
--- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr
+++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr
@@ -465,7 +465,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
- 00 10 00 00 00 00 00 00 │ ........
+ 00 00 00 00 00 10 00 00 │ ........
}
error[E0080]: it is undefined behavior to use this value
@@ -476,7 +476,7 @@ LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unche
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 4) {
- 09 00 00 00 03 00 00 00 │ ........
+ 03 00 00 00 09 00 00 00 │ ........
}
error[E0080]: it is undefined behavior to use this value
diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr
index 9706f3ec2..a32d4863a 100644
--- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr
+++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr
@@ -465,7 +465,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 16, align: 8) {
- 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................
+ 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 │ ................
}
error[E0080]: it is undefined behavior to use this value
@@ -476,7 +476,7 @@ LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unche
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 16, align: 8) {
- 09 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 │ ................
+ 03 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 │ ................
}
error[E0080]: it is undefined behavior to use this value
diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs
index 369e45194..a5d2ea014 100644
--- a/tests/ui/consts/const-eval/ub-ref-ptr.rs
+++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs
@@ -3,7 +3,6 @@
// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP"
#![allow(invalid_value)]
-#![feature(const_ptr_read)]
use std::mem;
diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr
index 080568b51..1d19dfff5 100644
--- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr
+++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr
@@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:16:1
+ --> $DIR/ub-ref-ptr.rs:15:1
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
@@ -10,7 +10,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:20:1
+ --> $DIR/ub-ref-ptr.rs:19:1
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
@@ -21,7 +21,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:24:1
+ --> $DIR/ub-ref-ptr.rs:23:1
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:27:1
+ --> $DIR/ub-ref-ptr.rs:26:1
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
@@ -43,7 +43,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
- --> $DIR/ub-ref-ptr.rs:34:1
+ --> $DIR/ub-ref-ptr.rs:33:1
|
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
@@ -52,7 +52,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
- --> $DIR/ub-ref-ptr.rs:37:39
+ --> $DIR/ub-ref-ptr.rs:36:39
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
@@ -61,13 +61,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
note: erroneous constant used
- --> $DIR/ub-ref-ptr.rs:37:38
+ --> $DIR/ub-ref-ptr.rs:36:38
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: evaluation of constant value failed
- --> $DIR/ub-ref-ptr.rs:40:86
+ --> $DIR/ub-ref-ptr.rs:39:86
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
@@ -76,13 +76,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
note: erroneous constant used
- --> $DIR/ub-ref-ptr.rs:40:85
+ --> $DIR/ub-ref-ptr.rs:39:85
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
| ^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:43:1
+ --> $DIR/ub-ref-ptr.rs:42:1
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
@@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:46:1
+ --> $DIR/ub-ref-ptr.rs:45:1
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
@@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
}
error[E0080]: evaluation of constant value failed
- --> $DIR/ub-ref-ptr.rs:49:41
+ --> $DIR/ub-ref-ptr.rs:48:41
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:53:1
+ --> $DIR/ub-ref-ptr.rs:52:1
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
@@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
- --> $DIR/ub-ref-ptr.rs:55:38
+ --> $DIR/ub-ref-ptr.rs:54:38
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:58:1
+ --> $DIR/ub-ref-ptr.rs:57:1
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
@@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
}
error[E0080]: it is undefined behavior to use this value
- --> $DIR/ub-ref-ptr.rs:60:1
+ --> $DIR/ub-ref-ptr.rs:59:1
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered alloc41, but expected a function pointer
@@ -158,7 +158,7 @@ note: inside `std::ptr::read::<u32>`
note: inside `ptr::const_ptr::<impl *const u32>::read`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
note: inside `UNALIGNED_READ`
- --> $DIR/ub-ref-ptr.rs:67:5
+ --> $DIR/ub-ref-ptr.rs:66:5
|
LL | ptr.read();
| ^^^^^^^^^^
diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
index d9a74b4f3..ebc5543b3 100644
--- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
+++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs
@@ -1,3 +1,5 @@
+// known-bug: #110395
+
#![feature(const_slice_index)]
const A: [(); 5] = [(), (), (), (), ()];
diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr
index 775e475df..403fb5e09 100644
--- a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr
+++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr
@@ -1,18 +1,11 @@
-error[E0080]: evaluation of constant value failed
- --> $SRC_DIR/core/src/slice/index.rs:LL:COL
- |
- = note: overflow executing `unchecked_sub`
- |
-note: inside `<std::ops::Range<usize> as SliceIndex<[()]>>::get_unchecked`
- --> $SRC_DIR/core/src/slice/index.rs:LL:COL
-note: inside `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>`
- --> $SRC_DIR/core/src/slice/mod.rs:LL:COL
-note: inside `B`
- --> $DIR/ub-slice-get-unchecked.rs:7:27
+error[E0015]: cannot call non-const fn `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` in constants
+ --> $DIR/ub-slice-get-unchecked.rs:9:29
|
LL | const B: &[()] = unsafe { A.get_unchecked(3..1) };
- | ^^^^^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
+For more information about this error, try `rustc --explain E0015`.