Skip to content

Commit f52eb4c

Browse files
committed
Add const-stability to panicking::panic_* fns
This allows us to use `panic!` and friends in a const-stable context within libcore.
1 parent 390bb34 commit f52eb4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/panicking.rs

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub const fn panic(expr: &'static str) -> ! {
5151
#[inline]
5252
#[track_caller]
5353
#[lang = "panic_str"] // needed for `non-fmt-panics` lint
54+
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
5455
pub const fn panic_str(expr: &str) -> ! {
5556
panic_display(&expr);
5657
}
@@ -59,6 +60,7 @@ pub const fn panic_str(expr: &str) -> ! {
5960
#[track_caller]
6061
#[lang = "panic_display"] // needed for const-evaluated panics
6162
#[rustc_do_not_const_check] // hooked by const-eval
63+
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
6264
pub const fn panic_display<T: fmt::Display>(x: &T) -> ! {
6365
panic_fmt(format_args!("{}", *x));
6466
}
@@ -89,6 +91,7 @@ fn panic_bounds_check(index: usize, len: usize) -> ! {
8991
#[track_caller]
9092
#[lang = "panic_fmt"] // needed for const-evaluated panics
9193
#[rustc_do_not_const_check] // hooked by const-eval
94+
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
9295
pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
9396
if cfg!(feature = "panic_immediate_abort") {
9497
super::intrinsics::abort()
@@ -109,6 +112,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
109112

110113
/// This function is used instead of panic_fmt in const eval.
111114
#[lang = "const_panic_fmt"]
115+
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
112116
pub const fn const_panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
113117
if let Some(msg) = fmt.as_str() {
114118
panic_str(msg);

0 commit comments

Comments
 (0)