Stabilize const_panic

This commit is contained in:
Jacob Pratt 2021-10-04 00:33:43 -04:00
parent e737694a4d
commit bce8621983
No known key found for this signature in database
GPG Key ID: B80E19E4662B5AA4
51 changed files with 100 additions and 229 deletions

View File

@ -2,7 +2,7 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(crate_visibility_modifier)]
#![feature(format_args_capture)]
#![feature(in_band_lifetimes)]

View File

@ -887,8 +887,6 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
// At this point, we are calling a function, `callee`, whose `DefId` is known...
if is_lang_panic_fn(tcx, callee) {
self.check_op(ops::Panic);
// `begin_panic` and `panic_display` are generic functions that accept
// types other than str. Check to enforce that only str can be used in
// const-eval.

View File

@ -368,23 +368,6 @@ impl NonConstOp for MutDeref {
}
}
#[derive(Debug)]
pub struct Panic;
impl NonConstOp for Panic {
fn status_in_item(&self, _: &ConstCx<'_, '_>) -> Status {
Status::Unstable(sym::const_panic)
}
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
feature_err(
&ccx.tcx.sess.parse_sess,
sym::const_panic,
span,
&format!("panicking in {}s is unstable", ccx.const_kind()),
)
}
}
/// A call to a `panic()` lang item where the first argument is _not_ a `&str`.
#[derive(Debug)]
pub struct PanicNonStr;

View File

@ -12,7 +12,7 @@
#![feature(associated_type_bounds)]
#![feature(auto_traits)]
#![feature(bool_to_option)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(control_flow_enum)]
#![feature(core_intrinsics)]
#![feature(extend_one)]

View File

