From 10e6372a83d94e69f792c1bd33c0c435e8073c61 Mon Sep 17 00:00:00 2001 From: Slanterns Date: Wed, 18 Oct 2023 07:35:23 +0800 Subject: [PATCH 1/2] Stabilize `result_option_inspect` --- library/core/src/option.rs | 9 ++------- library/core/src/result.rs | 8 ++------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index bdaeea666221c..10efd9061c0f3 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1072,8 +1072,6 @@ impl Option { /// # Examples /// /// ``` - /// #![feature(result_option_inspect)] - /// /// let v = vec![1, 2, 3, 4, 5]; /// /// // prints "got: 4" @@ -1083,11 +1081,8 @@ impl Option { /// let x: Option<&usize> = v.get(5).inspect(|x| println!("got: {x}")); /// ``` #[inline] - #[unstable(feature = "result_option_inspect", issue = "91345")] - pub fn inspect(self, f: F) -> Self - where - F: FnOnce(&T), - { + #[stable(feature = "result_option_inspect", since = "CURRENT_RUSTC_VERSION")] + pub fn inspect(self, f: F) -> Self { if let Some(ref x) = self { f(x); } diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 50127b27f8bfc..90c346e98bccf 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -835,8 +835,6 @@ impl Result { /// # Examples /// /// ``` - /// #![feature(result_option_inspect)] - /// /// let x: u8 = "4" /// .parse::() /// .inspect(|x| println!("original: {x}")) @@ -844,7 +842,7 @@ impl Result { /// .expect("failed to parse number"); /// ``` #[inline] - #[unstable(feature = "result_option_inspect", issue = "91345")] + #[stable(feature = "result_option_inspect", since = "CURRENT_RUSTC_VERSION")] pub fn inspect(self, f: F) -> Self { if let Ok(ref t) = self { f(t); @@ -858,8 +856,6 @@ impl Result { /// # Examples /// /// ``` - /// #![feature(result_option_inspect)] - /// /// use std::{fs, io}; /// /// fn read() -> io::Result { @@ -868,7 +864,7 @@ impl Result { /// } /// ``` #[inline] - #[unstable(feature = "result_option_inspect", issue = "91345")] + #[stable(feature = "result_option_inspect", since = "CURRENT_RUSTC_VERSION")] pub fn inspect_err(self, f: F) -> Self { if let Err(ref e) = self { f(e); From ed512e91d0318cb06ea2b3729198e64090b5648e Mon Sep 17 00:00:00 2001 From: Slanterns Date: Wed, 18 Oct 2023 07:35:57 +0800 Subject: [PATCH 2/2] Remove `#![feature(result_option_inspect)]` from the compiler --- compiler/rustc_errors/src/lib.rs | 1 - compiler/rustc_middle/src/lib.rs | 1 - compiler/rustc_trait_selection/src/lib.rs | 1 - 3 files changed, 3 deletions(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index da74ee6391ae2..fad3cb202eec1 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -10,7 +10,6 @@ #![feature(if_let_guard)] #![feature(let_chains)] #![feature(never_type)] -#![feature(result_option_inspect)] #![feature(rustc_attrs)] #![feature(yeet_expr)] #![feature(try_blocks)] diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index dee18dc11628c..cd0944f6985ab 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -58,7 +58,6 @@ #![feature(extract_if)] #![feature(intra_doc_pointers)] #![feature(yeet_expr)] -#![feature(result_option_inspect)] #![feature(const_option)] #![feature(trait_alias)] #![feature(ptr_alignment_type)] diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 5ba29f878558f..6fab9441bdc26 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -21,7 +21,6 @@ #![feature(let_chains)] #![feature(if_let_guard)] #![feature(never_type)] -#![feature(result_option_inspect)] #![feature(type_alias_impl_trait)] #![feature(min_specialization)] #![recursion_limit = "512"] // For rustdoc