summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-eval
diff options
context:
space:
mode:
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/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
37 files changed, 226 insertions, 133 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 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