Skip to content

Commit

Permalink
Stabilize the map/value methods on ControlFlow
Browse files Browse the repository at this point in the history
And fix the stability attribute on the `pub use` in `core::ops`.
  • Loading branch information
scottmcm committed Sep 18, 2024
1 parent f7b4c72 commit ce0541e
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 20 deletions.
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(let_chains)]
#![feature(never_type)]
#![feature(rustc_attrs)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ This API is completely unstable and subject to change.
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(control_flow_enum)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir_typeck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![allow(rustc::untranslatable_diagnostic)]
#![feature(array_windows)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(never_type)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(extend_one)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(extract_if)]
#![feature(if_let_guard)]
#![feature(iter_order_by)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![allow(rustc::potential_query_instability)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(control_flow_enum)]
#![feature(coroutines)]
#![feature(decl_macro)]
#![feature(error_iter)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_trait_selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
#![feature(cfg_version)]
#![feature(control_flow_enum)]
#![feature(extract_if)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
Expand Down
18 changes: 6 additions & 12 deletions library/core/src/ops/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl<B, C> ControlFlow<B, C> {
/// assert_eq!(ControlFlow::<String, i32>::Continue(3).break_value(), None);
/// ```
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
pub fn break_value(self) -> Option<B> {
match self {
ControlFlow::Continue(..) => None,
Expand All @@ -189,11 +189,8 @@ impl<B, C> ControlFlow<B, C> {
/// Maps `ControlFlow<B, C>` to `ControlFlow<T, C>` by applying a function
/// to the break value in case it exists.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn map_break<T, F>(self, f: F) -> ControlFlow<T, C>
where
F: FnOnce(B) -> T,
{
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C> {
match self {
ControlFlow::Continue(x) => ControlFlow::Continue(x),
ControlFlow::Break(x) => ControlFlow::Break(f(x)),
Expand All @@ -213,7 +210,7 @@ impl<B, C> ControlFlow<B, C> {
/// assert_eq!(ControlFlow::<String, i32>::Continue(3).continue_value(), Some(3));
/// ```
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
pub fn continue_value(self) -> Option<C> {
match self {
ControlFlow::Continue(x) => Some(x),
Expand All @@ -224,11 +221,8 @@ impl<B, C> ControlFlow<B, C> {
/// Maps `ControlFlow<B, C>` to `ControlFlow<B, T>` by applying a function
/// to the continue value in case it exists.
#[inline]
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
pub fn map_continue<T, F>(self, f: F) -> ControlFlow<B, T>
where
F: FnOnce(C) -> T,
{
#[stable(feature = "control_flow_enum", since = "CURRENT_RUSTC_VERSION")]
pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T> {
match self {
ControlFlow::Continue(x) => ControlFlow::Continue(f(x)),
ControlFlow::Break(x) => ControlFlow::Break(x),
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce};
pub use self::bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
#[stable(feature = "op_assign_traits", since = "1.8.0")]
pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
#[stable(feature = "control_flow_enum_type", since = "1.55.0")]
pub use self::control_flow::ControlFlow;
#[unstable(feature = "coroutine_trait", issue = "43122")]
pub use self::coroutine::{Coroutine, CoroutineState};
Expand Down

0 comments on commit ce0541e

Please sign in to comment.