From 1ef99401144c1e8805468f8f35a7a7ebea9e774e Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Thu, 27 Mar 2025 14:25:19 -0400 Subject: [PATCH] Reduce repo MSRV from 1.85 to 1.84 (#7425) * Reduce repo MSRV from 1.85 to 1.84 Fixes https://github.com/gfx-rs/wgpu/issues/7409 * Replace usage of task::Waker::noop() * Gate waker code to `noop` feature * Remove unused copied waker function * Remove doctest from copied code --- .github/workflows/ci.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/generate.yml | 2 +- Cargo.toml | 2 +- README.md | 2 +- .../standalone/01_hello_compute/Cargo.toml | 2 +- .../standalone/02_hello_window/Cargo.toml | 2 +- examples/standalone/custom_backend/Cargo.toml | 2 +- naga/xtask/Cargo.toml | 2 +- rust-toolchain.toml | 2 +- wgpu/src/api/device.rs | 35 ++++++++++++++++++- xtask/Cargo.toml | 2 +- 12 files changed, 45 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77ec7c7a5..cc5dce5cd 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 246b3ed6e..d96ed0870 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 907648990..0f758d4a8 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 0b3245ee6..7924888be 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 c397a6ae3..aaf016183 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 c0f79f487..e4e0fedce 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 010d70dd2..c0bec2123 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 efbe58ad5..ec37bca11 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 47453e934..abb4c5734 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 5ec20384e..1ed8cd0e6 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/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 992d8e571..5971b061d 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,36 @@ 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) } + } +} diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 5c5ff7b88..cc22def43 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]