about summary refs log tree commit diff
path: root/library/core/src
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
parent17ea490310ba7c836c93fe1b7002555b3bea5eb1 (diff)
downloadrust-06661ba7591b1531555cd084f75540d99ef35ac5.tar.gz
rust-06661ba7591b1531555cd084f75540d99ef35ac5.zip
Update to new bootstrap compiler
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/iter/adapters/peekable.rs23
-rw-r--r--library/core/src/iter/traits/iterator.rs27
-rw-r--r--library/core/src/lib.rs3
-rw-r--r--library/core/src/marker.rs2
-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
-rw-r--r--library/core/src/option.rs32
-rw-r--r--library/core/src/result.rs22
-rw-r--r--library/core/src/task/poll.rs53
11 files changed, 7 insertions, 283 deletions
diff --git a/library/core/src/iter/adapters/peekable.rs b/library/core/src/iter/adapters/peekable.rs
index 69bd2996efe..91fa1a9ad35 100644
--- a/library/core/src/iter/adapters/peekable.rs
+++ b/library/core/src/iter/adapters/peekable.rs
@@ -130,7 +130,6 @@ where
     }
 
     #[inline]
-    #[cfg(not(bootstrap))]
     fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
     where
         Self: Sized,
@@ -151,28 +150,6 @@ where
     }
 
     #[inline]
-    #[cfg(bootstrap)]
-    fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
-    where
-        Self: Sized,
-        F: FnMut(B, Self::Item) -> R,
-        R: Try<Output = B>,
-    {
-        let _use_the_import: ControlFlow<()>;
-        match self.peeked.take() {
-            Some(None) => try { init },
-            Some(Some(v)) => match self.iter.try_rfold(init, &mut f).into_result() {
-                Ok(acc) => f(acc, v),
-                Err(e) => {
-                    self.peeked = Some(Some(v));
-                    R::from_error(e)
-                }
-            },
-            None => self.iter.try_rfold(init, f),
-        }
-    }
-
-    #[inline]
     fn rfold<Acc, Fold>(self, init: Acc, mut fold: Fold) -> Acc
     where
         Fold: FnMut(Acc, Self::Item) -> Acc,
diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs
index 41d9993abaa..0032e8c3e47 100644
--- a/library/core/src/iter/traits/iterator.rs
+++ b/library/core/src/iter/traits/iterator.rs
@@ -2439,7 +2439,6 @@ pub trait Iterator {
     /// ```
     #[inline]
     #[unstable(feature = "try_find", reason = "new API", issue = "63178")]
-    #[cfg(not(bootstrap))]
     fn try_find<F, R, E>(&mut self, f: F) -> Result<Option<Self::Item>, E>
     where
         Self: Sized,
@@ -2466,32 +2465,6 @@ pub trait Iterator {
         self.try_fold((), check(f)).break_value().transpose()
     }
 
-    /// We're bootstrapping.
-    #[inline]
-    #[unstable(feature = "try_find", reason = "new API", issue = "63178")]
-    #[cfg(bootstrap)]
-    fn try_find<F, R>(&mut self, f: F) -> Result<Option<Self::Item>, R::Error>
-    where
-        Self: Sized,
-        F: FnMut(&Self::Item) -> R,
-        R: Try<Output = bool>,
-    {
-        #[inline]
-        fn check<F, T, R>(mut f: F) -> impl FnMut((), T) -> ControlFlow<Result<T, R::Error>>
-        where
-            F: FnMut(&T) -> R,
-            R: Try<Output = bool>,
-        {
-            move |(), x| match f(&x).into_result() {
-                Ok(false) => ControlFlow::CONTINUE,
-                Ok(true) => ControlFlow::Break(Ok(x)),
-                Err(x) => ControlFlow::Break(Err(x)),
-            }
-        }
-
-        self.try_fold((), check(f)).break_value().transpose()
-    }
-
     /// Searches for an element in an iterator, returning its index.
     ///
     /// `position()` takes a closure that returns `true` or `false`. It applies
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 73959291481..7fa8202e5d6 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -87,7 +87,6 @@
 #![feature(const_fn_floating_point_arithmetic)]
 #![feature(const_fn_fn_ptr_basics)]
 #![feature(const_fn_trait_bound)]
-#![cfg_attr(bootstrap, feature(const_fn))]
 #![feature(const_option)]
 #![feature(const_precise_live_drops)]
 #![feature(const_ptr_offset)]
@@ -112,7 +111,6 @@
 #![feature(doc_cfg)]
 #![feature(doc_notable_trait)]
 #![feature(duration_consts_2)]
-#![cfg_attr(bootstrap, feature(extended_key_value_attributes))]
 #![feature(extern_types)]
 #![feature(fundamental)]
 #![feature(intra_doc_pointers)]
@@ -165,7 +163,6 @@
 #![feature(slice_ptr_get)]
 #![feature(no_niche)] // rust-lang/rust#68303
 #![feature(no_coverage)] // rust-lang/rust#84605
-#![cfg_attr(bootstrap, feature(target_feature_11))]
 #![deny(unsafe_op_in_unsafe_fn)]
 #![deny(or_patterns_back_compat)]
 
diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs
index 2b240455043..271565693d6 100644
--- a/library/core/src/marker.rs
+++ b/library/core/src/marker.rs
@@ -31,7 +31,7 @@ use crate::hash::Hasher;
 /// [ub]: ../../reference/behavior-considered-undefined.html
 #[stable(feature = "rust1", since = "1.0.0")]
 #[cfg_attr(not(test), rustc_diagnostic_item = "send_trait")]
-#[cfg_attr(not(bootstrap), lang = "send")]
+#[lang = "send"]
 #[rustc_on_unimplemented(
     message = "`{Self}` cannot be sent between threads safely",
     label = "`{Self}` cannot be sent between threads safely"
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;
 }
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index aedfe88f688..13de1cb3092 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -1636,38 +1636,6 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
     }
 }
 
