Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obk · model-checking/verify-rust-std@9fe1803 (original) (raw)
`@@ -161,6 +161,11 @@ async unsafe fn surface_drop_in_place<T: Drop + ?Sized>(ptr: *mut T) {
`
161
161
`` /// wrapped future completes by returning Poll::Ready(())
on poll. This
``
162
162
`/// is useful for constructing async destructors to guarantee this
`
163
163
`/// "fuse" property
`
``
164
`+
//
`
``
165
`+
// FIXME: Consider optimizing combinators to not have to use fuse in majority
`
``
166
`` +
// of cases, perhaps by adding #[(rustc_)idempotent(_future)]
attribute for
``
``
167
`+
// async functions and blocks with the unit return type. However current layout
`
``
168
`` +
// optimizations currently encode None
case into the async block's discriminant.
``
164
169
`struct Fuse {
`
165
170
`inner: Option,
`
166
171
`}
`
`@@ -251,6 +256,14 @@ async unsafe fn either<O: IntoFuture<Output = ()>, M: IntoFuture<Output = ()>, T
`
251
256
`}
`
252
257
`}
`
253
258
``
``
259
`+
#[cfg(not(bootstrap))]
`
``
260
`+
#[lang = "async_drop_deferred_drop_in_place"]
`
``
261
`+
async unsafe fn deferred_drop_in_place(to_drop: *mut T) {
`
``
262
`+
// SAFETY: same safety requirements as with drop_in_place (implied by
`
``
263
`+
// function's name)
`
``
264
`+
unsafe { crate::ptr::drop_in_place(to_drop) }
`
``
265
`+
}
`
``
266
+
254
267
`` /// Used for noop async destructors. We don't use [core::future::Ready
]
``
255
268
`/// because it panics after its second poll, which could be potentially
`
256
269
`/// bad if that would happen during the cleanup.
`