From 46599bfe544feb722978cfa62f9dc07454db79b0 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Tue, 25 Mar 2025 13:48:58 -0400 Subject: [PATCH 1/5] Reduce repo MSRV from 1.85 to 1.84 Fixes https://github.com/gfx-rs/wgpu/issues/7409 --- .github/workflows/ci.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/generate.yml | 2 +- Cargo.toml | 2 +- README.md | 2 +- examples/standalone/01_hello_compute/Cargo.toml | 2 +- examples/standalone/02_hello_window/Cargo.toml | 2 +- examples/standalone/custom_backend/Cargo.toml | 2 +- naga/xtask/Cargo.toml | 2 +- rust-toolchain.toml | 2 +- xtask/Cargo.toml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38ff5f81c97..f110ca5cdc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ env: CI_BINARY_BUILD: "build20" # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.85" + REPO_MSRV: "1.84" # This is the MSRV used by the `wgpu-core`, `wgpu-hal`, and `wgpu-types` crates, # to ensure that they can be used with firefox. CORE_MSRV: "1.82.0" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 246b3ed6e3e..d96ed087096 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -10,7 +10,7 @@ on: env: # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.85" + REPO_MSRV: "1.84" CARGO_INCREMENTAL: false CARGO_TERM_COLOR: always diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 907648990e6..0f758d4a839 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -13,7 +13,7 @@ env: # # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.85" + REPO_MSRV: "1.84" RUSTFLAGS: -D warnings jobs: diff --git a/Cargo.toml b/Cargo.toml index 31e3bdfd103..09dc9c62854 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ ref_as_ptr = "warn" [workspace.package] edition = "2021" -rust-version = "1.85" +rust-version = "1.84" keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" diff --git a/README.md b/README.md index c397a6ae30b..aaf0161839e 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ On Linux, you can point to them using `LD_LIBRARY_PATH` environment. Due to complex dependants, we have two MSRV policies: - `naga`, `wgpu-core`, `wgpu-hal`, and `wgpu-types`'s MSRV is **1.76**. -- The rest of the workspace has an MSRV of **1.85**. +- The rest of the workspace has an MSRV of **1.84**. It is enforced on CI (in "/.github/workflows/ci.yml") with the `CORE_MSRV` and `REPO_MSRV` variables. This version can only be upgraded in breaking releases, though we release a breaking version every three months. diff --git a/examples/standalone/01_hello_compute/Cargo.toml b/examples/standalone/01_hello_compute/Cargo.toml index c0f79f487f3..e4e0fedce40 100644 --- a/examples/standalone/01_hello_compute/Cargo.toml +++ b/examples/standalone/01_hello_compute/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu-example-01-hello-compute" edition = "2021" -rust-version = "1.85" +rust-version = "1.84" publish = false [dependencies] diff --git a/examples/standalone/02_hello_window/Cargo.toml b/examples/standalone/02_hello_window/Cargo.toml index 010d70dd283..c0bec212385 100644 --- a/examples/standalone/02_hello_window/Cargo.toml +++ b/examples/standalone/02_hello_window/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu-example-02-hello-window" edition = "2021" -rust-version = "1.85" +rust-version = "1.84" publish = false [dependencies] diff --git a/examples/standalone/custom_backend/Cargo.toml b/examples/standalone/custom_backend/Cargo.toml index efbe58ad592..ec37bca1117 100644 --- a/examples/standalone/custom_backend/Cargo.toml +++ b/examples/standalone/custom_backend/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu-example-custom-backend" edition = "2021" -rust-version = "1.85" +rust-version = "1.84" publish = false [dependencies] diff --git a/naga/xtask/Cargo.toml b/naga/xtask/Cargo.toml index 47453e93407..abb4c57340c 100644 --- a/naga/xtask/Cargo.toml +++ b/naga/xtask/Cargo.toml @@ -3,7 +3,7 @@ name = "xtask" version = "0.1.0" edition = "2021" publish = false -rust-version = "1.85" +rust-version = "1.84" [dependencies] anyhow = "1" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5ec20384ef2..1ed8cd0e604 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.85" +channel = "1.84" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 5c5ff7b8815..cc22def4318 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -2,7 +2,7 @@ name = "xtask" version = "0.1.0" edition = "2021" -rust-version = "1.85" +rust-version = "1.84" publish = false [lints.rust] From 9c5e501582c06b622cf9794d534178aeddac0371 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Tue, 25 Mar 2025 14:13:18 -0400 Subject: [PATCH 2/5] Replace usage of task::Waker::noop() --- wgpu/src/api/device.rs | 59 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 992d8e57172..a17ff7ae371 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -51,7 +51,7 @@ impl Device { use core::future::Future as _; use core::pin::pin; use core::task; - let ctx = &mut task::Context::from_waker(task::Waker::noop()); + let ctx = &mut task::Context::from_waker(waker::noop_waker_ref()); let instance = Instance::new(&InstanceDescriptor { backends: Backends::NOOP, @@ -695,3 +695,60 @@ impl fmt::Display for Error { } } } + +// Copied from [`futures::task::noop_waker`]. +// Needed until MSRV is 1.85 with `task::Waker::noop()` available +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) + } + + /// Create a new [`Waker`] which does + /// nothing when `wake()` is called on it. + /// + /// # Examples + /// + /// ``` + /// use futures::task::noop_waker; + /// let waker = noop_waker(); + /// waker.wake(); + /// ``` + #[inline] + #[allow(unused)] + pub fn noop_waker() -> Waker { + // FIXME: Since 1.46.0 we can use transmute in consts, allowing this function to be const. + unsafe { Waker::from_raw(noop_raw_waker()) } + } + + /// Get a static reference to a [`Waker`] which + /// does nothing when `wake()` is called on it. + /// + /// # Examples + /// + /// ``` + /// use futures::task::noop_waker_ref; + /// let waker = noop_waker_ref(); + /// waker.wake_by_ref(); + /// ``` + #[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) } + } +} From dd2ab18dac65e860c282c9ccfef374eb4f583af9 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Tue, 25 Mar 2025 14:17:05 -0400 Subject: [PATCH 3/5] Gate waker code to `noop` feature --- wgpu/src/api/device.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index a17ff7ae371..cffda7a2c47 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -698,6 +698,7 @@ 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}; From de415e88156d6bfa26526818451238a964fc4ea4 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Tue, 25 Mar 2025 14:19:56 -0400 Subject: [PATCH 4/5] Remove unused copied waker function --- wgpu/src/api/device.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index cffda7a2c47..055e9d71343 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -715,23 +715,6 @@ mod waker { RawWaker::new(null(), &NOOP_WAKER_VTABLE) } - /// Create a new [`Waker`] which does - /// nothing when `wake()` is called on it. - /// - /// # Examples - /// - /// ``` - /// use futures::task::noop_waker; - /// let waker = noop_waker(); - /// waker.wake(); - /// ``` - #[inline] - #[allow(unused)] - pub fn noop_waker() -> Waker { - // FIXME: Since 1.46.0 we can use transmute in consts, allowing this function to be const. - unsafe { Waker::from_raw(noop_raw_waker()) } - } - /// Get a static reference to a [`Waker`] which /// does nothing when `wake()` is called on it. /// From d36c665472683d5355a7a50fa833b6ce67bd712b Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Tue, 25 Mar 2025 14:25:10 -0400 Subject: [PATCH 5/5] Remove doctest from copied code --- wgpu/src/api/device.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 055e9d71343..5971b061d89 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -717,14 +717,6 @@ mod waker { /// Get a static reference to a [`Waker`] which /// does nothing when `wake()` is called on it. - /// - /// # Examples - /// - /// ``` - /// use futures::task::noop_waker_ref; - /// let waker = noop_waker_ref(); - /// waker.wake_by_ref(); - /// ``` #[inline] pub fn noop_waker_ref() -> &'static Waker { struct SyncRawWaker(RawWaker);