diff options
| author | Ralf Jung <post@ralfj.de> | 2024-03-13 15:07:47 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-03-13 17:49:45 +0100 |
| commit | 514b2745b35ecc8c8c0b8ec8c12bde3fa48cb464 (patch) | |
| tree | 386fcc61f7b685e505b4962d70deb2e36b7eac10 /tests/ui/consts/const-eval | |
| parent | 7de1a1f6db26cf7af43cca74819118428e6317ee (diff) | |
| download | rust-514b2745b35ecc8c8c0b8ec8c12bde3fa48cb464.tar.gz rust-514b2745b35ecc8c8c0b8ec8c12bde3fa48cb464.zip | |
const-eval: organize and extend tests for required-consts
Diffstat (limited to 'tests/ui/consts/const-eval')
| -rw-r--r-- | tests/ui/consts/const-eval/erroneous-const.rs | 21 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/erroneous-const.stderr | 15 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/erroneous-const2.rs | 19 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/erroneous-const2.stderr | 15 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/unused-broken-const-late.rs | 20 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/unused-broken-const-late.stderr | 11 |
6 files changed, 0 insertions, 101 deletions
diff --git a/tests/ui/consts/const-eval/erroneous-const.rs b/tests/ui/consts/const-eval/erroneous-const.rs deleted file mode 100644 index 74d44c5259a..00000000000 --- a/tests/ui/consts/const-eval/erroneous-const.rs +++ /dev/null @@ -1,21 +0,0 @@ -//! Make sure we error on erroneous consts even if they are unused. -#![allow(unconditional_panic)] - -struct PrintName<T>(T); -impl<T> PrintName<T> { - const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::<i32>::VOID` failed -} - -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. - PrintName::<T>::VOID; //~ constant - } -} - -pub static FOO: () = no_codegen::<i32>(); - -fn main() { - FOO -} diff --git a/tests/ui/consts/const-eval/erroneous-const.stderr b/tests/ui/consts/const-eval/erroneous-const.stderr deleted file mode 100644 index bd25e96c2cf..00000000000 --- a/tests/ui/consts/const-eval/erroneous-const.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0080]: evaluation of `PrintName::<i32>::VOID` failed - --> $DIR/erroneous-const.rs:6:22 - | -LL | const VOID: () = [()][2]; - | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - -note: erroneous constant encountered - --> $DIR/erroneous-const.rs:13:13 - | -LL | PrintName::<T>::VOID; - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/erroneous-const2.rs b/tests/ui/consts/const-eval/erroneous-const2.rs deleted file mode 100644 index 61f2955f2d8..00000000000 --- a/tests/ui/consts/const-eval/erroneous-const2.rs +++ /dev/null @@ -1,19 +0,0 @@ -//! Make sure we error on erroneous consts even if they are unused. -#![allow(unconditional_panic)] - -struct PrintName<T>(T); -impl<T> PrintName<T> { - const VOID: () = [()][2]; //~ERROR evaluation of `PrintName::<i32>::VOID` failed -} - -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. - PrintName::<i32>::VOID; //~ constant - } -}; - -fn main() { - FOO -} diff --git a/tests/ui/consts/const-eval/erroneous-const2.stderr b/tests/ui/consts/const-eval/erroneous-const2.stderr deleted file mode 100644 index 6a5839e3dfb..00000000000 --- a/tests/ui/consts/const-eval/erroneous-const2.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0080]: evaluation of `PrintName::<i32>::VOID` failed - --> $DIR/erroneous-const2.rs:6:22 - | -LL | const VOID: () = [()][2]; - | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 - -note: erroneous constant encountered - --> $DIR/erroneous-const2.rs:13:9 - | -LL | PrintName::<i32>::VOID; - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/unused-broken-const-late.rs b/tests/ui/consts/const-eval/unused-broken-const-late.rs deleted file mode 100644 index c4916061f9e..00000000000 --- a/tests/ui/consts/const-eval/unused-broken-const-late.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ build-fail -//@ compile-flags: -O -//! Make sure we detect erroneous constants post-monomorphization even when they are unused. This is -//! crucial, people rely on it for soundness. (https://github.com/rust-lang/rust/issues/112090) - -struct PrintName<T>(T); -impl<T> PrintName<T> { - const VOID: () = panic!(); //~ERROR evaluation of `PrintName::<i32>::VOID` failed -} - -fn no_codegen<T>() { - // Any function that is called is guaranteed to have all consts that syntactically - // appear in its body evaluated, even if they only appear in dead code. - if false { - let _ = PrintName::<T>::VOID; - } -} -pub fn main() { - no_codegen::<i32>(); -} diff --git a/tests/ui/consts/const-eval/unused-broken-const-late.stderr b/tests/ui/consts/const-eval/unused-broken-const-late.stderr deleted file mode 100644 index c2cf2f3813c..00000000000 --- a/tests/ui/consts/const-eval/unused-broken-const-late.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0080]: evaluation of `PrintName::<i32>::VOID` failed - --> $DIR/unused-broken-const-late.rs:8:22 - | -LL | const VOID: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unused-broken-const-late.rs:8:22 - | - = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0080`. |
