diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-05-25 20:54:59 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2021-05-30 11:59:54 -0500 |
| commit | 2779fc1c4768567b74b757a8083db3c39765f071 (patch) | |
| tree | bf4b6fe649cc157aa435373bcf14dc539e4bd4b5 /src | |
| parent | 2023cc3aa1ea98530f3124ed07713e6f95fd26ab (diff) | |
| download | rust-2779fc1c4768567b74b757a8083db3c39765f071.tar.gz rust-2779fc1c4768567b74b757a8083db3c39765f071.zip | |
Emit a hard error when a panic occurs during const-eval
Previous, a panic during const evaluation would go through the `const_err` lint. This PR ensures that such a panic always causes compilation to fail.
Diffstat (limited to 'src')
13 files changed, 56 insertions, 128 deletions
diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs index 8ae8376ae4a..b33b1475a22 100644 --- a/src/test/ui/consts/const-eval/const_panic.rs +++ b/src/test/ui/consts/const-eval/const_panic.rs @@ -6,40 +6,30 @@ const MSG: &str = "hello"; const Z: () = std::panic!("cheese"); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Z2: () = std::panic!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Y: () = std::unreachable!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const X: () = std::unimplemented!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // const W: () = std::panic!(MSG); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Z_CORE: () = core::panic!("cheese"); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Z2_CORE: () = core::panic!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Y_CORE: () = core::unreachable!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const X_CORE: () = core::unimplemented!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const W_CORE: () = core::panic!(MSG); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index 5637de8b313..3c890f78af7 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: any use of this value will cause an error --> $DIR/const_panic.rs:7:15 | LL | const Z: () = std::panic!("cheese"); @@ -6,118 +6,98 @@ LL | const Z: () = std::panic!("cheese"); | | | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15 | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:11:16 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:10:16 | LL | const Z2: () = std::panic!(); | ---------------^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:11:16 + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:15:15 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:13:15 | LL | const Y: () = std::unreachable!(); | --------------^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:15:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:15 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:16:15 | LL | const X: () = std::unimplemented!(); | --------------^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:19:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:23:15 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:19:15 | LL | const W: () = std::panic!(MSG); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'hello', $DIR/const_panic.rs:23:15 + | the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:27:20 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:22:20 | LL | const Z_CORE: () = core::panic!("cheese"); | -------------------^^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:27:20 + | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:22:20 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:31:21 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:25:21 | LL | const Z2_CORE: () = core::panic!(); | --------------------^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:31:21 + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:25:21 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:35:20 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:28:20 | LL | const Y_CORE: () = core::unreachable!(); | -------------------^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:35:20 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:28:20 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:39:20 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:31:20 | LL | const X_CORE: () = core::unimplemented!(); | -------------------^^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:39:20 + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:31:20 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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:43:20 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic.rs:34:20 | LL | const W_CORE: () = core::panic!(MSG); | -------------------^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'hello', $DIR/const_panic.rs:43:20 + | the evaluated program panicked at 'hello', $DIR/const_panic.rs:34:20 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs index 0eb1e3eb94e..6b03e847def 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs @@ -8,15 +8,12 @@ use core::panic::PanicInfo; const Z: () = panic!("cheese"); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Y: () = unreachable!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const X: () = unimplemented!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out #[lang = "eh_personality"] fn eh() {} diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr index 9971559e33b..2a3ad3ca180 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: any use of this value will cause an error --> $DIR/const_panic_libcore_bin.rs:9:15 | LL | const Z: () = panic!("cheese"); @@ -6,34 +6,28 @@ LL | const Z: () = panic!("cheese"); | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15 | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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_bin.rs:13:15 +error[E0080]: any use of this value will cause an error + --> $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_bin.rs:13:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (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_bin.rs:17:15 +error[E0080]: any use of this value will cause an error + --> $DIR/const_panic_libcore_bin.rs:15:15 | LL | const X: () = unimplemented!(); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:17:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index f76440298b3..dd18a98035b 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -9,8 +9,7 @@ struct PrintName; impl PrintName { const VOID: ! = panic!(); - //~^ WARN any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out + //~^ ERROR any use of this value will cause an error } fn main() { diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index d1f067df848..e186240f53a 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,4 +1,4 @@ -warning: any use of this value will cause an error +error[E0080]: any use of this value will cause an error --> $DIR/panic-assoc-never-type.rs:11:21 | LL | const VOID: ! = panic!(); @@ -6,21 +6,14 @@ LL | const VOID: ! = panic!(); | | | the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:11:21 | -note: the lint level is defined here - --> $DIR/panic-assoc-never-type.rs:4:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-assoc-never-type.rs:17:13 + --> $DIR/panic-assoc-never-type.rs:16:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index c5139c575b1..71b489d828c 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -1,15 +1,11 @@ -// build-fail - // Regression test for #66975 #![warn(const_err)] #![feature(const_panic)] #![feature(never_type)] const VOID: ! = panic!(); -//~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out +//~^ ERROR any use of this value will cause an error fn main() { let _ = VOID; - //~^ ERROR erroneous constant used } diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 2217bf1e05a..2254c3dcfdf 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -1,26 +1,13 @@ -warning: any use of this value will cause an error - --> $DIR/panic-never-type.rs:8:17 +error[E0080]: any use of this value will cause an error + --> $DIR/panic-never-type.rs:6:17 | LL | const VOID: ! = panic!(); | ----------------^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:8:17 + | the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:6:17 | -note: the lint level is defined here - --> $DIR/panic-never-type.rs:4:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> - = note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0080]: erroneous constant used - --> $DIR/panic-never-type.rs:13:13 - | -LL | let _ = VOID; - | ^^^^ referenced constant has errors + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/unwind-abort.rs b/src/test/ui/consts/const-eval/unwind-abort.rs index 10820986fa7..9bc63d9328c 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.rs +++ b/src/test/ui/consts/const-eval/unwind-abort.rs @@ -2,8 +2,7 @@ #[unwind(aborts)] const fn foo() { - panic!() //~ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out + panic!() //~ ERROR any use of this value will cause an error } const _: () = foo(); diff --git a/src/test/ui/consts/const-eval/unwind-abort.stderr b/src/test/ui/consts/const-eval/unwind-abort.stderr index 79fdd05be30..b41d786169b 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.stderr +++ b/src/test/ui/consts/const-eval/unwind-abort.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: any use of this value will cause an error --> $DIR/unwind-abort.rs:5:5 | LL | panic!() @@ -6,15 +6,13 @@ LL | panic!() | | | the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5 | inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL - | inside `_` at $DIR/unwind-abort.rs:9:15 + | inside `_` at $DIR/unwind-abort.rs:8:15 ... LL | const _: () = foo(); | -------------------- | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-unwrap.stderr b/src/test/ui/consts/const-unwrap.stderr index 0100dce5a96..95f4711cb65 100644 --- a/src/test/ui/consts/const-unwrap.stderr +++ b/src/test/ui/consts/const-unwrap.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: any use of this value will cause an error --> $SRC_DIR/core/src/option.rs:LL:COL | LL | None => panic!("called `Option::unwrap()` on a `None` value"), @@ -13,10 +13,8 @@ LL | None => panic!("called `Option::unwrap()` on a `None` value"), LL | const BAR: i32 = Option::<i32>::None.unwrap(); | ---------------------------------------------- | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/control-flow/assert.const_panic.stderr b/src/test/ui/consts/control-flow/assert.const_panic.stderr index 665b4240011..8e1a2b5eb46 100644 --- a/src/test/ui/consts/control-flow/assert.const_panic.stderr +++ b/src/test/ui/consts/control-flow/assert.const_panic.stderr @@ -1,4 +1,4 @@ -error: any use of this value will cause an error +error[E0080]: any use of this value will cause an error --> $DIR/assert.rs:10:15 | LL | const _: () = assert!(false); @@ -6,10 +6,8 @@ LL | const _: () = assert!(false); | | | the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15 | - = note: `#[deny(const_err)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/control-flow/assert.rs b/src/test/ui/consts/control-flow/assert.rs index a21f28604bd..90017fee193 100644 --- a/src/test/ui/consts/control-flow/assert.rs +++ b/src/test/ui/consts/control-flow/assert.rs @@ -10,6 +10,5 @@ const _: () = assert!(true); const _: () = assert!(false); //[stock]~^ ERROR panicking in constants is unstable //[const_panic]~^^ ERROR any use of this value will cause an error -//[const_panic]~| WARN this was previously accepted by the compiler but is being phased out fn main() {} |
