about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2020-04-22 15:45:35 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2020-04-25 09:25:33 -0400
commit93eed402adbe9e7a532995500d50716d52eefee9 (patch)
treeef6d0177fa8dac0ed4edff1de6ee9cf6a3e6b016 /src/libstd
parent0b958790b336738540d027d645718713849638d7 (diff)
Bump bootstrap compiler
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/future.rs106
-rw-r--r--src/libstd/lib.rs7
-rw-r--r--src/libstd/panicking.rs38
-rw-r--r--src/libstd/prelude/v1.rs1
4 files changed, 5 insertions, 147 deletions
diff --git a/src/libstd/future.rs b/src/libstd/future.rs
index c0675eeba98..e2092cfefa3 100644
--- a/src/libstd/future.rs
+++ b/src/libstd/future.rs
@@ -1,111 +1,5 @@
 //! Asynchronous values.
 
-#[cfg(bootstrap)]
-use core::{
-    cell::Cell,
-    marker::Unpin,
-    ops::{Drop, Generator, GeneratorState},
-    pin::Pin,
-    ptr::NonNull,
-    task::{Context, Poll},
-};
-
 #[doc(inline)]
 #[stable(feature = "futures_api", since = "1.36.0")]
 pub use core::future::*;
-
-/// Wrap a generator in a future.
-///
-/// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give
-/// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`).
-// This is `const` to avoid extra errors after we recover from `const async fn`
-#[cfg(bootstrap)]
-#[doc(hidden)]
-#[unstable(feature = "gen_future", issue = "50547")]
-pub const fn from_generator<T: Generator<Yield = ()>>(x: T) -> impl Future<Output = T::Return> {
-    GenFuture(x)
-}
-
-/// A wrapper around generators used to implement `Future` for `async`/`await` code.
-#[cfg(bootstrap)]
-#[doc(hidden)]
-#[unstable(feature = "gen_future", issue = "50547")]
-#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
-struct GenFuture<T: Generator<Yield = ()>>(T);
-
-// We rely on the fact that async/await futures are immovable in order to create
-// self-referential borrows in the underlying generator.
-#[cfg(bootstrap)]
-impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}
-
-#[cfg(bootstrap)]
-#[doc(hidden)]
-#[unstable(feature = "gen_future", issue = "50547")]
-impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
-    type Output = T::Return;
-    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
-        // Safe because we're !Unpin + !Drop mapping to a ?Unpin value
-        let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };
-        let _guard = unsafe { set_task_context(cx) };
-        match gen.resume(()) {
-            GeneratorState::Yielded(()) => Poll::Pending,
-            GeneratorState::Complete(x) => Poll::Ready(x),
-        }
-    }
-}
-
-#[cfg(bootstrap)]
-thread_local! {
-    static TLS_CX: Cell<Option<NonNull<Context<'static>>>> = Cell::new(None);
-}
-
-#[cfg(bootstrap)]
-struct SetOnDrop(Option<NonNull<Context<'static>>>);
-
-#[cfg(bootstrap)]
-impl Drop for SetOnDrop {
-    fn drop(&mut self) {
-        TLS_CX.with(|tls_cx| {
-            tls_cx.set(self.0.take());
-        });
-    }
-}
-
-// Safety: the returned guard must drop before `cx` is dropped and before
-// any previous guard is dropped.
-#[cfg(bootstrap)]
-unsafe fn set_task_context(cx: &mut Context<'_>) -> SetOnDrop {
-    // transmute the context's lifetime to 'static so we can store it.
-    let cx = core::mem::transmute::<&mut Context<'_>, &mut Context<'static>>(cx);
-    let old_cx = TLS_CX.with(|tls_cx| tls_cx.replace(Some(NonNull::from(cx))));
-    SetOnDrop(old_cx)
-}
-
-#[cfg(bootstrap)]
-#[doc(hidden)]
-#[unstable(feature = "gen_future", issue = "50547")]
-/// Polls a future in the current thread-local task waker.
-pub fn poll_with_tls_context<F>(f: Pin<&mut F>) -> Poll<F::Output>
-where
-    F: Future,
-{
-    let cx_ptr = TLS_CX.with(|tls_cx| {
-        // Clear the entry so that nested `get_task_waker` calls
-        // will fail or set their own value.
-        tls_cx.replace(None)
-    });
-    let _reset = SetOnDrop(cx_ptr);
-
-    let mut cx_ptr = cx_ptr.expect(
-        "TLS Context not set. This is a rustc bug. \
-        Please file an issue on https://github.com/rust-lang/rust.",
-    );
-
-    // Safety: we've ensured exclusive access to the context by
-    // removing the pointer from TLS, only to be replaced once
-    // we're done with it.
-    //
-    // The pointer that was inserted came from an `&mut Context<'_>`,
-    // so it is safe to treat as mutable.
-    unsafe { F::poll(f, cx_ptr.as_mut()) }
-}
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index 9d2810cacc2..5fd15bb8fe4 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -242,7 +242,7 @@
 #![feature(atomic_mut_ptr)]
 #![feature(box_syntax)]
 #![feature(c_variadic)]
-#![cfg_attr(not(bootstrap), feature(cfg_accessible))]
+#![feature(cfg_accessible)]
 #![feature(cfg_target_has_atomic)]
 #![feature(cfg_target_thread_local)]
 #![feature(char_error_internals)]
@@ -281,7 +281,7 @@
 #![feature(maybe_uninit_ref)]
 #![feature(maybe_uninit_slice)]
 #![feature(needs_panic_runtime)]
-#![cfg_attr(not(bootstrap), feature(negative_impls))]
+#![feature(negative_impls)]
 #![feature(never_type)]
 #![feature(nll)]
 #![feature(optin_builtin_traits)]
@@ -298,8 +298,7 @@
 #![feature(shrink_to)]
 #![feature(slice_concat_ext)]
 #![feature(slice_internals)]
-#![cfg_attr(bootstrap, feature(specialization))]
-#![cfg_attr(not(bootstrap), feature(min_specialization))]
+#![feature(min_specialization)]
 #![feature(staged_api)]
 #![feature(std_internals)]
 #![feature(stdsimd)]
diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs
index 10078bd4aee..343b2ee1273 100644
--- a/src/libstd/panicking.rs
+++ b/src/libstd/panicking.rs
@@ -271,44 +271,12 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
     let mut data = Data { f: ManuallyDrop::new(f) };
 
     let data_ptr = &mut data as *mut _ as *mut u8;
-    return if do_try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
+    return if intrinsics::r#try(do_call::<F, R>, data_ptr, do_catch::<F, R>) == 0 {
         Ok(ManuallyDrop::into_inner(data.r))
     } else {
         Err(ManuallyDrop::into_inner(data.p))
     };
 
