Make `Option::expect` unstably const
Tracking issue: #67441
#[inline]
#[track_caller]
#[stable(feature = "rust1", since = "1.0.0")]
- pub fn expect(self, msg: &str) -> T {
+ #[rustc_const_unstable(feature = "const_option", issue = "67441")]
+ pub const fn expect(self, msg: &str) -> T {
match self {
Some(val) => val,
None => expect_failed(msg),
#[inline(never)]
#[cold]
#[track_caller]
-fn expect_failed(msg: &str) -> ! {
+const fn expect_failed(msg: &str) -> ! {
panic!("{}", msg)
}