@ -297,6 +297,8 @@ declare_features! (
(accepted, arbitrary_enum_discriminant, "1.56.0", Some(60553), None),
/// Allows macro attributes to observe output of `#[derive]`.
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
/// Allows panicking during const eval (producing compile-time errors).
(accepted, const_panic, "1.57.0", Some(51999), None),
// -------------------------------------------------------------------------
// feature-group-end: accepted features

View File

@ -425,9 +425,6 @@ declare_features! (
/// Allows using the `amdgpu-kernel` ABI.
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),
/// Allows panicking during const eval (producing compile-time errors).
(active, const_panic, "1.30.0", Some(51999), None),
/// Allows `#[marker]` on certain traits allowing overlapping implementations.
(active, marker_trait_attr, "1.30.0", Some(29864), None),

View File

@ -124,7 +124,9 @@ macro_rules! newtype_index {
#[inline]
$v const fn from_usize(value: usize) -> Self {
// FIXME: replace with `assert!(value <= ($max as usize));` once `const_panic` is stable
#[cfg(not(bootstrap))]
assert!(value <= ($max as usize));
#[cfg(bootstrap)]
[()][(value > ($max as usize)) as usize];
unsafe {
Self::from_u32_unchecked(value as u32)
@ -133,7 +135,9 @@ macro_rules! newtype_index {
#[inline]
$v const fn from_u32(value: u32) -> Self {
// FIXME: replace with `assert!(value <= $max);` once `const_panic` is stable
#[cfg(not(bootstrap))]
assert!(value <= $max);
#[cfg(bootstrap)]
[()][(value > $max) as usize];
unsafe {
Self::from_u32_unchecked(value)

View File

@ -2,7 +2,7 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(exact_size_is_empty)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]

View File

@ -1,7 +1,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(map_try_insert)]

View File

@ -123,7 +123,7 @@
#![feature(const_fn_trait_bound)]
#![feature(const_impl_trait)]
#![feature(const_mut_refs)]
#![feature(const_panic)]
#![cfg_attr(bootstrap, feature(const_panic))]
#![feature(const_precise_live_drops)]
#![feature(const_raw_ptr_deref)]
#![feature(const_refs_to_cell)]

View File

@ -5,7 +5,6 @@
// Force generation of optimized mir for functions that do not reach codegen.
// compile-flags: --emit mir,link
#![feature(const_panic)]
#![feature(never_type)]
#![warn(const_err)]

View File

@ -1,11 +1,11 @@
// MIR for `no_codegen` after PreCodegen
fn no_codegen() -> () {
let mut _0: (); // return place in scope 0 at $DIR/remove-never-const.rs:19:20: 19:20
let mut _0: (); // return place in scope 0 at $DIR/remove-never-const.rs:18:20: 18:20
scope 1 {
}
bb0: {
unreachable; // scope 0 at $DIR/remove-never-const.rs:20:13: 20:33
unreachable; // scope 0 at $DIR/remove-never-const.rs:19:13: 19:33
}
}

View File

@ -1,4 +1,3 @@
#![feature(const_panic)]
#![allow(non_fmt_panics)]
#![crate_type = "lib"]

View File

@ -1,96 +1,96 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:7:15
--> $DIR/const_panic.rs:6:15
|
LL | const Z: () = std::panic!("cheese");
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:10:16
--> $DIR/const_panic.rs:9:16
|
LL | const Z2: () = std::panic!();
| ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16
| ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:13:15
--> $DIR/const_panic.rs:12:15
|
LL | const Y: () = std::unreachable!();
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:13:15
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:16:15
--> $DIR/const_panic.rs:15:15
|
LL | const X: () = std::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:16:15
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:19:15
--> $DIR/const_panic.rs:18:15
|
LL | const W: () = std::panic!(MSG);
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:19:15
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:22:16
--> $DIR/const_panic.rs:21:16
|
LL | const W2: () = std::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:22:16
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:21:16
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:25:20
--> $DIR/const_panic.rs:24:20
|
LL | const Z_CORE: () = core::panic!("cheese");
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:25:20
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:24:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:28:21
--> $DIR/const_panic.rs:27:21
|
LL | const Z2_CORE: () = core::panic!();
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:28:21
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:27:21
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:31:20
--> $DIR/const_panic.rs:30:20
|
LL | const Y_CORE: () = core::unreachable!();
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:31:20
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:30:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:34:20
--> $DIR/const_panic.rs:33:20
|
LL | const X_CORE: () = core::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:34:20
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:33:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:37:20
--> $DIR/const_panic.rs:36:20
|
LL | const W_CORE: () = core::panic!(MSG);
| ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:37:20
| ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:36:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic.rs:40:21
--> $DIR/const_panic.rs:39:21
|
LL | const W2_CORE: () = core::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:40:21
| ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:39:21
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,5 +1,4 @@
// edition:2021
#![feature(const_panic)]
#![crate_type = "lib"]
const MSG: &str = "hello";

View File

@ -1,80 +1,80 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:7:15
--> $DIR/const_panic_2021.rs:6:15
|
LL | const A: () = std::panic!("blåhaj");
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:7:15
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:6:15
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:10:15
--> $DIR/const_panic_2021.rs:9:15
|
LL | const B: () = std::panic!();
| ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:10:15
| ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:9:15
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:13:15
--> $DIR/const_panic_2021.rs:12:15
|
LL | const C: () = std::unreachable!();
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:13:15
| ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:12:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:16:15
--> $DIR/const_panic_2021.rs:15:15
|
LL | const D: () = std::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:16:15
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:15:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:19:15
--> $DIR/const_panic_2021.rs:18:15
|
LL | const E: () = std::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:19:15
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:18:15
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:22:20
--> $DIR/const_panic_2021.rs:21:20
|
LL | const A_CORE: () = core::panic!("shark");
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:22:20
| ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:21:20
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:25:20
--> $DIR/const_panic_2021.rs:24:20
|
LL | const B_CORE: () = core::panic!();
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:25:20
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:24:20
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:28:20
--> $DIR/const_panic_2021.rs:27:20
|
LL | const C_CORE: () = core::unreachable!();
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:28:20
| ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:27:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:31:20
--> $DIR/const_panic_2021.rs:30:20
|
LL | const D_CORE: () = core::unimplemented!();
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:31:20
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:30:20
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_2021.rs:34:20
--> $DIR/const_panic_2021.rs:33:20
|
LL | const E_CORE: () = core::panic!("{}", MSG);
| ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:34:20
| ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:33:20
|
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,6 +1,5 @@
#![crate_type = "bin"]
#![feature(lang_items)]
#![feature(const_panic)]
#![no_main]
#![no_std]

View File

@ -1,24 +1,24 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_libcore_bin.rs:9:15
--> $DIR/const_panic_libcore_bin.rs:8:15
|
LL | const Z: () = panic!("cheese");
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:8:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_libcore_bin.rs:12:15
--> $DIR/const_panic_libcore_bin.rs:11:15
|
LL | const Y: () = unreachable!();
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:11:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_libcore_bin.rs:15:15
--> $DIR/const_panic_libcore_bin.rs:14:15
|
LL | const X: () = unimplemented!();
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15
| ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:14:15
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,4 +1,3 @@
#![feature(const_panic)]
#![allow(non_fmt_panics)]
#![crate_type = "lib"]

View File

@ -1,14 +1,14 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const_panic_track_caller.rs:16:5
--> $DIR/const_panic_track_caller.rs:15:5
|
LL | b()
| ^^^
| |
| the evaluated program panicked at 'hey', $DIR/const_panic_track_caller.rs:16:5
| inside `c` at $DIR/const_panic_track_caller.rs:16:5
| the evaluated program panicked at 'hey', $DIR/const_panic_track_caller.rs:15:5
| inside `c` at $DIR/const_panic_track_caller.rs:15:5
...
LL | const X: u32 = c();
| --- inside `X` at $DIR/const_panic_track_caller.rs:22:16
| --- inside `X` at $DIR/const_panic_track_caller.rs:21:16
error: aborting due to previous error

View File

@ -1,10 +0,0 @@
fn main() {}
const Z: () = panic!("cheese");
//~^ ERROR panicking in constants is unstable
const Y: () = unreachable!();
//~^ ERROR panicking in constants is unstable
const X: () = unimplemented!();
//~^ ERROR panicking in constants is unstable

View File

@ -1,33 +0,0 @@
error[E0658]: panicking in constants is unstable
--> $DIR/feature-gate-const_panic.rs:3:15
|
LL | const Z: () = panic!("cheese");
| ^^^^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: panicking in constants is unstable
--> $DIR/feature-gate-const_panic.rs:6:15
|
LL | const Y: () = unreachable!();
| ^^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: panicking in constants is unstable
--> $DIR/feature-gate-const_panic.rs:9:15
|
LL | const X: () = unimplemented!();
| ^^^^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= 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 E0658`.

View File

@ -2,7 +2,6 @@
// Regression test for #66975
#![warn(const_err)]
#![feature(const_panic)]
#![feature(never_type)]
struct PrintName;

View File

@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
--> $DIR/panic-assoc-never-type.rs:11:21
--> $DIR/panic-assoc-never-type.rs:10:21
|
LL | const VOID: ! = panic!();
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:11:21
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:10:21
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,6 +1,5 @@
// Regression test for #66975
#![warn(const_err)]
#![feature(const_panic)]
#![feature(never_type)]
const VOID: ! = panic!();

View File

@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
--> $DIR/panic-never-type.rs:6:17
--> $DIR/panic-never-type.rs:5:17
|
LL | const VOID: ! = panic!();
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:6:17
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:5:17
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,4 +1,4 @@
#![feature(c_unwind, const_panic, const_extern_fn)]
#![feature(c_unwind, const_extern_fn)]
const extern "C" fn foo() {
panic!() //~ ERROR evaluation of constant value failed

View File

@ -1,7 +1,6 @@
// compile-flags: -Zmir-opt-level=0
// run-pass
#![feature(const_panic)]
#![feature(const_float_bits_conv)]
#![feature(const_float_classify)]

View File

@ -1,7 +1,6 @@
// compile-flags: -Zmir-opt-level=0
// run-pass
#![feature(const_panic)]
#![feature(const_float_bits_conv)]
#![feature(const_float_classify)]
#![feature(const_trait_impl)]

View File

@ -1,14 +1,8 @@
// Test that `assert` works when `const_panic` is enabled.
// revisions: stock const_panic
#![cfg_attr(const_panic, feature(const_panic))]
// Test that `assert` works in consts.
const _: () = assert!(true);
//[stock]~^ ERROR panicking in constants is unstable
const _: () = assert!(false);
//[stock]~^ ERROR panicking in constants is unstable
//[const_panic]~^^ ERROR evaluation of constant value failed
//~^ ERROR evaluation of constant value failed
fn main() {}

View File

@ -1,8 +1,8 @@
error[E0080]: evaluation of constant value failed
--> $DIR/assert.rs:10:15
--> $DIR/assert.rs:5:15
|
LL | const _: () = assert!(false);
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:5:15
|
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,23 +0,0 @@
error[E0658]: panicking in constants is unstable
--> $DIR/assert.rs:7:15
|
LL | const _: () = assert!(true);
| ^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0658]: panicking in constants is unstable
--> $DIR/assert.rs:10:15
|
LL | const _: () = assert!(false);
| ^^^^^^^^^^^^^^
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View File

@ -2,8 +2,6 @@
// run-pass
#![feature(const_panic)]
const X: u32 = 4;
const Y: u32 = 5;

View File

@ -2,8 +2,6 @@
// run-pass
#![feature(const_panic)]
const X: i32 = {
let mut x = 0;
let _ = true && { x = 1; false };

View File

@ -3,8 +3,6 @@
// Test that both `&&` and `||` actually short-circuit.
// Formerly, both sides were evaluated unconditionally
#![feature(const_panic)]
const TRUE: bool = true || panic!();
const FALSE: bool = false && panic!();

View File

@ -1,5 +1,5 @@
static S : u64 = { { panic!("foo"); 0 } };
//~^ ERROR panicking in statics is unstable
//~^ ERROR could not evaluate static initializer
fn main() {
println!("{:?}", S);

View File

@ -1,13 +1,11 @@
error[E0658]: panicking in statics is unstable
error[E0080]: could not evaluate static initializer
--> $DIR/issue-32829.rs:1:22
|
LL | static S : u64 = { { panic!("foo"); 0 } };
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'foo', $DIR/issue-32829.rs:1:22
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= 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 E0658`.
For more information about this error, try `rustc --explain E0080`.

View File

@ -2,8 +2,6 @@
// in a separate stage before `const`s and `statics` and so the error below is hit and
// the compiler exits before generating errors for the others.
#![feature(const_panic)]
fn main() {
let _ = [0i32; panic!(2f32)];
//~^ ERROR: argument to `panic!()` in a const context must have type `&str`

View File

@ -1,5 +1,5 @@
error: argument to `panic!()` in a const context must have type `&str`
--> $DIR/issue-66693-panic-in-array-len.rs:8:20
--> $DIR/issue-66693-panic-in-array-len.rs:6:20
|
LL | let _ = [0i32; panic!(2f32)];
| ^^^^^^^^^^^^
@ -7,10 +7,10 @@ LL | let _ = [0i32; panic!(2f32)];
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0080]: evaluation of constant value failed
--> $DIR/issue-66693-panic-in-array-len.rs:12:21
--> $DIR/issue-66693-panic-in-array-len.rs:10:21
|
LL | let _ = [false; panic!()];
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693-panic-in-array-len.rs:12:21
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693-panic-in-array-len.rs:10:21
|
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -1,8 +1,6 @@
// Tests that the compiler does not ICE when const-evaluating a `panic!()` invocation with a
// non-`&str` argument.
#![feature(const_panic)]
const _: () = panic!(1);
//~^ ERROR: argument to `panic!()` in a const context must have type `&str`

View File

@ -1,5 +1,5 @@
error: argument to `panic!()` in a const context must have type `&str`
--> $DIR/issue-66693.rs:6:15
--> $DIR/issue-66693.rs:4:15
|
LL | const _: () = panic!(1);
| ^^^^^^^^^
@ -7,7 +7,7 @@ LL | const _: () = panic!(1);
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: argument to `panic!()` in a const context must have type `&str`
--> $DIR/issue-66693.rs:9:19
--> $DIR/issue-66693.rs:7:19
|
LL | static _FOO: () = panic!(true);
| ^^^^^^^^^^^^
@ -15,7 +15,7 @@ LL | static _FOO: () = panic!(true);
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
error: argument to `panic!()` in a const context must have type `&str`
--> $DIR/issue-66693.rs:13:5
--> $DIR/issue-66693.rs:11:5
|
LL | panic!(&1);
| ^^^^^^^^^^^

View File

@ -1,5 +1,3 @@
// Note: non-`&str` panic arguments gained a separate error in PR #80734
// which is why this doesn't match the issue
struct Bug([u8; panic!("panic")]); //~ ERROR panicking in constants is unstable
struct Bug([u8; panic!("panic")]); //~ ERROR evaluation of constant value failed
fn main() {}

View File

@ -1,13 +1,11 @@
error[E0658]: panicking in constants is unstable
--> $DIR/issue-76064.rs:3:17
error[E0080]: evaluation of constant value failed
--> $DIR/issue-76064.rs:1:17
|
LL | struct Bug([u8; panic!("panic")]);
| ^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^ the evaluated program panicked at 'panic', $DIR/issue-76064.rs:1:17
|
= note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
= help: add `#![feature(const_panic)]` to the crate attributes to enable
= 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 E0658`.
For more information about this error, try `rustc --explain E0080`.

View File

@ -161,17 +161,11 @@ help: skipping check that does not even have a feature gate
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_panic` feature
--> $DIR/const_refers_to_static_cross_crate.rs:32:77
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning 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; 3 warnings emitted

View File

@ -161,17 +161,11 @@ help: skipping check that does not even have a feature gate
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: skipping check for `const_panic` feature
--> $DIR/const_refers_to_static_cross_crate.rs:32:77
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^
help: skipping check that does not even have a feature gate
--> $DIR/const_refers_to_static_cross_crate.rs:32:20
|
LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this warning 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; 3 warnings emitted

View File

@ -5,7 +5,6 @@
// normalize-stderr-64bit: "size 8" -> "size $$WORD"
#![feature(
const_panic,
core_intrinsics,
const_raw_ptr_comparison,
const_ptr_offset,

View File

@ -7,19 +7,19 @@ LL | unsafe { intrinsics::offset(self, count) }
| pointer arithmetic failed: alloc3 has size $WORD, so pointer to $TWO_WORDS bytes starting at offset 0 is out-of-bounds
| inside `ptr::const_ptr::<impl *const usize>::offset` at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
::: $DIR/ptr_comparisons.rs:61:34
::: $DIR/ptr_comparisons.rs:60:34
|
LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) };
| ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:61:34
| ------------------------------- inside `_` at $DIR/ptr_comparisons.rs:60:34
error[E0080]: evaluation of constant value failed
--> $DIR/ptr_comparisons.rs:64:33
--> $DIR/ptr_comparisons.rs:63:33
|
LL | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: alloc3 has size $WORD, so pointer to 1000 bytes starting at offset 0 is out-of-bounds
error: any use of this value will cause an error
--> $DIR/ptr_comparisons.rs:68:27
--> $DIR/ptr_comparisons.rs:67:27
|
LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 };
| --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---
@ -31,7 +31,7 @@ LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) +
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
error: any use of this value will cause an error
--> $DIR/ptr_comparisons.rs:73:27
--> $DIR/ptr_comparisons.rs:72:27
|
LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 };
| --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---

View File

@ -1,7 +1,7 @@
// compile-flags: --crate-type=lib
// check-pass
#![feature(const_ptr_is_null, const_panic)]
#![feature(const_ptr_is_null)]
const FOO: &usize = &42;

View File

@ -1,6 +1,6 @@
// check-pass
#![feature(c_unwind, const_panic, const_extern_fn)]
#![feature(c_unwind, const_extern_fn)]
// We don't unwind in const-eval anyways.
const extern "C" fn foo() {

View File

@ -1,7 +1,5 @@
// run-pass
#![feature(const_panic)]
//! Make sure that we read and write enum discriminants correctly for corner cases caused
//! by layout optimizations.

View File

@ -3,7 +3,6 @@
#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
#![feature(const_mut_refs)]
#![feature(const_panic)]
#![cfg_attr(precise, feature(const_precise_live_drops))]
struct S<'a>(&'a mut u8);