Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize Option::expect_none(msg) and Option::unwrap_none() #73077

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<T> Option<T> {
///
/// [`None`]: #variant.None
#[must_use = "if you intended to assert that this doesn't have a value, consider \
`.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"]
`.unwrap_none()` instead"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_none(&self) -> bool {
Expand Down Expand Up @@ -1066,8 +1066,6 @@ impl<T: fmt::Debug> Option<T> {
/// # Examples
///
/// ```
/// #![feature(option_expect_none)]
///
/// use std::collections::HashMap;
/// let mut squares = HashMap::new();
/// for i in -10..=10 {
Expand All @@ -1077,8 +1075,6 @@ impl<T: fmt::Debug> Option<T> {
/// ```
///
/// ```{.should_panic}
/// #![feature(option_expect_none)]
///
/// use std::collections::HashMap;
/// let mut sqrts = HashMap::new();
/// for i in -10..=10 {
Expand All @@ -1089,7 +1085,7 @@ impl<T: fmt::Debug> Option<T> {
/// ```
#[inline]
#[track_caller]
#[unstable(feature = "option_expect_none", reason = "newly added", issue = "62633")]
#[stable(feature = "option_expect_none", since = "1.45.0")]
pub fn expect_none(self, msg: &str) {
if let Some(val) = self {
expect_none_failed(msg, &val);
Expand All @@ -1109,8 +1105,6 @@ impl<T: fmt::Debug> Option<T> {
/// # Examples
///
/// ```
/// #![feature(option_unwrap_none)]
///
/// use std::collections::HashMap;
/// let mut squares = HashMap::new();
/// for i in -10..=10 {
Expand All @@ -1120,8 +1114,6 @@ impl<T: fmt::Debug> Option<T> {
/// ```
///
/// ```{.should_panic}
/// #![feature(option_unwrap_none)]
///
/// use std::collections::HashMap;
/// let mut sqrts = HashMap::new();
/// for i in -10..=10 {
Expand All @@ -1132,7 +1124,7 @@ impl<T: fmt::Debug> Option<T> {
/// ```
#[inline]
#[track_caller]
#[unstable(feature = "option_unwrap_none", reason = "newly added", issue = "62633")]
#[stable(feature = "option_unwrap_none", since = "1.45.0")]
pub fn unwrap_none(self) {
if let Some(val) = self {
expect_none_failed("called `Option::unwrap_none()` on a `Some` value", &val);
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#![feature(unwrap_infallible)]
#![feature(leading_trailing_ones)]
#![feature(const_forget)]
#![feature(option_unwrap_none)]
#![feature(peekable_next_if)]

extern crate test;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#![feature(marker_trait_attr)]
#![feature(extern_types)]
#![feature(nll)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![feature(range_is_empty)]
#![feature(specialization)] // FIXME: min_specialization does not work
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Rust MIR: a lowered representation of Rust.
#![feature(range_is_empty)]
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![recursion_limit = "256"]

Expand Down
1 change: 0 additions & 1 deletion src/test/ui/rfc-2091-track-caller/std-panic-locations.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
// ignore-wasm32-bare compiled with panic=abort by default

#![feature(option_expect_none, option_unwrap_none)]
#![allow(unconditional_panic)]

//! Test that panic locations for `#[track_caller]` functions in std have the correct
Expand Down