about summary refs log tree commit diff
path: root/library/core/src/ops
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2021-06-24 12:47:33 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2021-06-28 11:30:49 -0400
commit06661ba7591b1531555cd084f75540d99ef35ac5 (patch)
tree34f973a21aab174c82621ccc33d53525e917970c /library/core/src/ops
parent17ea490310ba7c836c93fe1b7002555b3bea5eb1 (diff)
downloadrust-06661ba7591b1531555cd084f75540d99ef35ac5.tar.gz
rust-06661ba7591b1531555cd084f75540d99ef35ac5.zip
Update to new bootstrap compiler
Diffstat (limited to 'library/core/src/ops')
-rw-r--r--library/core/src/ops/control_flow.rs48
-rw-r--r--library/core/src/ops/mod.rs11
-rw-r--r--library/core/src/ops/try.rs61
-rw-r--r--library/core/src/ops/try_trait.rs8
4 files changed, 6 insertions, 122 deletions
diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs
index c26b5c67710..c2270c864df 100644
--- a/library/core/src/ops/control_flow.rs
+++ b/library/core/src/ops/control_flow.rs
@@ -51,39 +51,17 @@ use crate::{convert, ops};
 pub enum ControlFlow<B, C = ()> {
     /// Move on to the next phase of the operation as normal.
     #[stable(feature = "control_flow_enum_type", since = "1.55.0")]
-    #[cfg_attr(not(bootstrap), lang = "Continue")]
+    #[lang = "Continue"]
     Continue(C),
     /// Exit the operation without running subsequent phases.
     #[stable(feature = "control_flow_enum_type", since = "1.55.0")]
-    #[cfg_attr(not(bootstrap), lang = "Break")]
+    #[lang = "Break"]
     Break(B),
     // Yes, the order of the variants doesn't match the type parameters.
     // They're in this order so that `ControlFlow<A, B>` <-> `Result<B, A>`
     // is a no-op conversion in the `Try` implementation.
 }
 
-#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
-#[cfg(bootstrap)]
-impl<B, C> ops::TryV1 for ControlFlow<B, C> {
-    type Output = C;
-    type Error = B;
-    #[inline]
-    fn into_result(self) -> Result<Self::Output, Self::Error> {
-        match self {
-            ControlFlow::Continue(y) => Ok(y),
-            ControlFlow::Break(x) => Err(x),
-        }
-    }
-    #[inline]
-    fn from_error(v: Self::Error) -> Self {
-        ControlFlow::Break(v)
-    }
-    #[inline]
-    fn from_ok(v: Self::Output) -> Self {
-        ControlFlow::Continue(v)
-    }
-}
-
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 impl<B, C> ops::TryV2 for ControlFlow<B, C> {
     type Output = C;
@@ -184,31 +162,9 @@ impl<B, C> ControlFlow<B, C> {
     }
 }
 
-#[cfg(bootstrap)]
-impl<R: ops::TryV1> ControlFlow<R, R::Output> {
-    /// Create a `ControlFlow` from any type implementing `Try`.
-    #[inline]
-    pub(crate) fn from_try(r: R) -> Self {
-        match R::into_result(r) {
-            Ok(v) => ControlFlow::Continue(v),
-            Err(v) => ControlFlow::Break(R::from_error(v)),
-        }
-    }
-
-    /// Convert a `ControlFlow` into any type implementing `Try`;
-    #[inline]
-    pub(crate) fn into_try(self) -> R {
-        match self {
-            ControlFlow::Continue(v) => R::from_ok(v),
-            ControlFlow::Break(v) => v,
-        }
-    }
-}
-
 /// These are used only as part of implementing the iterator adapters.
 /// They have mediocre names and non-obvious semantics, so aren't
 /// currently on a path to potential stabilization.