-/// The error type that results from applying the try operator (`?`) to a `None` value. If you wish
-/// to allow `x?` (where `x` is an `Option<T>`) to be converted into your error type, you can
-/// implement `impl From<NoneError>` for `YourErrorType`. In that case, `x?` within a function that
-/// returns `Result<_, YourErrorType>` will translate a `None` value into an `Err` result.
-#[rustc_diagnostic_item = "none_error"]
-#[unstable(feature = "try_trait", issue = "42327")]
-#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
-#[cfg(bootstrap)]
-pub struct NoneError;
-
-#[unstable(feature = "try_trait", issue = "42327")]
-#[cfg(bootstrap)]
-impl<T> ops::TryV1 for Option<T> {
-    type Output = T;
-    type Error = NoneError;
-
-    #[inline]
-    fn into_result(self) -> Result<T, NoneError> {
-        self.ok_or(NoneError)
-    }
-
-    #[inline]
-    fn from_ok(v: T) -> Self {
-        Some(v)
-    }
-
-    #[inline]
-    fn from_error(_: NoneError) -> Self {
-        None
-    }
-}
-
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 impl<T> ops::TryV2 for Option<T> {
     type Output = T;
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index babd0a0b552..325efe721e3 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -1626,28 +1626,6 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
     }
 }
 
-#[unstable(feature = "try_trait", issue = "42327")]
-#[cfg(bootstrap)]
-impl<T, E> ops::TryV1 for Result<T, E> {
-    type Output = T;
-    type Error = E;
-
-    #[inline]
-    fn into_result(self) -> Self {
-        self
-    }
-
-    #[inline]
-    fn from_ok(v: T) -> Self {
-        Ok(v)
-    }
-
-    #[inline]
-    fn from_error(v: E) -> Self {
-        Err(v)
-    }
-}
-
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 impl<T, E> ops::TryV2 for Result<T, E> {
     type Output = T;
diff --git a/library/core/src/task/poll.rs b/library/core/src/task/poll.rs
index 9cf89623d88..ce5a8a86a30 100644
--- a/library/core/src/task/poll.rs
+++ b/library/core/src/task/poll.rs
@@ -128,32 +128,6 @@ impl<T> From<T> for Poll<T> {
     }
 }
 
-#[stable(feature = "futures_api", since = "1.36.0")]
-#[cfg(bootstrap)]
-impl<T, E> ops::TryV1 for Poll<Result<T, E>> {
-    type Output = Poll<T>;
-    type Error = E;
-
-    #[inline]
-    fn into_result(self) -> Result<Self::Output, Self::Error> {
-        match self {
-            Poll::Ready(Ok(x)) => Ok(Poll::Ready(x)),
-            Poll::Ready(Err(e)) => Err(e),
-            Poll::Pending => Ok(Poll::Pending),
-        }
-    }
-
-    #[inline]
-    fn from_error(e: Self::Error) -> Self {
-        Poll::Ready(Err(e))
-    }
-
-    #[inline]
-    fn from_ok(x: Self::Output) -> Self {
-        x.map(Ok)
-    }
-}
-
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 impl<T, E> ops::TryV2 for Poll<Result<T, E>> {
     type Output = Poll<T>;
@@ -184,33 +158,6 @@ impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>> for Pol
     }
 }
 
-#[stable(feature = "futures_api", since = "1.36.0")]
-#[cfg(bootstrap)]
-impl<T, E> ops::TryV1 for Poll<Option<Result<T, E>>> {
-    type Output = Poll<Option<T>>;
-    type Error = E;
-
-    #[inline]
-    fn into_result(self) -> Result<Self::Output, Self::Error> {
-        match self {
-            Poll::Ready(Some(Ok(x))) => Ok(Poll::Ready(Some(x))),
-            Poll::Ready(Some(Err(e))) => Err(e),
-            Poll::Ready(None) => Ok(Poll::Ready(None)),
-            Poll::Pending => Ok(Poll::Pending),
-        }
-    }
-
-    #[inline]
-    fn from_error(e: Self::Error) -> Self {
-        Poll::Ready(Some(Err(e)))
-    }
-
-    #[inline]
-    fn from_ok(x: Self::Output) -> Self {
-        x.map(|x| x.map(Ok))
-    }
-}
-
 #[unstable(feature = "try_trait_v2", issue = "84277")]
 impl<T, E> ops::TryV2 for Poll<Option<Result<T, E>>> {
     type Output = Poll<Option<T>>;