Skip to content

Commit 94cd025

Browse files
authored
Rollup merge of rust-lang#90269 - woppopo:const_option_expect, r=yaahc
Make `Option::expect` unstably const Tracking issue: rust-lang#67441
2 parents 31003a3 + 7430b22 commit 94cd025

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/core/src/option.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ impl<T> Option<T> {
703703
#[inline]
704704
#[track_caller]
705705
#[stable(feature = "rust1", since = "1.0.0")]
706-
pub fn expect(self, msg: &str) -> T {
706+
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
707+
pub const fn expect(self, msg: &str) -> T {
707708
match self {
708709
Some(val) => val,
709710
None => expect_failed(msg),
@@ -1658,7 +1659,7 @@ impl<T, E> Option<Result<T, E>> {
16581659
#[inline(never)]
16591660
#[cold]
16601661
#[track_caller]
1661-
fn expect_failed(msg: &str) -> ! {
1662+
const fn expect_failed(msg: &str) -> ! {
16621663
panic!("{}", msg)
16631664
}
16641665

0 commit comments

Comments
 (0)