From 2a58599dc4a2a3ba565c0540c5c45e41bc3d25e3 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 1 Nov 2025 09:13:22 -0700 Subject: [PATCH] Replace noop waker implementation with `Waker::noop()`. The MSRV of `wgpu` is currently 1.88, so we can use `Waker::noop()`, which was stabilized in 1.85. --- wgpu/src/api/device.rs | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 482a439f1..2cc384091 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -58,7 +58,7 @@ impl Device { use core::future::Future as _; use core::pin::pin; use core::task; - let ctx = &mut task::Context::from_waker(waker::noop_waker_ref()); + let ctx = &mut task::Context::from_waker(task::Waker::noop()); let instance = Instance::new(&InstanceDescriptor { backends: Backends::NOOP, @@ -795,36 +795,3 @@ impl fmt::Display for Error { } } } - -// Copied from [`futures::task::noop_waker`]. -// Needed until MSRV is 1.85 with `task::Waker::noop()` available -#[cfg(feature = "noop")] -mod waker { - use core::ptr::null; - use core::task::{RawWaker, RawWakerVTable, Waker}; - - unsafe fn noop_clone(_data: *const ()) -> RawWaker { - noop_raw_waker() - } - - unsafe fn noop(_data: *const ()) {} - - const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(noop_clone, noop, noop, noop); - - const fn noop_raw_waker() -> RawWaker { - RawWaker::new(null(), &NOOP_WAKER_VTABLE) - } - - /// Get a static reference to a [`Waker`] which - /// does nothing when `wake()` is called on it. - #[inline] - pub fn noop_waker_ref() -> &'static Waker { - struct SyncRawWaker(RawWaker); - unsafe impl Sync for SyncRawWaker {} - - static NOOP_WAKER_INSTANCE: SyncRawWaker = SyncRawWaker(noop_raw_waker()); - - // SAFETY: `Waker` is #[repr(transparent)] over its `RawWaker`. - unsafe { &*(&NOOP_WAKER_INSTANCE.0 as *const RawWaker as *const Waker) } - } -}