Stabilize futures_api
This commit is contained in:
parent
e617025e96
commit
3f966dcd53
32 changed files with 86 additions and 66 deletions
|
@ -911,7 +911,7 @@ impl<G: ?Sized + Generator> Generator for Pin<Box<G>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "futures_api", issue = "50547")]
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<F: ?Sized + Future + Unpin> Future for Box<F> {
|
impl<F: ?Sized + Future + Unpin> Future for Box<F> {
|
||||||
type Output = F::Output;
|
type Output = F::Output;
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,6 @@
|
||||||
#![feature(fmt_internals)]
|
#![feature(fmt_internals)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(fundamental)]
|
#![feature(fundamental)]
|
||||||
#![feature(futures_api)]
|
|
||||||
#![feature(lang_items)]
|
#![feature(lang_items)]
|
||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
#![feature(needs_allocator)]
|
#![feature(needs_allocator)]
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#![unstable(feature = "futures_api",
|
#![stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
|
|
||||||
use crate::marker::Unpin;
|
use crate::marker::Unpin;
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
|
@ -26,8 +24,10 @@ use crate::task::{Context, Poll};
|
||||||
/// `await!` the value.
|
/// `await!` the value.
|
||||||
#[doc(spotlight)]
|
#[doc(spotlight)]
|
||||||
#[must_use = "futures do nothing unless polled"]
|
#[must_use = "futures do nothing unless polled"]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub trait Future {
|
pub trait Future {
|
||||||
/// The type of value produced on completion.
|
/// The type of value produced on completion.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
type Output;
|
type Output;
|
||||||
|
|
||||||
/// Attempt to resolve the future to a final value, registering
|
/// Attempt to resolve the future to a final value, registering
|
||||||
|
@ -92,9 +92,11 @@ pub trait Future {
|
||||||
/// [`Context`]: ../task/struct.Context.html
|
/// [`Context`]: ../task/struct.Context.html
|
||||||
/// [`Waker`]: ../task/struct.Waker.html
|
/// [`Waker`]: ../task/struct.Waker.html
|
||||||
/// [`Waker::wake`]: ../task/struct.Waker.html#method.wake
|
/// [`Waker::wake`]: ../task/struct.Waker.html#method.wake
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<F: ?Sized + Future + Unpin> Future for &mut F {
|
impl<F: ?Sized + Future + Unpin> Future for &mut F {
|
||||||
type Output = F::Output;
|
type Output = F::Output;
|
||||||
|
|
||||||
|
@ -103,6 +105,7 @@ impl<F: ?Sized + Future + Unpin> Future for &mut F {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<P> Future for Pin<P>
|
impl<P> Future for Pin<P>
|
||||||
where
|
where
|
||||||
P: Unpin + ops::DerefMut,
|
P: Unpin + ops::DerefMut,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#![unstable(feature = "futures_api",
|
#![stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
|
|
||||||
//! Asynchronous values.
|
//! Asynchronous values.
|
||||||
|
|
||||||
mod future;
|
mod future;
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub use self::future::Future;
|
pub use self::future::Future;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#![unstable(feature = "futures_api",
|
#![stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
|
|
||||||
//! Types and Traits for working with asynchronous tasks.
|
//! Types and Traits for working with asynchronous tasks.
|
||||||
|
|
||||||
mod poll;
|
mod poll;
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub use self::poll::Poll;
|
pub use self::poll::Poll;
|
||||||
|
|
||||||
mod wake;
|
mod wake;
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub use self::wake::{Context, Waker, RawWaker, RawWakerVTable};
|
pub use self::wake::{Context, Waker, RawWaker, RawWakerVTable};
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#![unstable(feature = "futures_api",
|
#![stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
|
|
||||||
use crate::ops::Try;
|
use crate::ops::Try;
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
|
@ -9,20 +7,27 @@ use crate::result::Result;
|
||||||
/// scheduled to receive a wakeup instead.
|
/// scheduled to receive a wakeup instead.
|
||||||
#[must_use = "this `Poll` may be a `Pending` variant, which should be handled"]
|
#[must_use = "this `Poll` may be a `Pending` variant, which should be handled"]
|
||||||
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub enum Poll<T> {
|
pub enum Poll<T> {
|
||||||
/// Represents that a value is immediately ready.
|
/// Represents that a value is immediately ready.
|
||||||
Ready(T),
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
|
Ready(
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
|
T
|
||||||
|
),
|
||||||
|
|
||||||
/// Represents that a value is not ready yet.
|
/// Represents that a value is not ready yet.
|
||||||
///
|
///
|
||||||
/// When a function returns `Pending`, the function *must* also
|
/// When a function returns `Pending`, the function *must* also
|
||||||
/// ensure that the current task is scheduled to be awoken when
|
/// ensure that the current task is scheduled to be awoken when
|
||||||
/// progress can be made.
|
/// progress can be made.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
Pending,
|
Pending,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Poll<T> {
|
impl<T> Poll<T> {
|
||||||
/// Changes the ready value of this `Poll` with the closure provided.
|
/// Changes the ready value of this `Poll` with the closure provided.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn map<U, F>(self, f: F) -> Poll<U>
|
pub fn map<U, F>(self, f: F) -> Poll<U>
|
||||||
where F: FnOnce(T) -> U
|
where F: FnOnce(T) -> U
|
||||||
{
|
{
|
||||||
|
@ -34,6 +39,7 @@ impl<T> Poll<T> {
|
||||||
|
|
||||||
/// Returns `true` if this is `Poll::Ready`
|
/// Returns `true` if this is `Poll::Ready`
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn is_ready(&self) -> bool {
|
pub fn is_ready(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Poll::Ready(_) => true,
|
Poll::Ready(_) => true,
|
||||||
|
@ -43,6 +49,7 @@ impl<T> Poll<T> {
|
||||||
|
|
||||||
/// Returns `true` if this is `Poll::Pending`
|
/// Returns `true` if this is `Poll::Pending`
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn is_pending(&self) -> bool {
|
pub fn is_pending(&self) -> bool {
|
||||||
!self.is_ready()
|
!self.is_ready()
|
||||||
}
|
}
|
||||||
|
@ -50,6 +57,7 @@ impl<T> Poll<T> {
|
||||||
|
|
||||||
impl<T, E> Poll<Result<T, E>> {
|
impl<T, E> Poll<Result<T, E>> {
|
||||||
/// Changes the success value of this `Poll` with the closure provided.
|
/// Changes the success value of this `Poll` with the closure provided.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>
|
pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>
|
||||||
where F: FnOnce(T) -> U
|
where F: FnOnce(T) -> U
|
||||||
{
|
{
|
||||||
|
@ -61,6 +69,7 @@ impl<T, E> Poll<Result<T, E>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Changes the error value of this `Poll` with the closure provided.
|
/// Changes the error value of this `Poll` with the closure provided.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>>
|
pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>>
|
||||||
where F: FnOnce(E) -> U
|
where F: FnOnce(E) -> U
|
||||||
{
|
{
|
||||||
|
@ -72,12 +81,14 @@ impl<T, E> Poll<Result<T, E>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<T> From<T> for Poll<T> {
|
impl<T> From<T> for Poll<T> {
|
||||||
fn from(t: T) -> Poll<T> {
|
fn from(t: T) -> Poll<T> {
|
||||||
Poll::Ready(t)
|
Poll::Ready(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<T, E> Try for Poll<Result<T, E>> {
|
impl<T, E> Try for Poll<Result<T, E>> {
|
||||||
type Ok = Poll<T>;
|
type Ok = Poll<T>;
|
||||||
type Error = E;
|
type Error = E;
|
||||||
|
@ -102,6 +113,7 @@ impl<T, E> Try for Poll<Result<T, E>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<T, E> Try for Poll<Option<Result<T, E>>> {
|
impl<T, E> Try for Poll<Option<Result<T, E>>> {
|
||||||
type Ok = Poll<Option<T>>;
|
type Ok = Poll<Option<T>>;
|
||||||
type Error = E;
|
type Error = E;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#![unstable(feature = "futures_api",
|
#![stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::marker::{PhantomData, Unpin};
|
use crate::marker::{PhantomData, Unpin};
|
||||||
|
@ -13,6 +11,7 @@ use crate::marker::{PhantomData, Unpin};
|
||||||
/// It consists of a data pointer and a [virtual function pointer table (vtable)][vtable] that
|
/// It consists of a data pointer and a [virtual function pointer table (vtable)][vtable] that
|
||||||
/// customizes the behavior of the `RawWaker`.
|
/// customizes the behavior of the `RawWaker`.
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub struct RawWaker {
|
pub struct RawWaker {
|
||||||
/// A data pointer, which can be used to store arbitrary data as required
|
/// A data pointer, which can be used to store arbitrary data as required
|
||||||
/// by the executor. This could be e.g. a type-erased pointer to an `Arc`
|
/// by the executor. This could be e.g. a type-erased pointer to an `Arc`
|
||||||
|
@ -37,9 +36,7 @@ impl RawWaker {
|
||||||
/// from a `RawWaker`. For each operation on the `Waker`, the associated
|
/// from a `RawWaker`. For each operation on the `Waker`, the associated
|
||||||
/// function in the `vtable` of the underlying `RawWaker` will be called.
|
/// function in the `vtable` of the underlying `RawWaker` will be called.
|
||||||
#[rustc_promotable]
|
#[rustc_promotable]
|
||||||
#[unstable(feature = "futures_api",
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
pub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker {
|
pub const fn new(data: *const (), vtable: &'static RawWakerVTable) -> RawWaker {
|
||||||
RawWaker {
|
RawWaker {
|
||||||
data,
|
data,
|
||||||
|
@ -58,6 +55,7 @@ impl RawWaker {
|
||||||
/// pointer of a properly constructed [`RawWaker`] object from inside the
|
/// pointer of a properly constructed [`RawWaker`] object from inside the
|
||||||
/// [`RawWaker`] implementation. Calling one of the contained functions using
|
/// [`RawWaker`] implementation. Calling one of the contained functions using
|
||||||
/// any other `data` pointer will cause undefined behavior.
|
/// any other `data` pointer will cause undefined behavior.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
#[derive(PartialEq, Copy, Clone, Debug)]
|
#[derive(PartialEq, Copy, Clone, Debug)]
|
||||||
pub struct RawWakerVTable {
|
pub struct RawWakerVTable {
|
||||||
/// This function will be called when the [`RawWaker`] gets cloned, e.g. when
|
/// This function will be called when the [`RawWaker`] gets cloned, e.g. when
|
||||||
|
@ -131,9 +129,14 @@ impl RawWakerVTable {
|
||||||
/// resources that are associated with this instance of a [`RawWaker`] and
|
/// resources that are associated with this instance of a [`RawWaker`] and
|
||||||
/// associated task.
|
/// associated task.
|
||||||
#[rustc_promotable]
|
#[rustc_promotable]
|
||||||
#[unstable(feature = "futures_api",
|
#[cfg_attr(stage0, unstable(feature = "futures_api_const_fn_ptr", issue = "50547"))]
|
||||||
reason = "futures in libcore are unstable",
|
#[cfg_attr(not(stage0), stable(feature = "futures_api", since = "1.36.0"))]
|
||||||
issue = "50547")]
|
// `rustc_allow_const_fn_ptr` is a hack that should not be used anywhere else
|
||||||
|
// without first consulting with T-Lang.
|
||||||
|
//
|
||||||
|
// FIXME: remove whenever we have a stable way to accept fn pointers from const fn
|
||||||
|
// (see https://github.com/rust-rfcs/const-eval/issues/19#issuecomment-472799062)
|
||||||
|
#[cfg_attr(not(stage0), rustc_allow_const_fn_ptr)]
|
||||||
pub const fn new(
|
pub const fn new(
|
||||||
clone: unsafe fn(*const ()) -> RawWaker,
|
clone: unsafe fn(*const ()) -> RawWaker,
|
||||||
wake: unsafe fn(*const ()),
|
wake: unsafe fn(*const ()),
|
||||||
|
@ -153,6 +156,7 @@ impl RawWakerVTable {
|
||||||
///
|
///
|
||||||
/// Currently, `Context` only serves to provide access to a `&Waker`
|
/// Currently, `Context` only serves to provide access to a `&Waker`
|
||||||
/// which can be used to wake the current task.
|
/// which can be used to wake the current task.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub struct Context<'a> {
|
pub struct Context<'a> {
|
||||||
waker: &'a Waker,
|
waker: &'a Waker,
|
||||||
// Ensure we future-proof against variance changes by forcing
|
// Ensure we future-proof against variance changes by forcing
|
||||||
|
@ -164,6 +168,7 @@ pub struct Context<'a> {
|
||||||
|
|
||||||
impl<'a> Context<'a> {
|
impl<'a> Context<'a> {
|
||||||
/// Create a new `Context` from a `&Waker`.
|
/// Create a new `Context` from a `&Waker`.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_waker(waker: &'a Waker) -> Self {
|
pub fn from_waker(waker: &'a Waker) -> Self {
|
||||||
Context {
|
Context {
|
||||||
|
@ -173,12 +178,14 @@ impl<'a> Context<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the `Waker` for the current task.
|
/// Returns a reference to the `Waker` for the current task.
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn waker(&self) -> &'a Waker {
|
pub fn waker(&self) -> &'a Waker {
|
||||||
&self.waker
|
&self.waker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl fmt::Debug for Context<'_> {
|
impl fmt::Debug for Context<'_> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Context")
|
f.debug_struct("Context")
|
||||||
|
@ -195,17 +202,22 @@ impl fmt::Debug for Context<'_> {
|
||||||
///
|
///
|
||||||
/// Implements [`Clone`], [`Send`], and [`Sync`].
|
/// Implements [`Clone`], [`Send`], and [`Sync`].
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub struct Waker {
|
pub struct Waker {
|
||||||
waker: RawWaker,
|
waker: RawWaker,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl Unpin for Waker {}
|
impl Unpin for Waker {}
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
unsafe impl Send for Waker {}
|
unsafe impl Send for Waker {}
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
unsafe impl Sync for Waker {}
|
unsafe impl Sync for Waker {}
|
||||||
|
|
||||||
impl Waker {
|
impl Waker {
|
||||||
/// Wake up the task associated with this `Waker`.
|
/// Wake up the task associated with this `Waker`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn wake(self) {
|
pub fn wake(self) {
|
||||||
// The actual wakeup call is delegated through a virtual function call
|
// The actual wakeup call is delegated through a virtual function call
|
||||||
// to the implementation which is defined by the executor.
|
// to the implementation which is defined by the executor.
|
||||||
|
@ -227,6 +239,7 @@ impl Waker {
|
||||||
/// where an owned `Waker` is available. This method should be preferred to
|
/// where an owned `Waker` is available. This method should be preferred to
|
||||||
/// calling `waker.clone().wake()`.
|
/// calling `waker.clone().wake()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn wake_by_ref(&self) {
|
pub fn wake_by_ref(&self) {
|
||||||
// The actual wakeup call is delegated through a virtual function call
|
// The actual wakeup call is delegated through a virtual function call
|
||||||
// to the implementation which is defined by the executor.
|
// to the implementation which is defined by the executor.
|
||||||
|
@ -243,6 +256,7 @@ impl Waker {
|
||||||
///
|
///
|
||||||
/// This function is primarily used for optimization purposes.
|
/// This function is primarily used for optimization purposes.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub fn will_wake(&self, other: &Waker) -> bool {
|
pub fn will_wake(&self, other: &Waker) -> bool {
|
||||||
self.waker == other.waker
|
self.waker == other.waker
|
||||||
}
|
}
|
||||||
|
@ -253,6 +267,7 @@ impl Waker {
|
||||||
/// in [`RawWaker`]'s and [`RawWakerVTable`]'s documentation is not upheld.
|
/// in [`RawWaker`]'s and [`RawWakerVTable`]'s documentation is not upheld.
|
||||||
/// Therefore this method is unsafe.
|
/// Therefore this method is unsafe.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub unsafe fn from_raw(waker: RawWaker) -> Waker {
|
pub unsafe fn from_raw(waker: RawWaker) -> Waker {
|
||||||
Waker {
|
Waker {
|
||||||
waker,
|
waker,
|
||||||
|
@ -260,6 +275,7 @@ impl Waker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl Clone for Waker {
|
impl Clone for Waker {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
|
@ -272,6 +288,7 @@ impl Clone for Waker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl Drop for Waker {
|
impl Drop for Waker {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
@ -282,6 +299,7 @@ impl Drop for Waker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl fmt::Debug for Waker {
|
impl fmt::Debug for Waker {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let vtable_ptr = self.waker.vtable as *const RawWakerVTable;
|
let vtable_ptr = self.waker.vtable as *const RawWakerVTable;
|
||||||
|
|
|
@ -9,6 +9,7 @@ use core::task::{Context, Poll};
|
||||||
use core::ops::{Drop, Generator, GeneratorState};
|
use core::ops::{Drop, Generator, GeneratorState};
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub use core::future::*;
|
pub use core::future::*;
|
||||||
|
|
||||||
/// Wrap a generator in a future.
|
/// Wrap a generator in a future.
|
||||||
|
|
|
@ -263,7 +263,6 @@
|
||||||
#![feature(fixed_size_array)]
|
#![feature(fixed_size_array)]
|
||||||
#![feature(fn_traits)]
|
#![feature(fn_traits)]
|
||||||
#![feature(fnbox)]
|
#![feature(fnbox)]
|
||||||
#![feature(futures_api)]
|
|
||||||
#![feature(generator_trait)]
|
#![feature(generator_trait)]
|
||||||
#![feature(hash_raw_entry)]
|
#![feature(hash_raw_entry)]
|
||||||
#![feature(hashmap_internals)]
|
#![feature(hashmap_internals)]
|
||||||
|
@ -458,18 +457,15 @@ pub mod process;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
|
|
||||||
#[unstable(feature = "futures_api",
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
pub mod task {
|
pub mod task {
|
||||||
//! Types and Traits for working with asynchronous tasks.
|
//! Types and Traits for working with asynchronous tasks.
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
pub use core::task::*;
|
pub use core::task::*;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "futures_api",
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
reason = "futures in libcore are unstable",
|
|
||||||
issue = "50547")]
|
|
||||||
pub mod future;
|
pub mod future;
|
||||||
|
|
||||||
// Platform-abstraction modules
|
// Platform-abstraction modules
|
||||||
|
|
|
@ -319,7 +319,7 @@ impl<T: fmt::Debug> fmt::Debug for AssertUnwindSafe<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "futures_api", issue = "50547")]
|
#[stable(feature = "futures_api", since = "1.36.0")]
|
||||||
impl<F: Future> Future for AssertUnwindSafe<F> {
|
impl<F: Future> Future for AssertUnwindSafe<F> {
|
||||||
type Output = F::Output;
|
type Output = F::Output;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#![deny(unused_must_use)]
|
#![deny(unused_must_use)]
|
||||||
#![feature(arbitrary_self_types, futures_api)]
|
#![feature(arbitrary_self_types)]
|
||||||
|
|
||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
// aux-build:arc_wake.rs
|
// aux-build:arc_wake.rs
|
||||||
|
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
extern crate arc_wake;
|
extern crate arc_wake;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(futures_api)]
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::task::{
|
use std::task::{
|
||||||
Waker, RawWaker, RawWakerVTable,
|
Waker, RawWaker, RawWakerVTable,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// aux-build:arc_wake.rs
|
// aux-build:arc_wake.rs
|
||||||
|
|
||||||
#![feature(futures_api)]
|
|
||||||
|
|
||||||
extern crate arc_wake;
|
extern crate arc_wake;
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
|
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
extern crate arc_wake;
|
extern crate arc_wake;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
// run-pass
|
// run-pass
|
||||||
|
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
trait Foo { }
|
trait Foo { }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(async_await, futures_api)]
|
#![feature(async_await)]
|
||||||
|
|
||||||
// @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>'
|
// @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>'
|
||||||
pub async fn foo() -> Option<Foo> {
|
pub async fn foo() -> Option<Foo> {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, async_await, await_macro, futures_api, pin)]
|
#![feature(arbitrary_self_types, async_await, await_macro, pin)]
|
||||||
|
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
error[E0723]: function pointers in const fn are unstable (see issue #57563)
|
error[E0723]: function pointers in const fn are unstable
|
||||||
--> $DIR/allow_const_fn_ptr.rs:4:16
|
--> $DIR/allow_const_fn_ptr.rs:4:16
|
||||||
|
|
|
|
||||||
LL | const fn error(_: fn()) {}
|
LL | const fn error(_: fn()) {}
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
|
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
|
||||||
= help: add #![feature(const_fn)] to the crate attributes to enable
|
= help: add #![feature(const_fn)] to the crate attributes to enable
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// edition:2015
|
// edition:2015
|
||||||
|
|
||||||
#![feature(futures_api, async_await)]
|
#![feature(async_await)]
|
||||||
|
|
||||||
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// edition:2015
|
// edition:2015
|
||||||
|
|
||||||
#![feature(futures_api)]
|
|
||||||
|
|
||||||
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
|
||||||
//~^ ERROR async fn is unstable
|
//~^ ERROR async fn is unstable
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
error[E0670]: `async fn` is not permitted in the 2015 edition
|
error[E0670]: `async fn` is not permitted in the 2015 edition
|
||||||
--> $DIR/feature-gate-async-await-2015-edition.rs:5:1
|
--> $DIR/feature-gate-async-await-2015-edition.rs:3:1
|
||||||
|
|
|
|
||||||
LL | async fn foo() {}
|
LL | async fn foo() {}
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error[E0422]: cannot find struct, variant or union type `async` in this scope
|
error[E0422]: cannot find struct, variant or union type `async` in this scope
|
||||||
--> $DIR/feature-gate-async-await-2015-edition.rs:9:13
|
--> $DIR/feature-gate-async-await-2015-edition.rs:7:13
|
||||||
|
|
|
|
||||||
LL | let _ = async {};
|
LL | let _ = async {};
|
||||||
| ^^^^^ not found in this scope
|
| ^^^^^ not found in this scope
|
||||||
|
|
||||||
error[E0425]: cannot find value `async` in this scope
|
error[E0425]: cannot find value `async` in this scope
|
||||||
--> $DIR/feature-gate-async-await-2015-edition.rs:10:13
|
--> $DIR/feature-gate-async-await-2015-edition.rs:8:13
|
||||||
|
|
|
|
||||||
LL | let _ = async || { true };
|
LL | let _ = async || { true };
|
||||||
| ^^^^^ not found in this scope
|
| ^^^^^ not found in this scope
|
||||||
|
|
||||||
error[E0658]: async fn is unstable
|
error[E0658]: async fn is unstable
|
||||||
--> $DIR/feature-gate-async-await-2015-edition.rs:5:1
|
--> $DIR/feature-gate-async-await-2015-edition.rs:3:1
|
||||||
|
|
|
|
||||||
LL | async fn foo() {}
|
LL | async fn foo() {}
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(futures_api)]
|
|
||||||
|
|
||||||
struct S;
|
struct S;
|
||||||
|
|
||||||
impl S {
|
impl S {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
error[E0706]: trait fns cannot be declared `async`
|
error[E0706]: trait fns cannot be declared `async`
|
||||||
--> $DIR/feature-gate-async-await.rs:12:5
|
--> $DIR/feature-gate-async-await.rs:10:5
|
||||||
|
|
|
|
||||||
LL | async fn foo();
|
LL | async fn foo();
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0658]: async fn is unstable
|
error[E0658]: async fn is unstable
|
||||||
--> $DIR/feature-gate-async-await.rs:8:5
|
--> $DIR/feature-gate-async-await.rs:6:5
|
||||||
|
|
|
|
||||||
LL | async fn foo() {}
|
LL | async fn foo() {}
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
@ -14,7 +14,7 @@ LL | async fn foo() {}
|
||||||
= help: add #![feature(async_await)] to the crate attributes to enable
|
= help: add #![feature(async_await)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: async fn is unstable
|
error[E0658]: async fn is unstable
|
||||||
--> $DIR/feature-gate-async-await.rs:12:5
|
--> $DIR/feature-gate-async-await.rs:10:5
|
||||||
|
|
|
|
||||||
LL | async fn foo();
|
LL | async fn foo();
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
@ -23,7 +23,7 @@ LL | async fn foo();
|
||||||
= help: add #![feature(async_await)] to the crate attributes to enable
|
= help: add #![feature(async_await)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: async fn is unstable
|
error[E0658]: async fn is unstable
|
||||||
--> $DIR/feature-gate-async-await.rs:16:1
|
--> $DIR/feature-gate-async-await.rs:14:1
|
||||||
|
|
|
|
||||||
LL | async fn foo() {}
|
LL | async fn foo() {}
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
@ -32,7 +32,7 @@ LL | async fn foo() {}
|
||||||
= help: add #![feature(async_await)] to the crate attributes to enable
|
= help: add #![feature(async_await)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: async blocks are unstable
|
error[E0658]: async blocks are unstable
|
||||||
--> $DIR/feature-gate-async-await.rs:19:13
|
--> $DIR/feature-gate-async-await.rs:17:13
|
||||||
|
|
|
|
||||||
LL | let _ = async {};
|
LL | let _ = async {};
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
@ -41,7 +41,7 @@ LL | let _ = async {};
|
||||||
= help: add #![feature(async_await)] to the crate attributes to enable
|
= help: add #![feature(async_await)] to the crate attributes to enable
|
||||||
|
|
||||||
error[E0658]: async closures are unstable
|
error[E0658]: async closures are unstable
|
||||||
--> $DIR/feature-gate-async-await.rs:20:13
|
--> $DIR/feature-gate-async-await.rs:18:13
|
||||||
|
|
|
|
||||||
LL | let _ = async || {};
|
LL | let _ = async || {};
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Test that impl trait does not allow creating recursive types that are
|
// Test that impl trait does not allow creating recursive types that are
|
||||||
// otherwise forbidden when using `async` and `await`.
|
// otherwise forbidden when using `async` and `await`.
|
||||||
|
|
||||||
#![feature(await_macro, async_await, futures_api, generators)]
|
#![feature(await_macro, async_await, generators)]
|
||||||
|
|
||||||
async fn recursive_async_function() -> () { //~ ERROR
|
async fn recursive_async_function() -> () { //~ ERROR
|
||||||
await!(recursive_async_function());
|
await!(recursive_async_function());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Test that impl trait does not allow creating recursive types that are
|
// Test that impl trait does not allow creating recursive types that are
|
||||||
// otherwise forbidden.
|
// otherwise forbidden.
|
||||||
|
|
||||||
#![feature(futures_api, generators)]
|
#![feature(generators)]
|
||||||
|
|
||||||
fn option(i: i32) -> impl Sized { //~ ERROR
|
fn option(i: i32) -> impl Sized { //~ ERROR
|
||||||
if i < 0 {
|
if i < 0 {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
struct Xyz {
|
struct Xyz {
|
||||||
a: u64,
|
a: u64,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(async_await, await_macro, futures_api)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, async_await, await_macro, futures_api, pin)]
|
#![feature(async_await, await_macro)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = async |x: u8| {};
|
let _ = async |x: u8| {};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// compile-pass
|
// compile-pass
|
||||||
|
|
||||||
#![allow(dead_code, unused)]
|
#![allow(dead_code, unused)]
|
||||||
#![feature(futures_api)]
|
|
||||||
|
|
||||||
use std::task::Poll;
|
use std::task::Poll;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue