mirror of
https://github.com/rust-lang/rust
synced 2024-10-04 15:50:51 +00:00
Add tracking issue to async_drop API
This commit is contained in:
parent
3baa20b783
commit
a6a78d28e6
|
@ -1,4 +1,4 @@
|
||||||
#![unstable(feature = "async_drop", issue = "none")]
|
#![unstable(feature = "async_drop", issue = "126482")]
|
||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::future::{Future, IntoFuture};
|
use crate::future::{Future, IntoFuture};
|
||||||
|
@ -10,27 +10,27 @@
|
||||||
|
|
||||||
/// Asynchronously drops a value by running `AsyncDrop::async_drop`
|
/// Asynchronously drops a value by running `AsyncDrop::async_drop`
|
||||||
/// on a value and its fields recursively.
|
/// on a value and its fields recursively.
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
pub fn async_drop<T>(value: T) -> AsyncDropOwning<T> {
|
pub fn async_drop<T>(value: T) -> AsyncDropOwning<T> {
|
||||||
AsyncDropOwning { value: MaybeUninit::new(value), dtor: None, _pinned: PhantomPinned }
|
AsyncDropOwning { value: MaybeUninit::new(value), dtor: None, _pinned: PhantomPinned }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A future returned by the [`async_drop`].
|
/// A future returned by the [`async_drop`].
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
pub struct AsyncDropOwning<T> {
|
pub struct AsyncDropOwning<T> {
|
||||||
value: MaybeUninit<T>,
|
value: MaybeUninit<T>,
|
||||||
dtor: Option<AsyncDropInPlace<T>>,
|
dtor: Option<AsyncDropInPlace<T>>,
|
||||||
_pinned: PhantomPinned,
|
_pinned: PhantomPinned,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
impl<T> fmt::Debug for AsyncDropOwning<T> {
|
impl<T> fmt::Debug for AsyncDropOwning<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("AsyncDropOwning").finish_non_exhaustive()
|
f.debug_struct("AsyncDropOwning").finish_non_exhaustive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
impl<T> Future for AsyncDropOwning<T> {
|
impl<T> Future for AsyncDropOwning<T> {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
|
@ -86,24 +86,24 @@ unsafe fn async_drop_in_place_raw<T: ?Sized>(
|
||||||
/// returned future stores the `to_drop` pointer and user is required
|
/// returned future stores the `to_drop` pointer and user is required
|
||||||
/// to guarantee that dropped value doesn't move.
|
/// to guarantee that dropped value doesn't move.
|
||||||
///
|
///
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
pub unsafe fn async_drop_in_place<T: ?Sized>(to_drop: *mut T) -> AsyncDropInPlace<T> {
|
pub unsafe fn async_drop_in_place<T: ?Sized>(to_drop: *mut T) -> AsyncDropInPlace<T> {
|
||||||
// SAFETY: `async_drop_in_place_raw` has the same safety requirements
|
// SAFETY: `async_drop_in_place_raw` has the same safety requirements
|
||||||
unsafe { AsyncDropInPlace(async_drop_in_place_raw(to_drop)) }
|
unsafe { AsyncDropInPlace(async_drop_in_place_raw(to_drop)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A future returned by the [`async_drop_in_place`].
|
/// A future returned by the [`async_drop_in_place`].
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
pub struct AsyncDropInPlace<T: ?Sized>(<T as AsyncDestruct>::AsyncDestructor);
|
pub struct AsyncDropInPlace<T: ?Sized>(<T as AsyncDestruct>::AsyncDestructor);
|
||||||
|
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
impl<T: ?Sized> fmt::Debug for AsyncDropInPlace<T> {
|
impl<T: ?Sized> fmt::Debug for AsyncDropInPlace<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("AsyncDropInPlace").finish_non_exhaustive()
|
f.debug_struct("AsyncDropInPlace").finish_non_exhaustive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
impl<T: ?Sized> Future for AsyncDropInPlace<T> {
|
impl<T: ?Sized> Future for AsyncDropInPlace<T> {
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
|
@ -117,18 +117,18 @@ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
// FIXME(zetanumbers): Add same restrictions on AsyncDrop impls as
|
// FIXME(zetanumbers): Add same restrictions on AsyncDrop impls as
|
||||||
// with Drop impls
|
// with Drop impls
|
||||||
/// Custom code within the asynchronous destructor.
|
/// Custom code within the asynchronous destructor.
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
#[lang = "async_drop"]
|
#[lang = "async_drop"]
|
||||||
pub trait AsyncDrop {
|
pub trait AsyncDrop {
|
||||||
/// A future returned by the [`AsyncDrop::async_drop`] to be part
|
/// A future returned by the [`AsyncDrop::async_drop`] to be part
|
||||||
/// of the async destructor.
|
/// of the async destructor.
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
type Dropper<'a>: Future<Output = ()>
|
type Dropper<'a>: Future<Output = ()>
|
||||||
where
|
where
|
||||||
Self: 'a;
|
Self: 'a;
|
||||||
|
|
||||||
/// Constructs the asynchronous destructor for this type.
|
/// Constructs the asynchronous destructor for this type.
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
fn async_drop(self: Pin<&mut Self>) -> Self::Dropper<'_>;
|
fn async_drop(self: Pin<&mut Self>) -> Self::Dropper<'_>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#[stable(feature = "future_poll_fn", since = "1.64.0")]
|
#[stable(feature = "future_poll_fn", since = "1.64.0")]
|
||||||
pub use poll_fn::{poll_fn, PollFn};
|
pub use poll_fn::{poll_fn, PollFn};
|
||||||
|
|
||||||
#[unstable(feature = "async_drop", issue = "none")]
|
#[unstable(feature = "async_drop", issue = "126482")]
|
||||||
pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace};
|
pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace};
|
||||||
|
|
||||||
/// This type is needed because:
|
/// This type is needed because:
|
||||||
|
|
Loading…
Reference in a new issue