diff options
Diffstat (limited to 'library')
| -rw-r--r-- | library/core/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/core/src/macros/mod.rs | 9 | ||||
| -rw-r--r-- | library/core/src/option.rs | 6 |
3 files changed, 11 insertions, 5 deletions
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 67f77f14a6e..32a5fd9c481 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -141,6 +141,7 @@ #![feature(const_type_id)] #![feature(const_type_name)] #![feature(const_default_impls)] +#![feature(core_panic)] #![feature(duration_consts_float)] #![feature(maybe_uninit_uninit_array)] #![feature(ptr_metadata)] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index b18508186a6..af6718df653 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -589,9 +589,10 @@ macro_rules! writeln { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] +#[allow_internal_unstable(core_panic)] macro_rules! unreachable { () => ({ - $crate::panic!("internal error: entered unreachable code") + $crate::panicking::panic("internal error: entered unreachable code") }); ($msg:expr $(,)?) => ({ $crate::unreachable!("{}", $msg) @@ -674,8 +675,9 @@ macro_rules! unreachable { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] +#[allow_internal_unstable(core_panic)] macro_rules! unimplemented { - () => ($crate::panic!("not implemented")); + () => ($crate::panicking::panic("not implemented")); ($($arg:tt)+) => ($crate::panic!("not implemented: {}", $crate::format_args!($($arg)+))); } @@ -735,8 +737,9 @@ macro_rules! unimplemented { /// ``` #[macro_export] #[stable(feature = "todo_macro", since = "1.40.0")] +#[allow_internal_unstable(core_panic)] macro_rules! todo { - () => ($crate::panic!("not yet implemented")); + () => ($crate::panicking::panic("not yet implemented")); ($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); } diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 8969c6f6171..e6312b8b2d9 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -501,6 +501,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::iter::{FromIterator, FusedIterator, TrustedLen}; +use crate::panicking::{panic, panic_str}; use crate::pin::Pin; use crate::{ convert, hint, mem, @@ -755,7 +756,7 @@ impl<T> Option<T> { pub const fn unwrap(self) -> T { match self { Some(val) => val, - None => panic!("called `Option::unwrap()` on a `None` value"), + None => panic("called `Option::unwrap()` on a `None` value"), } } @@ -1815,8 +1816,9 @@ impl<T, E> Option<Result<T, E>> { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] +#[rustc_const_unstable(feature = "const_option", issue = "67441")] const fn expect_failed(msg: &str) -> ! { - panic!("{}", msg) + panic_str(msg) } ///////////////////////////////////////////////////////////////////////////// |
