From 762ded17f83a9309c5d8a626e2bc30a544048007 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 18 Oct 2020 14:34:30 +0200 Subject: [PATCH] we can test std and core panic macros together --- src/test/ui/consts/const-eval/const_panic.rs | 21 ++++- .../ui/consts/const-eval/const_panic.stderr | 82 +++++++++++++++---- .../consts/const-eval/const_panic_libcore.rs | 12 --- ...ore_main.rs => const_panic_libcore_bin.rs} | 0 ....stderr => const_panic_libcore_bin.stderr} | 12 +-- .../const_panic_libcore_main.stderr | 33 -------- 6 files changed, 90 insertions(+), 70 deletions(-) delete mode 100644 src/test/ui/consts/const-eval/const_panic_libcore.rs rename src/test/ui/consts/const-eval/{const_panic_libcore_main.rs => const_panic_libcore_bin.rs} (100%) rename src/test/ui/consts/const-eval/{const_panic_libcore.stderr => const_panic_libcore_bin.stderr} (78%) delete mode 100644 src/test/ui/consts/const-eval/const_panic_libcore_main.stderr diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs index 3e5112b0b145f..ada9feec8971e 100644 --- a/src/test/ui/consts/const-eval/const_panic.rs +++ b/src/test/ui/consts/const-eval/const_panic.rs @@ -1,11 +1,26 @@ #![feature(const_panic)] #![crate_type = "lib"] -pub const Z: () = panic!("cheese"); +const Z: () = std::panic!("cheese"); //~^ ERROR any use of this value will cause an error -pub const Y: () = unreachable!(); +const Z2: () = std::panic!(); //~^ ERROR any use of this value will cause an error -pub const X: () = unimplemented!(); +const Y: () = std::unreachable!(); +//~^ ERROR any use of this value will cause an error + +const X: () = std::unimplemented!(); +//~^ ERROR any use of this value will cause an error + +const Z_CORE: () = core::panic!("cheese"); +//~^ ERROR any use of this value will cause an error + +const Z2_CORE: () = core::panic!(); +//~^ ERROR any use of this value will cause an error + +const Y_CORE: () = core::unreachable!(); +//~^ ERROR any use of this value will cause an error + +const X_CORE: () = core::unimplemented!(); //~^ ERROR any use of this value will cause an error diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index 679d8f280cc60..e4ca1f4fa26a2 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -1,33 +1,83 @@ error: any use of this value will cause an error - --> $DIR/const_panic.rs:4:19 + --> $DIR/const_panic.rs:4:15 | -LL | pub const Z: () = panic!("cheese"); - | ------------------^^^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:19 +LL | const Z: () = std::panic!("cheese"); + | --------------^^^^^^^^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:15 | = note: `#[deny(const_err)]` on by default = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:7:19 + --> $DIR/const_panic.rs:7:16 | -LL | pub const Y: () = unreachable!(); - | ------------------^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:7:19 +LL | const Z2: () = std::panic!(); + | ---------------^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:7:16 | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:10:19 + --> $DIR/const_panic.rs:10:15 | -LL | pub const X: () = unimplemented!(); - | ------------------^^^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:10:19 +LL | const Y: () = std::unreachable!(); + | --------------^^^^^^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:10:15 | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +error: any use of this value will cause an error + --> $DIR/const_panic.rs:13:15 + | +LL | const X: () = std::unimplemented!(); + | --------------^^^^^^^^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:13:15 + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: any use of this value will cause an error + --> $DIR/const_panic.rs:16:20 + | +LL | const Z_CORE: () = core::panic!("cheese"); + | -------------------^^^^^^^^^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:16:20 + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: any use of this value will cause an error + --> $DIR/const_panic.rs:19:21 + | +LL | const Z2_CORE: () = core::panic!(); + | --------------------^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:19:21 + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: any use of this value will cause an error + --> $DIR/const_panic.rs:22:20 + | +LL | const Y_CORE: () = core::unreachable!(); + | -------------------^^^^^^^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:22:20 + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: any use of this value will cause an error + --> $DIR/const_panic.rs:25:20 + | +LL | const X_CORE: () = core::unimplemented!(); + | -------------------^^^^^^^^^^^^^^^^^^^^^^- + | | + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:25:20 + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.rs b/src/test/ui/consts/const-eval/const_panic_libcore.rs deleted file mode 100644 index e42685e9c76b0..0000000000000 --- a/src/test/ui/consts/const-eval/const_panic_libcore.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![no_std] -#![crate_type = "lib"] -#![feature(const_panic)] - -const Z: () = panic!("cheese"); -//~^ ERROR any use of this value will cause an error - -const Y: () = unreachable!(); -//~^ ERROR any use of this value will cause an error - -const X: () = unimplemented!(); -//~^ ERROR any use of this value will cause an error diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.rs b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs similarity index 100% rename from src/test/ui/consts/const-eval/const_panic_libcore_main.rs rename to src/test/ui/consts/const-eval/const_panic_libcore_bin.rs diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr similarity index 78% rename from src/test/ui/consts/const-eval/const_panic_libcore.stderr rename to src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr index 2abf158aade54..9eeddc464f5ad 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -1,31 +1,31 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:5:15 + --> $DIR/const_panic_libcore_bin.rs:9:15 | LL | const Z: () = panic!("cheese"); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore.rs:5:15 + | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15 | = note: `#[deny(const_err)]` on by default = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:8:15 + --> $DIR/const_panic_libcore_bin.rs:12:15 | LL | const Y: () = unreachable!(); | --------------^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore.rs:8:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15 | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:11:15 + --> $DIR/const_panic_libcore_bin.rs:15:15 | LL | const X: () = unimplemented!(); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore.rs:11:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15 | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr deleted file mode 100644 index c5887ff8c5697..0000000000000 --- a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:9:15 - | -LL | const Z: () = panic!("cheese"); - | --------------^^^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:9:15 - | - = note: `#[deny(const_err)]` on by default - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:12:15 - | -LL | const Y: () = unreachable!(); - | --------------^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:12:15 - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:15:15 - | -LL | const X: () = unimplemented!(); - | --------------^^^^^^^^^^^^^^^^- - | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_main.rs:15:15 - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 3 previous errors -