Skip to content

Commit 452cfcc

Browse files
committed
Auto merge of rust-lang#74956 - ecstatic-morse:const-option-unwrap, r=oli-obk
Make `Option::unwrap` unstably const This is lumped into the `const_option` feature gate (rust-lang#67441), which enables a potpourri of `Option` methods. cc @rust-lang/wg-const-eval r? @oli-obk
2 parents 9b2ad66 + d64dea7 commit 452cfcc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#![feature(const_fn_union)]
8282
#![feature(const_generics)]
8383
#![feature(const_option)]
84+
#![feature(const_precise_live_drops)]
8485
#![feature(const_ptr_offset)]
8586
#![feature(const_ptr_offset_from)]
8687
#![feature(const_raw_ptr_comparison)]

core/src/option.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ impl<T> Option<T> {
380380
#[inline]
381381
#[track_caller]
382382
#[stable(feature = "rust1", since = "1.0.0")]
383-
pub fn unwrap(self) -> T {
383+
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
384+
pub const fn unwrap(self) -> T {
384385
match self {
385386
Some(val) => val,
386387
None => panic!("called `Option::unwrap()` on a `None` value"),

0 commit comments

Comments
 (0)