-    // Compatibility wrapper around the try intrinsic for bootstrap.
-    //
-    // We also need to mark it #[inline(never)] to work around a bug on MinGW
-    // targets: the unwinding implementation was relying on UB, but this only
-    // becomes a problem in practice if inlining is involved.
-    #[cfg(not(bootstrap))]
-    use intrinsics::r#try as do_try;
-    #[cfg(bootstrap)]
-    #[inline(never)]
-    unsafe fn do_try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32 {
-        use crate::mem::MaybeUninit;
-        #[cfg(target_env = "msvc")]
-        type TryPayload = [u64; 2];
-        #[cfg(not(target_env = "msvc"))]
-        type TryPayload = *mut u8;
-
-        let mut payload: MaybeUninit<TryPayload> = MaybeUninit::uninit();
-        let payload_ptr = payload.as_mut_ptr() as *mut u8;
-        let r = intrinsics::r#try(try_fn, data, payload_ptr);
-        if r != 0 {
-            #[cfg(target_env = "msvc")]
-            {
-                catch_fn(data, payload_ptr)
-            }
-            #[cfg(not(target_env = "msvc"))]
-            {
-                catch_fn(data, payload.assume_init())
-            }
-        }
-        r
-    }
-
     // We consider unwinding to be rare, so mark this function as cold. However,
     // do not mark it no-inline -- that decision is best to leave to the
     // optimizer (in most cases this function is not inlined even as a normal,
@@ -320,9 +288,7 @@ pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>>
         obj
     }
 
-    // See comment on do_try above for why #[inline(never)] is needed on bootstrap.
-    #[cfg_attr(bootstrap, inline(never))]
-    #[cfg_attr(not(bootstrap), inline)]
+    #[inline]
     fn do_call<F: FnOnce() -> R, R>(data: *mut u8) {
         unsafe {
             let data = data as *mut Data<F, R>;
diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs
index 92e3ea84850..0fbd6b62f18 100644
--- a/src/libstd/prelude/v1.rs
+++ b/src/libstd/prelude/v1.rs
@@ -54,7 +54,6 @@ pub use core::prelude::v1::{
     PartialEq, PartialOrd, RustcDecodable, RustcEncodable,
 };
 
-#[cfg(not(bootstrap))]
 #[unstable(
     feature = "cfg_accessible",
     issue = "64797",