-#[cfg(not(bootstrap))]
 impl<R: ops::TryV2> ControlFlow<R, R::Output> {
     /// Create a `ControlFlow` from any type implementing `Try`.
     #[inline]
diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs
index 139a8c0eec9..85e04740d96 100644
--- a/library/core/src/ops/mod.rs
+++ b/library/core/src/ops/mod.rs
@@ -147,8 +147,6 @@ mod function;
 mod generator;
 mod index;
 mod range;
-#[cfg(bootstrap)]
-mod r#try;
 mod try_trait;
 mod unsize;
 
@@ -183,19 +181,10 @@ pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
 #[stable(feature = "inclusive_range", since = "1.26.0")]
 pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
 
-#[unstable(feature = "try_trait", issue = "42327")]
-#[cfg(bootstrap)]
-pub use self::r#try::Try;
-
-#[unstable(feature = "try_trait_transition", reason = "for bootstrap", issue = "none")]
-#[cfg(bootstrap)]
-pub(crate) use self::r#try::Try as TryV1;
-
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 pub use self::try_trait::FromResidual;
 
 #[unstable(feature = "try_trait_v2", issue = "84277")]
-#[cfg(not(bootstrap))]
 pub use self::try_trait::Try;
 
 #[unstable(feature = "try_trait_transition", reason = "for bootstrap", issue = "none")]
diff --git a/library/core/src/ops/try.rs b/library/core/src/ops/try.rs
deleted file mode 100644
index 9d659e78d3c..00000000000
--- a/library/core/src/ops/try.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-/// A trait for customizing the behavior of the `?` operator.
-///
-/// A type implementing `Try` is one that has a canonical way to view it
-/// in terms of a success/failure dichotomy. This trait allows both
-/// extracting those success or failure values from an existing instance and
-/// creating a new instance from a success or failure value.
-#[unstable(feature = "try_trait", issue = "42327")]
-#[rustc_on_unimplemented(
-    on(
-        all(
-            any(from_method = "from_error", from_method = "from_ok"),
-            from_desugaring = "QuestionMark"
-        ),
-        message = "the `?` operator can only be used in {ItemContext} \
-                    that returns `Result` or `Option` \
-                    (or another type that implements `{Try}`)",
-        label = "cannot use the `?` operator in {ItemContext} that returns `{Self}`",
-        enclosing_scope = "this function should return `Result` or `Option` to accept `?`"
-    ),
-    on(
-        all(from_method = "into_result", from_desugaring = "QuestionMark"),
-        message = "the `?` operator can only be applied to values \
-                    that implement `{Try}`",
-        label = "the `?` operator cannot be applied to type `{Self}`"
-    )
-)]
-#[doc(alias = "?")]
-#[cfg_attr(bootstrap, lang = "try")]
-pub trait Try {
-    /// The type of this value when viewed as successful.
-    #[unstable(feature = "try_trait", issue = "42327")]
-    type Output; // This no longer follows its RFC, but is only used in bootstrap.
-    /// The type of this value when viewed as failed.
-    #[unstable(feature = "try_trait", issue = "42327")]
-    type Error;
-
-    /// Applies the "?" operator. A return of `Ok(t)` means that the
-    /// execution should continue normally, and the result of `?` is the
-    /// value `t`. A return of `Err(e)` means that execution should branch
-    /// to the innermost enclosing `catch`, or return from the function.
-    ///
-    /// If an `Err(e)` result is returned, the value `e` will be "wrapped"
-    /// in the return type of the enclosing scope (which must itself implement
-    /// `Try`). Specifically, the value `X::from_error(From::from(e))`
-    /// is returned, where `X` is the return type of the enclosing function.
-    #[cfg_attr(bootstrap, lang = "into_result")]
-    #[unstable(feature = "try_trait", issue = "42327")]
-    fn into_result(self) -> Result<Self::Output, Self::Error>;
-
-    /// Wrap an error value to construct the composite result. For example,
-    /// `Result::Err(x)` and `Result::from_error(x)` are equivalent.
-    #[cfg_attr(bootstrap, lang = "from_error")]
-    #[unstable(feature = "try_trait", issue = "42327")]
-    fn from_error(v: Self::Error) -> Self;
-
-    /// Wrap an OK value to construct the composite result. For example,
-    /// `Result::Ok(x)` and `Result::from_ok(x)` are equivalent.
-    #[cfg_attr(bootstrap, lang = "from_ok")]
-    #[unstable(feature = "try_trait", issue = "42327")]
-    fn from_ok(v: Self::Output) -> Self;
-}
diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs
index 0eec52a8701..bd46fb6f2cf 100644
--- a/library/core/src/ops/try_trait.rs
+++ b/library/core/src/ops/try_trait.rs
@@ -128,7 +128,7 @@ use crate::ops::ControlFlow;
     )
 )]
 #[doc(alias = "?")]
-#[cfg_attr(not(bootstrap), lang = "Try")]
+#[lang = "Try"]
 pub trait Try: FromResidual {
     /// The type of the value produced by `?` when *not* short-circuiting.
     #[unstable(feature = "try_trait_v2", issue = "84277")]
@@ -186,7 +186,7 @@ pub trait Try: FromResidual {
     /// let r = std::iter::empty().try_fold(4, |_, ()| -> Option<_> { unreachable!() });
     /// assert_eq!(r, Some(4));
     /// ```
-    #[cfg_attr(not(bootstrap), lang = "from_output")]
+    #[lang = "from_output"]
     #[unstable(feature = "try_trait_v2", issue = "84277")]
     fn from_output(output: Self::Output) -> Self;
 
@@ -213,7 +213,7 @@ pub trait Try: FromResidual {
     ///     ControlFlow::Break(ControlFlow::Break(3)),
     /// );
     /// ```
-    #[cfg_attr(not(bootstrap), lang = "branch")]
+    #[lang = "branch"]
     #[unstable(feature = "try_trait_v2", issue = "84277")]
     fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
 }
@@ -334,7 +334,7 @@ pub trait FromResidual<R = <Self as Try>::Residual> {
     ///     ControlFlow::Break(5),
     /// );
     /// ```
-    #[cfg_attr(not(bootstrap), lang = "from_residual")]
+    #[lang = "from_residual"]
     #[unstable(feature = "try_trait_v2", issue = "84277")]
     fn from_residual(residual: R) -> Self;
 }