summaryrefslogtreecommitdiffstats
path: root/vendor/futures-task/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/futures-task/src
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/futures-task/src')
-rw-r--r--vendor/futures-task/src/future_obj.rs24
-rw-r--r--vendor/futures-task/src/waker.rs10
-rw-r--r--vendor/futures-task/src/waker_ref.rs5
3 files changed, 20 insertions, 19 deletions
diff --git a/vendor/futures-task/src/future_obj.rs b/vendor/futures-task/src/future_obj.rs
index 48ec12beb..071392af6 100644
--- a/vendor/futures-task/src/future_obj.rs
+++ b/vendor/futures-task/src/future_obj.rs
@@ -149,6 +149,7 @@ pub unsafe trait UnsafeFutureObj<'a, T>: 'a {
/// provided `*mut (dyn Future<Output = T> + 'a)` into a `Pin<&mut (dyn
/// Future<Output = T> + 'a)>` and call methods on it, non-reentrantly,
/// until `UnsafeFutureObj::drop` is called with it.
+ #[allow(clippy::unnecessary_safety_doc)]
fn into_raw(self) -> *mut (dyn Future<Output = T> + 'a);
/// Drops the future represented by the given fat pointer.
@@ -224,7 +225,7 @@ mod if_alloc {
}
unsafe fn drop(ptr: *mut (dyn Future<Output = T> + 'a)) {
- drop(Box::from_raw(ptr as *mut F))
+ drop(Box::from_raw(ptr.cast::<F>()))
}
}
@@ -252,10 +253,9 @@ mod if_alloc {
where
F: Future<Output = T> + 'a,
{
- fn into_raw(mut self) -> *mut (dyn Future<Output = T> + 'a) {
- let ptr = unsafe { self.as_mut().get_unchecked_mut() as *mut _ };
- mem::forget(self);
- ptr
+ fn into_raw(self) -> *mut (dyn Future<Output = T> + 'a) {
+ let mut this = mem::ManuallyDrop::new(self);
+ unsafe { this.as_mut().get_unchecked_mut() as *mut _ }
}
unsafe fn drop(ptr: *mut (dyn Future<Output = T> + 'a)) {
@@ -264,10 +264,9 @@ mod if_alloc {
}
unsafe impl<'a, T: 'a> UnsafeFutureObj<'a, T> for Pin<Box<dyn Future<Output = T> + 'a>> {
- fn into_raw(mut self) -> *mut (dyn Future<Output = T> + 'a) {
- let ptr = unsafe { self.as_mut().get_unchecked_mut() as *mut _ };
- mem::forget(self);
- ptr
+ fn into_raw(self) -> *mut (dyn Future<Output = T> + 'a) {
+ let mut this = mem::ManuallyDrop::new(self);
+ unsafe { this.as_mut().get_unchecked_mut() as *mut _ }
}
unsafe fn drop(ptr: *mut (dyn Future<Output = T> + 'a)) {
@@ -276,10 +275,9 @@ mod if_alloc {
}
unsafe impl<'a, T: 'a> UnsafeFutureObj<'a, T> for Pin<Box<dyn Future<Output = T> + Send + 'a>> {
- fn into_raw(mut self) -> *mut (dyn Future<Output = T> + 'a) {
- let ptr = unsafe { self.as_mut().get_unchecked_mut() as *mut _ };
- mem::forget(self);
- ptr
+ fn into_raw(self) -> *mut (dyn Future<Output = T> + 'a) {
+ let mut this = mem::ManuallyDrop::new(self);
+ unsafe { this.as_mut().get_unchecked_mut() as *mut _ }
}
unsafe fn drop(ptr: *mut (dyn Future<Output = T> + 'a)) {
diff --git a/vendor/futures-task/src/waker.rs b/vendor/futures-task/src/waker.rs
index a7310a07a..79112569c 100644
--- a/vendor/futures-task/src/waker.rs
+++ b/vendor/futures-task/src/waker.rs
@@ -20,7 +20,7 @@ pub fn waker<W>(wake: Arc<W>) -> Waker
where
W: ArcWake + 'static,
{
- let ptr = Arc::into_raw(wake) as *const ();
+ let ptr = Arc::into_raw(wake).cast::<()>();
unsafe { Waker::from_raw(RawWaker::new(ptr, waker_vtable::<W>())) }
}
@@ -31,7 +31,7 @@ where
#[allow(clippy::redundant_clone)] // The clone here isn't actually redundant.
unsafe fn increase_refcount<T: ArcWake>(data: *const ()) {
// Retain Arc, but don't touch refcount by wrapping in ManuallyDrop
- let arc = mem::ManuallyDrop::new(Arc::<T>::from_raw(data as *const T));
+ let arc = mem::ManuallyDrop::new(Arc::<T>::from_raw(data.cast::<T>()));
// Now increase refcount, but don't drop new refcount either
let _arc_clone: mem::ManuallyDrop<_> = arc.clone();
}
@@ -43,17 +43,17 @@ unsafe fn clone_arc_raw<T: ArcWake>(data: *const ()) -> RawWaker {
}
unsafe fn wake_arc_raw<T: ArcWake>(data: *const ()) {
- let arc: Arc<T> = Arc::from_raw(data as *const T);
+ let arc: Arc<T> = Arc::from_raw(data.cast::<T>());
ArcWake::wake(arc);
}
// used by `waker_ref`
unsafe fn wake_by_ref_arc_raw<T: ArcWake>(data: *const ()) {
// Retain Arc, but don't touch refcount by wrapping in ManuallyDrop
- let arc = mem::ManuallyDrop::new(Arc::<T>::from_raw(data as *const T));
+ let arc = mem::ManuallyDrop::new(Arc::<T>::from_raw(data.cast::<T>()));
ArcWake::wake_by_ref(&arc);
}
unsafe fn drop_arc_raw<T: ArcWake>(data: *const ()) {
- drop(Arc::<T>::from_raw(data as *const T))
+ drop(Arc::<T>::from_raw(data.cast::<T>()))
}
diff --git a/vendor/futures-task/src/waker_ref.rs b/vendor/futures-task/src/waker_ref.rs
index 791c69012..aac410957 100644
--- a/vendor/futures-task/src/waker_ref.rs
+++ b/vendor/futures-task/src/waker_ref.rs
@@ -18,6 +18,7 @@ pub struct WakerRef<'a> {
impl<'a> WakerRef<'a> {
/// Create a new [`WakerRef`] from a [`Waker`] reference.
+ #[inline]
pub fn new(waker: &'a Waker) -> Self {
// copy the underlying (raw) waker without calling a clone,
// as we won't call Waker::drop either.
@@ -31,6 +32,7 @@ impl<'a> WakerRef<'a> {
/// an unsafe way (that will be valid only for a lifetime to be determined
/// by the caller), and the [`Waker`] doesn't need to or must not be
/// destroyed.
+ #[inline]
pub fn new_unowned(waker: ManuallyDrop<Waker>) -> Self {
Self { waker, _marker: PhantomData }
}
@@ -39,6 +41,7 @@ impl<'a> WakerRef<'a> {
impl Deref for WakerRef<'_> {
type Target = Waker;
+ #[inline]
fn deref(&self) -> &Waker {
&self.waker
}
@@ -55,7 +58,7 @@ where
{
// simply copy the pointer instead of using Arc::into_raw,
// as we don't actually keep a refcount by using ManuallyDrop.<
- let ptr = (&**wake as *const W) as *const ();
+ let ptr = Arc::as_ptr(wake).cast::<()>();
let waker =
ManuallyDrop::new(unsafe { Waker::from_raw(RawWaker::new(ptr, waker_vtable::<W>())) });