about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-08-26 09:51:44 +0900
committerGitHub <noreply@github.com>2022-08-26 09:51:44 +0900
commitba31a9b5059d93bcd6b2a0472fec769f0ab16ef5 (patch)
treea198b69f96341b2e0704ca9bf7c089bad4a65343
parente193f4697f11aed89329177d04c84bcd9ce1b424 (diff)
parent39809c5f68e5618dc4183cfa95499df70357e617 (diff)
downloadrust-ba31a9b5059d93bcd6b2a0472fec769f0ab16ef5.tar.gz
rust-ba31a9b5059d93bcd6b2a0472fec769f0ab16ef5.zip
Rollup merge of #100604 - dtolnay:okorerr, r=m-ou-se
Remove unstable Result::into_ok_or_err

Pending FCP: https://github.com/rust-lang/rust/issues/82223#issuecomment-1214920203

```@rustbot``` label +waiting-on-fcp
-rw-r--r--compiler/rustc_codegen_gcc/patches/0024-core-Disable-portable-simd-test.patch1
-rw-r--r--compiler/rustc_transmute/src/layout/tree.rs18
-rw-r--r--compiler/rustc_transmute/src/lib.rs9
-rw-r--r--library/core/src/result.rs34
-rw-r--r--library/core/tests/lib.rs1
-rw-r--r--library/core/tests/result.rs9
6 files changed, 11 insertions, 61 deletions
diff --git a/compiler/rustc_codegen_gcc/patches/0024-core-Disable-portable-simd-test.patch b/compiler/rustc_codegen_gcc/patches/0024-core-Disable-portable-simd-test.patch
index d5fa1cec061..c59a40df039 100644
--- a/compiler/rustc_codegen_gcc/patches/0024-core-Disable-portable-simd-test.patch
+++ b/compiler/rustc_codegen_gcc/patches/0024-core-Disable-portable-simd-test.patch
@@ -14,7 +14,6 @@ index 06c7be0..359e2e7 100644
 @@ -75,7 +75,6 @@
  #![feature(never_type)]
  #![feature(unwrap_infallible)]
- #![feature(result_into_ok_or_err)]
 -#![feature(portable_simd)]
  #![feature(ptr_metadata)]
  #![feature(once_cell)]
diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs
index 70b3ba02b05..93cab7ca533 100644
--- a/compiler/rustc_transmute/src/layout/tree.rs
+++ b/compiler/rustc_transmute/src/layout/tree.rs
@@ -1,4 +1,5 @@
 use super::{Byte, Def, Ref};
+use std::ops::ControlFlow;
 
 #[cfg(test)]
 mod tests;
@@ -86,17 +87,18 @@ where
         F: Fn(D) -> bool,
     {
         match self {
-            Self::Seq(elts) => elts
-                .into_iter()
-                .map(|elt| elt.prune(f))
-                .try_fold(Tree::unit(), |elts, elt| {
+            Self::Seq(elts) => match elts.into_iter().map(|elt| elt.prune(f)).try_fold(
+                Tree::unit(),
+                |elts, elt| {
                     if elt == Tree::uninhabited() {
-                        Err(Tree::uninhabited())
+                        ControlFlow::Break(Tree::uninhabited())
                     } else {
-                        Ok(elts.then(elt))
+                        ControlFlow::Continue(elts.then(elt))
                     }
-                })
-                .into_ok_or_err(),
+                },
+            ) {
+                ControlFlow::Break(node) | ControlFlow::Continue(node) => node,
+            },
             Self::Alt(alts) => alts
                 .into_iter()
                 .map(|alt| alt.prune(f))
diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs
index 32e6cb9c64f..89b1ce5abe9 100644
--- a/compiler/rustc_transmute/src/lib.rs
+++ b/compiler/rustc_transmute/src/lib.rs
@@ -1,11 +1,4 @@
-#![feature(
-    alloc_layout_extra,
-    control_flow_enum,
-    decl_macro,
-    iterator_try_reduce,
-    never_type,
-    result_into_ok_or_err
-)]
+#![feature(alloc_layout_extra, control_flow_enum, decl_macro, iterator_try_reduce, never_type)]
 #![allow(dead_code, unused_variables)]
 #![deny(rustc::untranslatable_diagnostic)]
 #![deny(rustc::diagnostic_outside_of_impl)]
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 75dcb4cdba9..76eaa191f78 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -1776,40 +1776,6 @@ impl<T, E> Result<Result<T, E>, E> {
     }
 }
 
-impl<T> Result<T, T> {
-    /// Returns the [`Ok`] value if `self` is `Ok`, and the [`Err`] value if
-    /// `self` is `Err`.
-    ///
-    /// In other words, this function returns the value (the `T`) of a
-    /// `Result<T, T>`, regardless of whether or not that result is `Ok` or
-    /// `Err`.
-    ///
-    /// This can be useful in conjunction with APIs such as
-    /// [`Atomic*::compare_exchange`], or [`slice::binary_search`], but only in
-    /// cases where you don't care if the result was `Ok` or not.
-    ///
-    /// [`Atomic*::compare_exchange`]: crate::sync::atomic::AtomicBool::compare_exchange
-    ///
-    /// # Examples
-    ///
-    /// ```
-    /// #![feature(result_into_ok_or_err)]
-    /// let ok: Result<u32, u32> = Ok(3);
-    /// let err: Result<u32, u32> = Err(4);
-    ///
-    /// assert_eq!(ok.into_ok_or_err(), 3);
-    /// assert_eq!(err.into_ok_or_err(), 4);
-    /// ```
-    #[inline]
-    #[unstable(feature = "result_into_ok_or_err", reason = "newly added", issue = "82223")]
-    pub const fn into_ok_or_err(self) -> T {
-        match self {
-            Ok(v) => v,
-            Err(v) => v,
-        }
-    }
-}
-
 // This is a separate function to reduce the code size of the methods
 #[cfg(not(feature = "panic_immediate_abort"))]
 #[inline(never)]
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 59510d3cc2a..c315f3a7975 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -75,7 +75,6 @@
 #![feature(const_pin)]
 #![feature(never_type)]
 #![feature(unwrap_infallible)]
-#![feature(result_into_ok_or_err)]
 #![feature(pointer_byte_offsets)]
 #![feature(portable_simd)]
 #![feature(ptr_metadata)]
diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs
index 103e8cc3a96..50926da3ce7 100644
--- a/library/core/tests/result.rs
+++ b/library/core/tests/result.rs
@@ -96,15 +96,6 @@ fn test_unwrap_or() {
 }
 
 #[test]
-fn test_ok_or_err() {
-    let ok: Result<isize, isize> = Ok(100);
-    let err: Result<isize, isize> = Err(200);
-
-    assert_eq!(ok.into_ok_or_err(), 100);
-    assert_eq!(err.into_ok_or_err(), 200);
-}
-
-#[test]
 fn test_unwrap_or_else() {
     fn handler(msg: &'static str) -> isize {
         if msg == "I got this." { 50 } else { panic!("BadBad") }