summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /tests/ui/consts
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/consts')
-rw-r--r--tests/ui/consts/assoc_const_generic_impl.rs2
-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/erroneous-const.rs2
-rw-r--r--tests/ui/consts/const-eval/erroneous-const.stderr6
-rw-r--r--tests/ui/consts/const-eval/erroneous-const2.rs2
-rw-r--r--tests/ui/consts/const-eval/erroneous-const2.stderr6
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr2
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs4
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr4
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs4
-rw-r--r--tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr6
-rw-r--r--tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr2
-rw-r--r--tests/ui/consts/const-eval/infinite_loop.rs4
-rw-r--r--tests/ui/consts/const-eval/infinite_loop.stderr23
-rw-r--r--tests/ui/consts/const-eval/issue-52475.rs3
-rw-r--r--tests/ui/consts/const-eval/issue-52475.stderr22
-rw-r--r--tests/ui/consts/const-eval/issue-70723.rs2
-rw-r--r--tests/ui/consts/const-eval/issue-70723.stderr14
-rw-r--r--tests/ui/consts/const-eval/promoted_errors.rs2
-rw-r--r--tests/ui/consts/const-eval/raw-bytes.32bit.stderr14
-rw-r--r--tests/ui/consts/const-eval/raw-bytes.64bit.stderr14
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs2
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr19
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs5
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr27
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs3
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr24
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr19
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs12
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr24
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr62
-rw-r--r--tests/ui/consts/const-eval/ub-enum.32bit.stderr4
-rw-r--r--tests/ui/consts/const-eval/ub-enum.64bit.stderr4
-rw-r--r--tests/ui/consts/const-eval/ub-uninhabit.stderr4
-rw-r--r--tests/ui/consts/const-eval/unwind-abort.rs2
-rw-r--r--tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr2
-rw-r--r--tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr2
-rw-r--r--tests/ui/consts/const-len-underflow-separate-spans.next.stderr (renamed from tests/ui/consts/const-len-underflow-separate-spans.stderr)4
-rw-r--r--tests/ui/consts/const-len-underflow-separate-spans.old.stderr15
-rw-r--r--tests/ui/consts/const-len-underflow-separate-spans.rs3
-rw-r--r--tests/ui/consts/const_in_pattern/issue-73431.rs1
-rw-r--r--tests/ui/consts/const_limit/const_eval_limit_not_reached.rs20
-rw-r--r--tests/ui/consts/const_limit/const_eval_limit_overflow.rs15
-rw-r--r--tests/ui/consts/const_limit/const_eval_limit_overflow.stderr10
-rw-r--r--tests/ui/consts/const_limit/const_eval_limit_reached.rs16
-rw-r--r--tests/ui/consts/const_limit/const_eval_limit_reached.stderr12
-rw-r--r--tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs14
-rw-r--r--tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr12
-rw-r--r--tests/ui/consts/issue-16538.mir.stderr29
-rw-r--r--tests/ui/consts/issue-16538.rs19
-rw-r--r--tests/ui/consts/issue-16538.thir.stderr29
-rw-r--r--tests/ui/consts/issue-28822.rs7
-rw-r--r--tests/ui/consts/issue-29798.rs11
-rw-r--r--tests/ui/consts/issue-64506.stderr2
-rw-r--r--tests/ui/consts/issue-83182.stderr4
-rw-r--r--tests/ui/consts/issue-miri-1910.stderr4
-rw-r--r--tests/ui/consts/large_const_alloc.rs4
-rw-r--r--tests/ui/consts/miri_unleashed/assoc_const.stderr2
-rw-r--r--tests/ui/consts/miri_unleashed/raw_mutable_const.rs2
-rw-r--r--tests/ui/consts/miri_unleashed/raw_mutable_const.stderr4
-rw-r--r--tests/ui/consts/missing-larger-array-impl.rs9
-rw-r--r--tests/ui/consts/missing-larger-array-impl.stderr20
-rw-r--r--tests/ui/consts/missing_span_in_backtrace.stderr4
-rw-r--r--tests/ui/consts/offset_from_ub.stderr14
-rw-r--r--tests/ui/consts/raw-ptr-const.rs2
-rw-r--r--tests/ui/consts/raw-ptr-const.stderr4
-rw-r--r--tests/ui/consts/refs_check_const_eq-issue-88384.rs4
-rw-r--r--tests/ui/consts/refs_check_const_eq-issue-88384.stderr16
-rw-r--r--tests/ui/consts/timeout.rs25
-rw-r--r--tests/ui/consts/timeout.stderr15
-rw-r--r--tests/ui/consts/too_generic_eval_ice.stderr12
72 files changed, 459 insertions, 266 deletions
diff --git a/tests/ui/consts/assoc_const_generic_impl.rs b/tests/ui/consts/assoc_const_generic_impl.rs
index 3475c862b..ba358628d 100644
--- a/tests/ui/consts/assoc_const_generic_impl.rs
+++ b/tests/ui/consts/assoc_const_generic_impl.rs
@@ -8,7 +8,7 @@ trait ZeroSized: Sized {
impl<T: Sized> ZeroSized for T {
const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::<Self>()]; //~ ERROR evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
fn requires_zero_size(self) {
- let () = Self::I_AM_ZERO_SIZED;
+ Self::I_AM_ZERO_SIZED;
println!("requires_zero_size called");
}
}
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 05f33c339..06e398edc 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-3b.stderr
@@ -12,10 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize];
|
= help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
+ <i8 as Add>
+ <i8 as Add<&i8>>
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
- <i8 as Add<&i8>>
- <i8 as Add>
error: aborting due to 2 previous errors
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 d019f5920..07ef2ac09 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-4b.stderr
@@ -12,10 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
|
= help: the trait `Add<u8>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
+ <i8 as Add>
+ <i8 as Add<&i8>>
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
- <i8 as Add<&i8>>
- <i8 as Add>
error[E0604]: only `u8` can be cast as `char`, not `i8`
--> $DIR/const-eval-overflow-4b.rs:22:13
diff --git a/tests/ui/consts/const-eval/erroneous-const.rs b/tests/ui/consts/const-eval/erroneous-const.rs
index e0fd057a2..74d44c525 100644
--- a/tests/ui/consts/const-eval/erroneous-const.rs
+++ b/tests/ui/consts/const-eval/erroneous-const.rs
@@ -10,7 +10,7 @@ const fn no_codegen<T>() {
if false {
// This bad constant is only used in dead code in a no-codegen function... and yet we still
// must make sure that the build fails.
- let _ = PrintName::<T>::VOID; //~ constant
+ PrintName::<T>::VOID; //~ constant
}
}
diff --git a/tests/ui/consts/const-eval/erroneous-const.stderr b/tests/ui/consts/const-eval/erroneous-const.stderr
index 03030392a..770f95062 100644
--- a/tests/ui/consts/const-eval/erroneous-const.stderr
+++ b/tests/ui/consts/const-eval/erroneous-const.stderr
@@ -5,10 +5,10 @@ LL | const VOID: () = [()][2];
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
note: erroneous constant used
- --> $DIR/erroneous-const.rs:13:17
+ --> $DIR/erroneous-const.rs:13:13
|
-LL | let _ = PrintName::<T>::VOID;
- | ^^^^^^^^^^^^^^^^^^^^
+LL | PrintName::<T>::VOID;
+ | ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
diff --git a/tests/ui/consts/const-eval/erroneous-const2.rs b/tests/ui/consts/const-eval/erroneous-const2.rs
index 15c0f9107..61f2955f2 100644
--- a/tests/ui/consts/const-eval/erroneous-const2.rs
+++ b/tests/ui/consts/const-eval/erroneous-const2.rs
@@ -10,7 +10,7 @@ pub static FOO: () = {
if false {
// This bad constant is only used in dead code in a static initializer... and yet we still
// must make sure that the build fails.
- let _ = PrintName::<i32>::VOID; //~ constant
+ PrintName::<i32>::VOID; //~ constant
}
};
diff --git a/tests/ui/consts/const-eval/erroneous-const2.stderr b/tests/ui/consts/const-eval/erroneous-const2.stderr
index 8626f4d78..082c28765 100644
--- a/tests/ui/consts/const-eval/erroneous-const2.stderr
+++ b/tests/ui/consts/const-eval/erroneous-const2.stderr
@@ -5,10 +5,10 @@ LL | const VOID: () = [()][2];
| ^^^^^^^ index out of bounds: the length is 1 but the index is 2
note: erroneous constant used
- --> $DIR/erroneous-const2.rs:13:17
+ --> $DIR/erroneous-const2.rs:13:9
|
-LL | let _ = PrintName::<i32>::VOID;
- | ^^^^^^^^^^^^^^^^^^^^^^
+LL | PrintName::<i32>::VOID;
+ | ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
index 8f3b3d5f7..23ba2c2f5 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/alloc_intrinsic_errors.rs:9:17
|
LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2
|
note: inside `foo`
--> $DIR/alloc_intrinsic_errors.rs:9:17
diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs
index f746f2700..9ae906bbb 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs
@@ -4,11 +4,11 @@
use std::intrinsics;
const FOO: *const i32 = foo();
-//~^ ERROR untyped pointers are not allowed in constant
+//~^ ERROR unsupported untyped pointer in constant
const fn foo() -> &'static i32 {
let t = unsafe {
- let i = intrinsics::const_allocate(4, 4) as * mut i32;
+ let i = intrinsics::const_allocate(4, 4) as *mut i32;
*i = 20;
i
};
diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr
index 00ab0dfc5..2103f842b 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr
@@ -1,8 +1,10 @@
-error: untyped pointers are not allowed in constant
+error: unsupported untyped pointer in constant
--> $DIR/alloc_intrinsic_nontransient_fail.rs:6:1
|
LL | const FOO: *const i32 = foo();
| ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: memory only reachable via raw pointers is not supported
error: aborting due to previous error
diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs
index 77871c394..1354b3c33 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs
@@ -3,7 +3,7 @@
#![feature(const_mut_refs)]
use std::intrinsics;
-const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32};
-//~^ error: untyped pointers are not allowed in constant
+const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
+//~^ error: unsupported untyped pointer in constant
fn main() {}
diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr
index 36002b850..b62766473 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr
@@ -1,8 +1,10 @@
-error: untyped pointers are not allowed in constant
+error: unsupported untyped pointer in constant
--> $DIR/alloc_intrinsic_untyped.rs:6:1
|
-LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32};
+LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 };
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = note: memory only reachable via raw pointers is not supported
error: aborting due to previous error
diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr
index 650b409b1..4c23957a1 100644
--- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr
+++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr
@@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5
|
LL | intrinsics::const_deallocate(ptr, 4, 3);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_deallocate`: 3 is not a power of 2
error: aborting due to 4 previous errors
diff --git a/tests/ui/consts/const-eval/infinite_loop.rs b/tests/ui/consts/const-eval/infinite_loop.rs
index 4babc9a28..217814906 100644
--- a/tests/ui/consts/const-eval/infinite_loop.rs
+++ b/tests/ui/consts/const-eval/infinite_loop.rs
@@ -4,8 +4,8 @@ fn main() {
let _ = [(); {
let mut n = 113383; // #20 in https://oeis.org/A006884
while n != 0 {
- //~^ ERROR evaluation of constant value failed
- n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
+ //~^ ERROR is taking a long time
+ n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
}
n
}];
diff --git a/tests/ui/consts/const-eval/infinite_loop.stderr b/tests/ui/consts/const-eval/infinite_loop.stderr
index f30bfaf3f..f0434a847 100644
--- a/tests/ui/consts/const-eval/infinite_loop.stderr
+++ b/tests/ui/consts/const-eval/infinite_loop.stderr
@@ -1,12 +1,27 @@
-error[E0080]: evaluation of constant value failed
+error: constant evaluation is taking a long time
--> $DIR/infinite_loop.rs:6:9
|
LL | / while n != 0 {
LL | |
-LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
+LL | | n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 };
LL | | }
- | |_________^ exceeded interpreter step limit (see `#[const_eval_limit]`)
+ | |_________^
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/infinite_loop.rs:4:18
+ |
+LL | let _ = [(); {
+ | __________________^
+LL | | let mut n = 113383; // #20 in https://oeis.org/A006884
+LL | | while n != 0 {
+LL | |
+... |
+LL | | n
+LL | | }];
+ | |_____^
+ = note: `#[deny(long_running_const_eval)]` on by default
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/issue-52475.rs b/tests/ui/consts/const-eval/issue-52475.rs
index 307c1a668..ee26d2800 100644
--- a/tests/ui/consts/const-eval/issue-52475.rs
+++ b/tests/ui/consts/const-eval/issue-52475.rs
@@ -2,7 +2,8 @@ fn main() {
let _ = [(); {
let mut x = &0;
let mut n = 0;
- while n < 5 { //~ ERROR evaluation of constant value failed [E0080]
+ while n < 5 {
+ //~^ ERROR: constant evaluation is taking a long time
n = (n + 1) % 5;
x = &0; // Materialize a new AllocId
}
diff --git a/tests/ui/consts/const-eval/issue-52475.stderr b/tests/ui/consts/const-eval/issue-52475.stderr
index 3aa6bd277..ebf9d12a6 100644
--- a/tests/ui/consts/const-eval/issue-52475.stderr
+++ b/tests/ui/consts/const-eval/issue-52475.stderr
@@ -1,12 +1,28 @@
-error[E0080]: evaluation of constant value failed
+error: constant evaluation is taking a long time
--> $DIR/issue-52475.rs:5:9
|
LL | / while n < 5 {
+LL | |
LL | | n = (n + 1) % 5;
LL | | x = &0; // Materialize a new AllocId
LL | | }
- | |_________^ exceeded interpreter step limit (see `#[const_eval_limit]`)
+ | |_________^
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/issue-52475.rs:2:18
+ |
+LL | let _ = [(); {
+ | __________________^
+LL | | let mut x = &0;
+LL | | let mut n = 0;
+LL | | while n < 5 {
+... |
+LL | | 0
+LL | | }];
+ | |_____^
+ = note: `#[deny(long_running_const_eval)]` on by default
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/issue-70723.rs b/tests/ui/consts/const-eval/issue-70723.rs
index 3c81afa67..c8c809a25 100644
--- a/tests/ui/consts/const-eval/issue-70723.rs
+++ b/tests/ui/consts/const-eval/issue-70723.rs
@@ -1,3 +1,3 @@
-static _X: () = loop {}; //~ ERROR could not evaluate static initializer
+static _X: () = loop {}; //~ ERROR taking a long time
fn main() {}
diff --git a/tests/ui/consts/const-eval/issue-70723.stderr b/tests/ui/consts/const-eval/issue-70723.stderr
index 09fb3e060..572a43072 100644
--- a/tests/ui/consts/const-eval/issue-70723.stderr
+++ b/tests/ui/consts/const-eval/issue-70723.stderr
@@ -1,9 +1,17 @@
-error[E0080]: could not evaluate static initializer
+error: constant evaluation is taking a long time
--> $DIR/issue-70723.rs:1:17
|
LL | static _X: () = loop {};
- | ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
+ | ^^^^^^^
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/issue-70723.rs:1:1
+ |
+LL | static _X: () = loop {};
+ | ^^^^^^^^^^^^^
+ = note: `#[deny(long_running_const_eval)]` on by default
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/promoted_errors.rs b/tests/ui/consts/const-eval/promoted_errors.rs
index 2c42d0356..5e67dc6f6 100644
--- a/tests/ui/consts/const-eval/promoted_errors.rs
+++ b/tests/ui/consts/const-eval/promoted_errors.rs
@@ -48,5 +48,5 @@ const Y: () = {
};
fn main() {
- let _y = Y;
+ Y;
}
diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr
index a93b561e5..c0ddaceea 100644
--- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr
+++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr
@@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:44:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never`
|
= 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: 1, align: 1) {
@@ -290,11 +290,11 @@ error[E0080]: it is undefined behavior to use this value
LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: 8, align: 4) {
╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼....
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:152:1
@@ -529,11 +529,11 @@ error[E0080]: it is undefined behavior to use this value
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: 8, align: 4) {
╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:221:1
@@ -574,11 +574,11 @@ error[E0080]: it is undefined behavior to use this value
LL | pub static R5: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: 8, align: 4) {
╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼....
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:242:1
diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr
index a32d4863a..20c905878 100644
--- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr
+++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr
@@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:44:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never`
|
= 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: 1, align: 1) {
@@ -290,11 +290,11 @@ error[E0080]: it is undefined behavior to use this value
LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: 16, align: 8) {
╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:152:1
@@ -529,11 +529,11 @@ error[E0080]: it is undefined behavior to use this value
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: 16, align: 8) {
╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:221:1
@@ -574,11 +574,11 @@ error[E0080]: it is undefined behavior to use this value
LL | pub static R5: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: 16, align: 8) {
╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:242:1
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs
index c59596238..a30518170 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs
@@ -25,7 +25,7 @@ const fn call_foo() -> u32 {
foo();
foo();
foo();
- foo(); //~ ERROR evaluation of constant value failed [E0080]
+ foo(); //~ ERROR is taking a long time
0
}
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr
index ed70975af..a3fd712ca 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr
@@ -1,20 +1,17 @@
-error[E0080]: evaluation of constant value failed
- --> $DIR/ctfe-fn-call.rs:28:5
- |
-LL | foo();
- | ^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
- |
-note: inside `call_foo`
+error: constant evaluation is taking a long time
--> $DIR/ctfe-fn-call.rs:28:5
|
LL | foo();
| ^^^^^
-note: inside `X`
- --> $DIR/ctfe-fn-call.rs:32:16
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/ctfe-fn-call.rs:32:1
|
LL | const X: u32 = call_foo();
- | ^^^^^^^^^^
+ | ^^^^^^^^^^^^
+ = note: `#[deny(long_running_const_eval)]` on by default
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs
index c10b8d837..f7cd04568 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs
@@ -3,9 +3,10 @@
const fn labelled_loop(n: u32) -> u32 {
let mut i = 0;
- 'mylabel: loop { //~ ERROR evaluation of constant value failed [E0080]
+ 'mylabel: loop {
+ //~^ ERROR is taking a long time
if i > n {
- break 'mylabel
+ break 'mylabel;
}
i += 1;
}
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr
index d9404edd5..5808ee35a 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr
@@ -1,30 +1,23 @@
-error[E0080]: evaluation of constant value failed
+error: constant evaluation is taking a long time
--> $DIR/ctfe-labelled-loop.rs:6:5
|
LL | / 'mylabel: loop {
+LL | |
LL | | if i > n {
-LL | | break 'mylabel
-LL | | }
-LL | | i += 1;
-LL | | }
- | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`)
- |
-note: inside `labelled_loop`
- --> $DIR/ctfe-labelled-loop.rs:6:5
- |
-LL | / 'mylabel: loop {
-LL | | if i > n {
-LL | | break 'mylabel
+LL | | break 'mylabel;
LL | | }
LL | | i += 1;
LL | | }
| |_____^
-note: inside `X`
- --> $DIR/ctfe-labelled-loop.rs:15:16
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/ctfe-labelled-loop.rs:16:1
|
LL | const X: u32 = labelled_loop(19);
- | ^^^^^^^^^^^^^^^^^
+ | ^^^^^^^^^^^^
+ = note: `#[deny(long_running_const_eval)]` on by default
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs
index 80ff835f3..56a39fc45 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs
@@ -1,11 +1,12 @@
// check-fail
// compile-flags: -Z tiny-const-eval-limit
+#[rustfmt::skip]
const fn recurse(n: u32) -> u32 {
if n == 0 {
n
} else {
- recurse(n - 1) //~ ERROR evaluation of constant value failed [E0080]
+ recurse(n - 1) //~ ERROR is taking a long time
}
}
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr
index ed9a31119..524c8e554 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr
@@ -1,25 +1,17 @@
-error[E0080]: evaluation of constant value failed
- --> $DIR/ctfe-recursion.rs:8:9
- |
-LL | recurse(n - 1)
- | ^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
- |
-note: inside `recurse`
- --> $DIR/ctfe-recursion.rs:8:9
+error: constant evaluation is taking a long time
+ --> $DIR/ctfe-recursion.rs:9:9
|
LL | recurse(n - 1)
| ^^^^^^^^^^^^^^
-note: [... 18 additional calls inside `recurse` ...]
- --> $DIR/ctfe-recursion.rs:8:9
|
-LL | recurse(n - 1)
- | ^^^^^^^^^^^^^^
-note: inside `X`
- --> $DIR/ctfe-recursion.rs:12:16
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/ctfe-recursion.rs:13:1
|
LL | const X: u32 = recurse(19);
- | ^^^^^^^^^^^
+ | ^^^^^^^^^^^^
+ = note: `#[deny(long_running_const_eval)]` on by default
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr
new file mode 100644
index 000000000..30550f93a
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr
@@ -0,0 +1,19 @@
+warning: constant evaluation is taking a long time
+ --> $DIR/ctfe-simple-loop.rs:9:5
+ |
+LL | / while index < n {
+LL | |
+LL | |
+LL | |
+LL | | index = index + 1;
+LL | | }
+ | |_____^ the const evaluator is currently interpreting this expression
+ |
+help: the constant being evaluated
+ --> $DIR/ctfe-simple-loop.rs:19:1
+ |
+LL | const Y: u32 = simple_loop(35);
+ | ^^^^^^^^^^^^
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
index ca0eec93c..214f33dfb 100644
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
@@ -1,14 +1,22 @@
-// check-fail
+// check-pass
+// revisions: warn allow
+#![cfg_attr(warn, warn(long_running_const_eval))]
+#![cfg_attr(allow, allow(long_running_const_eval))]
+
// compile-flags: -Z tiny-const-eval-limit
const fn simple_loop(n: u32) -> u32 {
let mut index = 0;
- while index < n { //~ ERROR evaluation of constant value failed [E0080]
+ while index < n {
+ //~^ WARN is taking a long time
+ //[warn]~| WARN is taking a long time
+ //[warn]~| WARN is taking a long time
index = index + 1;
}
0
}
const X: u32 = simple_loop(19);
+const Y: u32 = simple_loop(35);
fn main() {
println!("{X}");
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr
deleted file mode 100644
index 83ff275de..000000000
--- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-error[E0080]: evaluation of constant value failed
- --> $DIR/ctfe-simple-loop.rs:5:5
- |
-LL | / while index < n {
-LL | | index = index + 1;
-LL | | }
- | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`)
- |
-note: inside `simple_loop`
- --> $DIR/ctfe-simple-loop.rs:5:5
- |
-LL | / while index < n {
-LL | | index = index + 1;
-LL | | }
- | |_____^
-note: inside `X`
- --> $DIR/ctfe-simple-loop.rs:11:16
- |
-LL | const X: u32 = simple_loop(19);
- | ^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr
new file mode 100644
index 000000000..40fc4a876
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr
@@ -0,0 +1,62 @@
+warning: constant evaluation is taking a long time
+ --> $DIR/ctfe-simple-loop.rs:9:5
+ |
+LL | / while index < n {
+LL | |
+LL | |
+LL | |
+LL | | index = index + 1;
+LL | | }
+ | |_____^
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/ctfe-simple-loop.rs:18:1
+ |
+LL | const X: u32 = simple_loop(19);
+ | ^^^^^^^^^^^^
+note: the lint level is defined here
+ --> $DIR/ctfe-simple-loop.rs:3:24
+ |
+LL | #![cfg_attr(warn, warn(long_running_const_eval))]
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: constant evaluation is taking a long time
+ --> $DIR/ctfe-simple-loop.rs:9:5
+ |
+LL | / while index < n {
+LL | |
+LL | |
+LL | |
+LL | | index = index + 1;
+LL | | }
+ | |_____^
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/ctfe-simple-loop.rs:19:1
+ |
+LL | const Y: u32 = simple_loop(35);
+ | ^^^^^^^^^^^^
+
+warning: constant evaluation is taking a long time
+ --> $DIR/ctfe-simple-loop.rs:9:5
+ |
+LL | / while index < n {
+LL | |
+LL | |
+LL | |
+LL | | index = index + 1;
+LL | | }
+ | |_____^ the const evaluator is currently interpreting this expression
+ |
+help: the constant being evaluated
+ --> $DIR/ctfe-simple-loop.rs:19:1
+ |
+LL | const Y: u32 = simple_loop(35);
+ | ^^^^^^^^^^^^
+
+warning: 3 warnings emitted
+
diff --git a/tests/ui/consts/const-eval/ub-enum.32bit.stderr b/tests/ui/consts/const-eval/ub-enum.32bit.stderr
index 3ad1ac974..1810600b7 100644
--- a/tests/ui/consts/const-eval/ub-enum.32bit.stderr
+++ b/tests/ui/consts/const-eval/ub-enum.32bit.stderr
@@ -86,7 +86,7 @@ error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:83:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never`
|
= 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: $SIZE, align: $ALIGN) {
@@ -108,7 +108,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:96:77
|
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
- | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type Never
+ | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type `Never`
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:98:77
diff --git a/tests/ui/consts/const-eval/ub-enum.64bit.stderr b/tests/ui/consts/const-eval/ub-enum.64bit.stderr
index a66706d1a..fb40babb0 100644
--- a/tests/ui/consts/const-eval/ub-enum.64bit.stderr
+++ b/tests/ui/consts/const-eval/ub-enum.64bit.stderr
@@ -86,7 +86,7 @@ error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:83:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never`
|
= 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: $SIZE, align: $ALIGN) {
@@ -108,7 +108,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:96:77
|
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
- | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type Never
+ | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type `Never`
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:98:77
diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr
index 733975fc0..f1ad0f04d 100644
--- a/tests/ui/consts/const-eval/ub-uninhabit.stderr
+++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/ub-uninhabit.rs:16:35
|
LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar`
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-uninhabit.rs:19:1
@@ -19,7 +19,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/ub-uninhabit.rs:22:42
|
LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar`
error: aborting due to 3 previous errors
diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs
index 2b0e58166..57959e7db 100644
--- a/tests/ui/consts/const-eval/unwind-abort.rs
+++ b/tests/ui/consts/const-eval/unwind-abort.rs
@@ -8,5 +8,5 @@ const _: () = foo();
// Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully
fn main() {
- let _ = foo();
+ foo();
}
diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr
index 74bc6317c..b423edbdc 100644
--- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr
+++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr
@@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/validate_uninhabited_zsts.rs:21:42
|
LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
- | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void`
warning: the type `empty::Empty` does not permit zero-initialization
--> $DIR/validate_uninhabited_zsts.rs:21:42
diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr
index 74bc6317c..b423edbdc 100644
--- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr
+++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr
@@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/validate_uninhabited_zsts.rs:21:42
|
LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
- | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void
+ | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void`
warning: the type `empty::Empty` does not permit zero-initialization
--> $DIR/validate_uninhabited_zsts.rs:21:42
diff --git a/tests/ui/consts/const-len-underflow-separate-spans.stderr b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr
index 269553631..d9208d070 100644
--- a/tests/ui/consts/const-len-underflow-separate-spans.stderr
+++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr
@@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
- --> $DIR/const-len-underflow-separate-spans.rs:7:20
+ --> $DIR/const-len-underflow-separate-spans.rs:10:20
|
LL | const LEN: usize = ONE - TWO;
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
note: erroneous constant used
- --> $DIR/const-len-underflow-separate-spans.rs:11:17
+ --> $DIR/const-len-underflow-separate-spans.rs:14:17
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^
diff --git a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr
new file mode 100644
index 000000000..d9208d070
--- /dev/null
+++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr
@@ -0,0 +1,15 @@
+error[E0080]: evaluation of constant value failed
+ --> $DIR/const-len-underflow-separate-spans.rs:10:20
+ |
+LL | const LEN: usize = ONE - TWO;
+ | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
+
+note: erroneous constant used
+ --> $DIR/const-len-underflow-separate-spans.rs:14:17
+ |
+LL | let a: [i8; LEN] = unimplemented!();
+ | ^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs
index 4544c8876..55704b641 100644
--- a/tests/ui/consts/const-len-underflow-separate-spans.rs
+++ b/tests/ui/consts/const-len-underflow-separate-spans.rs
@@ -2,6 +2,9 @@
// spot (where the underflow occurred), while also providing the
// overall context for what caused the evaluation.
+// revisions: old next
+//[next] compile-flags: -Ztrait-solver=next
+
const ONE: usize = 1;
const TWO: usize = 2;
const LEN: usize = ONE - TWO;
diff --git a/tests/ui/consts/const_in_pattern/issue-73431.rs b/tests/ui/consts/const_in_pattern/issue-73431.rs
index fa18a3af1..835f502b4 100644
--- a/tests/ui/consts/const_in_pattern/issue-73431.rs
+++ b/tests/ui/consts/const_in_pattern/issue-73431.rs
@@ -1,4 +1,5 @@
// run-pass
+// unset-rustc-env:RUSTC_LOG_COLOR
// Regression test for https://github.com/rust-lang/rust/issues/73431.
diff --git a/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs b/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs
deleted file mode 100644
index 629d1f02a..000000000
--- a/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// check-pass
-
-#![feature(const_eval_limit)]
-
-// This needs to be higher than the number of loop iterations since each pass through the loop may
-// hit more than one terminator.
-#![const_eval_limit="4000"]
-
-const X: usize = {
- let mut x = 0;
- while x != 1000 {
- x += 1;
- }
-
- x
-};
-
-fn main() {
- assert_eq!(X, 1000);
-}
diff --git a/tests/ui/consts/const_limit/const_eval_limit_overflow.rs b/tests/ui/consts/const_limit/const_eval_limit_overflow.rs
deleted file mode 100644
index 1c49593cd..000000000
--- a/tests/ui/consts/const_limit/const_eval_limit_overflow.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-#![feature(const_eval_limit)]
-#![const_eval_limit="18_446_744_073_709_551_615"]
-//~^ ERROR `limit` must be a non-negative integer
-
-const CONSTANT: usize = limit();
-
-fn main() {
- assert_eq!(CONSTANT, 1764);
-}
-
-const fn limit() -> usize {
- let x = 42;
-
- x * 42
-}
diff --git a/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr b/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr
deleted file mode 100644
index 7f5d5e6cd..000000000
--- a/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: `limit` must be a non-negative integer
- --> $DIR/const_eval_limit_overflow.rs:2:1
- |
-LL | #![const_eval_limit="18_446_744_073_709_551_615"]
- | ^^^^^^^^^^^^^^^^^^^^----------------------------^
- | |
- | not a valid integer
-
-error: aborting due to previous error
-
diff --git a/tests/ui/consts/const_limit/const_eval_limit_reached.rs b/tests/ui/consts/const_limit/const_eval_limit_reached.rs
deleted file mode 100644
index 3ce038c1d..000000000
--- a/tests/ui/consts/const_limit/const_eval_limit_reached.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-#![feature(const_eval_limit)]
-#![const_eval_limit = "500"]
-
-const X: usize = {
- let mut x = 0;
- while x != 1000 {
- //~^ ERROR evaluation of constant value failed
- x += 1;
- }
-
- x
-};
-
-fn main() {
- assert_eq!(X, 1000);
-}
diff --git a/tests/ui/consts/const_limit/const_eval_limit_reached.stderr b/tests/ui/consts/const_limit/const_eval_limit_reached.stderr
deleted file mode 100644
index a8e8ae9bb..000000000
--- a/tests/ui/consts/const_limit/const_eval_limit_reached.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0080]: evaluation of constant value failed
- --> $DIR/const_eval_limit_reached.rs:6:5
- |
-LL | / while x != 1000 {
-LL | |
-LL | | x += 1;
-LL | | }
- | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs b/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs
deleted file mode 100644
index 61119d751..000000000
--- a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-#![const_eval_limit="42"]
-//~^ ERROR the `#[const_eval_limit]` attribute is an experimental feature [E0658]
-
-const CONSTANT: usize = limit();
-
-fn main() {
- assert_eq!(CONSTANT, 1764);
-}
-
-const fn limit() -> usize {
- let x = 42;
-
- x * 42
-}
diff --git a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr b/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr
deleted file mode 100644
index 5bd29c7df..000000000
--- a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0658]: the `#[const_eval_limit]` attribute is an experimental feature
- --> $DIR/feature-gate-const_eval_limit.rs:1:1
- |
-LL | #![const_eval_limit="42"]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #67217 <https://github.com/rust-lang/rust/issues/67217> for more information
- = help: add `#![feature(const_eval_limit)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/consts/issue-16538.mir.stderr b/tests/ui/consts/issue-16538.mir.stderr
new file mode 100644
index 000000000..e320df4b7
--- /dev/null
+++ b/tests/ui/consts/issue-16538.mir.stderr
@@ -0,0 +1,29 @@
+error[E0015]: cannot call non-const fn `Y::foo` in statics
+ --> $DIR/issue-16538.rs:14:23
+ |
+LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: calls in statics are limited to constant functions, tuple structs and tuple variants
+ = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/issue-16538.rs:14:30
+ |
+LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+ | ^^^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
+ --> $DIR/issue-16538.rs:14:21
+ |
+LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
+ |
+ = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0015, E0133.
+For more information about an error, try `rustc --explain E0015`.
diff --git a/tests/ui/consts/issue-16538.rs b/tests/ui/consts/issue-16538.rs
new file mode 100644
index 000000000..270fa3014
--- /dev/null
+++ b/tests/ui/consts/issue-16538.rs
@@ -0,0 +1,19 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
+mod Y {
+ pub type X = usize;
+ extern "C" {
+ pub static x: *const usize;
+ }
+ pub fn foo(value: *const X) -> *const X {
+ value
+ }
+}
+
+static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+//~^ ERROR dereference of raw pointer
+//~| ERROR E0015
+//~| ERROR use of extern static is unsafe and requires
+
+fn main() {}
diff --git a/tests/ui/consts/issue-16538.thir.stderr b/tests/ui/consts/issue-16538.thir.stderr
new file mode 100644
index 000000000..4a8628692
--- /dev/null
+++ b/tests/ui/consts/issue-16538.thir.stderr
@@ -0,0 +1,29 @@
+error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
+ --> $DIR/issue-16538.rs:14:22
+ |
+LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereference of raw pointer
+ |
+ = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
+
+error[E0133]: use of extern static is unsafe and requires unsafe function or block
+ --> $DIR/issue-16538.rs:14:30
+ |
+LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+ | ^^^^ use of extern static
+ |
+ = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
+
+error[E0015]: cannot call non-const fn `Y::foo` in statics
+ --> $DIR/issue-16538.rs:14:23
+ |
+LL | static foo: &Y::X = &*Y::foo(Y::x as *const Y::X);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: calls in statics are limited to constant functions, tuple structs and tuple variants
+ = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0015, E0133.
+For more information about an error, try `rustc --explain E0015`.
diff --git a/tests/ui/consts/issue-28822.rs b/tests/ui/consts/issue-28822.rs
new file mode 100644
index 000000000..10e5d1dd0
--- /dev/null
+++ b/tests/ui/consts/issue-28822.rs
@@ -0,0 +1,7 @@
+// check-pass
+#![allow(dead_code)]
+
+fn main() {}
+
+const fn size_ofs(_: usize) {}
+const fn size_ofs2(_foo: usize) {}
diff --git a/tests/ui/consts/issue-29798.rs b/tests/ui/consts/issue-29798.rs
new file mode 100644
index 000000000..5eff5d191
--- /dev/null
+++ b/tests/ui/consts/issue-29798.rs
@@ -0,0 +1,11 @@
+// run-fail
+// error-pattern:index out of bounds: the len is 5 but the index is 5
+// ignore-emscripten no processes
+
+const fn test(x: usize) -> i32 {
+ [42;5][x]
+}
+
+fn main () {
+ let _ = test(5);
+}
diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr
index 31a5b1df8..2fe84245b 100644
--- a/tests/ui/consts/issue-64506.stderr
+++ b/tests/ui/consts/issue-64506.stderr
@@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed
--> $DIR/issue-64506.rs:16:22
|
LL | let x = unsafe { Foo { b: () }.a };
- | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type AnonPipe
+ | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe`
error: aborting due to previous error
diff --git a/tests/ui/consts/issue-83182.stderr b/tests/ui/consts/issue-83182.stderr
index 1d578f910..ca4e0f7aa 100644
--- a/tests/ui/consts/issue-83182.stderr
+++ b/tests/ui/consts/issue-83182.stderr
@@ -4,11 +4,11 @@ error[E0080]: it is undefined behavior to use this value
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
HEX_DUMP
}
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error: aborting due to previous error
diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr
index fb758d406..67797e6fb 100644
--- a/tests/ui/consts/issue-miri-1910.stderr
+++ b/tests/ui/consts/issue-miri-1910.stderr
@@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed
|
= note: unable to turn pointer into raw bytes
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
note: inside `std::ptr::read::<u8>`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `ptr::const_ptr::<impl *const u8>::read`
@@ -14,6 +12,8 @@ note: inside `C`
|
LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error: aborting due to previous error
diff --git a/tests/ui/consts/large_const_alloc.rs b/tests/ui/consts/large_const_alloc.rs
index 54abaab22..298ed38d1 100644
--- a/tests/ui/consts/large_const_alloc.rs
+++ b/tests/ui/consts/large_const_alloc.rs
@@ -13,6 +13,6 @@ static FOO2: () = {
};
fn main() {
- let _ = FOO;
- let _ = FOO2;
+ FOO;
+ FOO2;
}
diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr
index 8e22cb74b..d97097d35 100644
--- a/tests/ui/consts/miri_unleashed/assoc_const.stderr
+++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr
@@ -1,4 +1,4 @@
-error[E0080]: evaluation of `<std::string::String as Bar<std::vec::Vec<u32>, std::string::String>>::F` failed
+error[E0080]: evaluation of `<String as Bar<Vec<u32>, String>>::F` failed
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
= note: calling non-const function `<Vec<u32> as Drop>::drop`
diff --git a/tests/ui/consts/miri_unleashed/raw_mutable_const.rs b/tests/ui/consts/miri_unleashed/raw_mutable_const.rs
index 5f8ec4e6e..adb1f8bf3 100644
--- a/tests/ui/consts/miri_unleashed/raw_mutable_const.rs
+++ b/tests/ui/consts/miri_unleashed/raw_mutable_const.rs
@@ -3,6 +3,6 @@
use std::cell::UnsafeCell;
const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
-//~^ ERROR: untyped pointers are not allowed in constant
+//~^ ERROR: unsupported untyped pointer in constant
fn main() {}
diff --git a/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr b/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr
index f8dc11d69..5acdcdd95 100644
--- a/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr
+++ b/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr
@@ -1,8 +1,10 @@
-error: untyped pointers are not allowed in constant
+error: unsupported untyped pointer in constant
--> $DIR/raw_mutable_const.rs:5:1
|
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: memory only reachable via raw pointers is not supported
warning: skipping const checks
|
diff --git a/tests/ui/consts/missing-larger-array-impl.rs b/tests/ui/consts/missing-larger-array-impl.rs
new file mode 100644
index 000000000..e6c879c8e
--- /dev/null
+++ b/tests/ui/consts/missing-larger-array-impl.rs
@@ -0,0 +1,9 @@
+struct X;
+
+// Make sure that we show the impl trait refs in the help message with
+// their evaluated constants, rather than `core::::array::{impl#30}::{constant#0}`
+
+fn main() {
+ <[X; 35] as Default>::default();
+ //~^ ERROR the trait bound `[X; 35]: Default` is not satisfied
+}
diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr
new file mode 100644
index 000000000..b8f6cb5ef
--- /dev/null
+++ b/tests/ui/consts/missing-larger-array-impl.stderr
@@ -0,0 +1,20 @@
+error[E0277]: the trait bound `[X; 35]: Default` is not satisfied
+ --> $DIR/missing-larger-array-impl.rs:7:5
+ |
+LL | <[X; 35] as Default>::default();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]`
+ |
+ = help: the following other types implement trait `Default`:
+ [T; 0]
+ [T; 1]
+ [T; 2]
+ [T; 3]
+ [T; 4]
+ [T; 5]
+ [T; 6]
+ [T; 7]
+ and 27 others
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr
index e6d3d5199..fcfb9fbb3 100644
--- a/tests/ui/consts/missing_span_in_backtrace.stderr
+++ b/tests/ui/consts/missing_span_in_backtrace.stderr
@@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed
|
= note: unable to copy parts of a pointer from memory at ALLOC_ID
|
- = help: this code performed an operation that depends on the underlying bytes representing a pointer
- = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
note: inside `mem::swap_simple::<MaybeUninit<MaybeUninit<u8>>>`
@@ -22,6 +20,8 @@ note: inside `X`
20 | | mem::size_of::<&i32>(),
21 | | );
| |_________^
+ = help: this code performed an operation that depends on the underlying bytes representing a pointer
+ = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error: aborting due to previous error
diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr
index 6530084a5..97ff6efdd 100644
--- a/tests/ui/consts/offset_from_ub.stderr
+++ b/tests/ui/consts/offset_from_ub.stderr
@@ -27,31 +27,31 @@ error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:37:14
|
LL | unsafe { ptr_offset_from(ptr, ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance)
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:44:14
|
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8[noalloc] is a dangling pointer (it has no provenance)
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: 0x8[noalloc] is a dangling pointer (it has no provenance)
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:53:14
|
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:62:14
|
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:70:14
|
LL | unsafe { ptr_offset_from(end_ptr, end_ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc23 has size 4, so pointer at offset 10 is out-of-bounds
error[E0080]: evaluation of constant value failed
--> $DIR/offset_from_ub.rs:79:14
@@ -86,7 +86,7 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) }
error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
- = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
+ = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance)
|
note: inside `ptr::const_ptr::<impl *const u8>::offset_from`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -99,7 +99,7 @@ LL | unsafe { ptr2.offset_from(ptr1) }
error[E0080]: evaluation of constant value failed
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
- = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance)
+ = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance)
|
note: inside `ptr::const_ptr::<impl *const u8>::offset_from`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
diff --git a/tests/ui/consts/raw-ptr-const.rs b/tests/ui/consts/raw-ptr-const.rs
index b9c542d03..fc774be54 100644
--- a/tests/ui/consts/raw-ptr-const.rs
+++ b/tests/ui/consts/raw-ptr-const.rs
@@ -3,6 +3,6 @@
// could also be allowed.
const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _;
-//~^ ERROR untyped pointers are not allowed in constant
+//~^ ERROR unsupported untyped pointer in constant
fn main() {}
diff --git a/tests/ui/consts/raw-ptr-const.stderr b/tests/ui/consts/raw-ptr-const.stderr
index f7b53433b..82f782fab 100644
--- a/tests/ui/consts/raw-ptr-const.stderr
+++ b/tests/ui/consts/raw-ptr-const.stderr
@@ -1,8 +1,10 @@
-error: untyped pointers are not allowed in constant
+error: unsupported untyped pointer in constant
--> $DIR/raw-ptr-const.rs:5:1
|
LL | const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: memory only reachable via raw pointers is not supported
error: aborting due to previous error
diff --git a/tests/ui/consts/refs_check_const_eq-issue-88384.rs b/tests/ui/consts/refs_check_const_eq-issue-88384.rs
index 1496b28bd..fb0405b65 100644
--- a/tests/ui/consts/refs_check_const_eq-issue-88384.rs
+++ b/tests/ui/consts/refs_check_const_eq-issue-88384.rs
@@ -8,10 +8,10 @@ struct CompileTimeSettings{
}
struct Foo<const T: CompileTimeSettings>;
-//~^ ERROR using function pointers as const generic parameters is forbidden
+//~^ ERROR `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter
impl<const T: CompileTimeSettings> Foo<T> {
- //~^ ERROR using function pointers as const generic parameters is forbidden
+ //~^ ERROR `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter
fn call_hooks(){
}
}
diff --git a/tests/ui/consts/refs_check_const_eq-issue-88384.stderr b/tests/ui/consts/refs_check_const_eq-issue-88384.stderr
index 3855b5f2a..c490cd053 100644
--- a/tests/ui/consts/refs_check_const_eq-issue-88384.stderr
+++ b/tests/ui/consts/refs_check_const_eq-issue-88384.stderr
@@ -7,17 +7,29 @@ LL | #![feature(adt_const_params)]
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
= note: `#[warn(incomplete_features)]` on by default
-error[E0741]: using function pointers as const generic parameters is forbidden
+error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> $DIR/refs_check_const_eq-issue-88384.rs:10:21
|
LL | struct Foo<const T: CompileTimeSettings>;
| ^^^^^^^^^^^^^^^^^^^
+ |
+help: add `#[derive(ConstParamTy)]` to the struct
+ |
+LL + #[derive(ConstParamTy)]
+LL | struct CompileTimeSettings{
+ |
-error[E0741]: using function pointers as const generic parameters is forbidden
+error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> $DIR/refs_check_const_eq-issue-88384.rs:13:15
|
LL | impl<const T: CompileTimeSettings> Foo<T> {
| ^^^^^^^^^^^^^^^^^^^
+ |
+help: add `#[derive(ConstParamTy)]` to the struct
+ |
+LL + #[derive(ConstParamTy)]
+LL | struct CompileTimeSettings{
+ |
error: aborting due to 2 previous errors; 1 warning emitted
diff --git a/tests/ui/consts/timeout.rs b/tests/ui/consts/timeout.rs
new file mode 100644
index 000000000..c9094999e
--- /dev/null
+++ b/tests/ui/consts/timeout.rs
@@ -0,0 +1,25 @@
+//! This test checks that external macros don't hide
+//! the const eval timeout lint and then subsequently
+//! ICE.
+
+// compile-flags: --crate-type=lib -Ztiny-const-eval-limit
+// error-pattern: constant evaluation is taking a long time
+
+static ROOK_ATTACKS_TABLE: () = {
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+ 0_u64.count_ones();
+};
diff --git a/tests/ui/consts/timeout.stderr b/tests/ui/consts/timeout.stderr
new file mode 100644
index 000000000..799b5ec8d
--- /dev/null
+++ b/tests/ui/consts/timeout.stderr
@@ -0,0 +1,15 @@
+error: constant evaluation is taking a long time
+ --> $SRC_DIR/core/src/num/mod.rs:LL:COL
+ |
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
+ If your compilation actually takes a long time, you can safely allow the lint.
+help: the constant being evaluated
+ --> $DIR/timeout.rs:8:1
+ |
+LL | static ROOK_ATTACKS_TABLE: () = {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: `#[deny(long_running_const_eval)]` on by default
+ = note: this error originates in the macro `uint_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/tests/ui/consts/too_generic_eval_ice.stderr b/tests/ui/consts/too_generic_eval_ice.stderr
index 5af82a3e3..843d6d9e0 100644
--- a/tests/ui/consts/too_generic_eval_ice.stderr
+++ b/tests/ui/consts/too_generic_eval_ice.stderr
@@ -22,14 +22,14 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
|
= help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]`
= help: the following other types implement trait `PartialEq<Rhs>`:
- <&[B] as PartialEq<[A; N]>>
- <&[T] as PartialEq<Vec<U, A>>>
- <&mut [B] as PartialEq<[A; N]>>
- <&mut [T] as PartialEq<Vec<U, A>>>
- <[A; N] as PartialEq<&[B]>>
- <[A; N] as PartialEq<&mut [B]>>
<[A; N] as PartialEq<[B; N]>>
<[A; N] as PartialEq<[B]>>
+ <[A; N] as PartialEq<&[B]>>
+ <[A; N] as PartialEq<&mut [B]>>
+ <[T] as PartialEq<Vec<U, A>>>
+ <[A] as PartialEq<[B]>>
+ <[B] as PartialEq<[A; N]>>
+ <&[T] as PartialEq<Vec<U, A>>>
and 3 others
error: aborting due to 3 previous errors