diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 025b2b8aa12..ce18f1b62dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ env: REPO_MSRV: "1.85" # 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.76" + CORE_MSRV: "1.81" # # Environment variables diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index bf8e84eefe9..f5d69924c34 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.76" +rust-version = "1.81" [package.metadata.docs.rs] all-features = true diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 5bb1aad6f21..91f466d2310 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -303,7 +303,7 @@ impl fmt::Display for DeviceMismatch { } } -impl std::error::Error for DeviceMismatch {} +impl core::error::Error for DeviceMismatch {} #[derive(Clone, Debug, Error)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] diff --git a/wgpu-core/src/error.rs b/wgpu-core/src/error.rs index b5881825e69..8c5eb8ab12d 100644 --- a/wgpu-core/src/error.rs +++ b/wgpu-core/src/error.rs @@ -1,6 +1,5 @@ use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec}; -use core::fmt; -use std::error::Error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump +use core::{error::Error, fmt}; use thiserror::Error; diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index c54f9db1c99..0b286494755 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0" # copy the crates it actually uses out of the workspace, so it's meaningful for # them to have less restrictive MSRVs individually than the workspace as a # whole, if their code permits. See `../README.md` for details. -rust-version = "1.76" +rust-version = "1.81" [package.metadata.docs.rs] # Ideally we would enable all the features. diff --git a/wgpu-hal/src/auxil/renderdoc.rs b/wgpu-hal/src/auxil/renderdoc.rs index c5fa96c7941..82750cc3a76 100644 --- a/wgpu-hal/src/auxil/renderdoc.rs +++ b/wgpu-hal/src/auxil/renderdoc.rs @@ -1,6 +1,7 @@ //! RenderDoc integration - #![cfg_attr(not(any(feature = "gles", feature = "vulkan")), allow(dead_code))] +use alloc::format; use alloc::string::String; use core::{ffi, ptr}; diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 0e7acc1884c..71dedf19492 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -440,14 +440,13 @@ impl crate::Instance for Instance { unsafe fn init(desc: &crate::InstanceDescriptor) -> Result { profiling::scope!("Init OpenGL (WGL) Backend"); let opengl_module = - unsafe { LibraryLoader::LoadLibraryA(PCSTR("opengl32.dll\0".as_ptr())) }.map_err( - |e| { + unsafe { LibraryLoader::LoadLibraryA(PCSTR(c"opengl32.dll".as_ptr().cast())) } + .map_err(|e| { crate::InstanceError::with_source( String::from("unable to load the OpenGL library"), e, ) - }, - )?; + })?; let device = create_instance_device()?; let dc = device.dc; diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index cd7139b27de..c68bab6e686 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -240,8 +240,9 @@ extern crate alloc; extern crate wgpu_types as wgt; -// TODO(https://github.com/gfx-rs/wgpu/issues/6826): disable std except on noop and gles-WebGL. -// Requires Rust 1.81 for core::error::Error. +// Each of these backends needs `std` in some fashion; usually `std::thread` functions. +// TODO(https://github.com/gfx-rs/wgpu/issues/6826): gles-WebGL backend should be made no-std +#[cfg(any(dx12, gles, metal, vulkan))] #[macro_use] extern crate std; @@ -290,12 +291,12 @@ use alloc::boxed::Box; use alloc::{borrow::Cow, string::String, sync::Arc, vec::Vec}; use core::{ borrow::Borrow, + error::Error, fmt, num::NonZeroU32, ops::{Range, RangeInclusive}, ptr::NonNull, }; -use std::error::Error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump use bitflags::bitflags; use parking_lot::Mutex; diff --git a/wgpu-hal/src/metal/layer_observer.rs b/wgpu-hal/src/metal/layer_observer.rs index 6f1fade72ec..8acd83b5314 100644 --- a/wgpu-hal/src/metal/layer_observer.rs +++ b/wgpu-hal/src/metal/layer_observer.rs @@ -23,8 +23,8 @@ const NSKeyValueObservingOptionNew: usize = 0x01; #[allow(non_upper_case_globals)] const NSKeyValueObservingOptionInitial: usize = 0x04; -const CONTENTS_SCALE: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"contentsScale\0") }; -const BOUNDS: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"bounds\0") }; +const CONTENTS_SCALE: &CStr = c"contentsScale"; +const BOUNDS: &CStr = c"bounds"; /// Create a new custom layer that tracks parameters from the given super layer. /// diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index a67781dba73..cf216e62f30 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -34,10 +34,8 @@ unsafe extern "system" fn debug_utils_messenger_callback( // https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671 // Versions 1.3.240 through 1.3.250 return a spurious error here if // the debug range start and end appear in different command buffers. - const KHRONOS_VALIDATION_LAYER: &CStr = - unsafe { CStr::from_bytes_with_nul_unchecked(b"Khronos Validation Layer\0") }; if let Some(layer_properties) = user_data.validation_layer_properties.as_ref() { - if layer_properties.layer_description.as_ref() == KHRONOS_VALIDATION_LAYER + if layer_properties.layer_description.as_ref() == c"Khronos Validation Layer" && layer_properties.layer_spec_version >= vk::make_api_version(0, 1, 3, 240) && layer_properties.layer_spec_version <= vk::make_api_version(0, 1, 3, 250) { @@ -611,7 +609,7 @@ impl crate::Instance for super::Instance { let app_info = vk::ApplicationInfo::default() .application_name(app_name.as_c_str()) .application_version(1) - .engine_name(CStr::from_bytes_with_nul(b"wgpu-hal\0").unwrap()) + .engine_name(c"wgpu-hal") .engine_version(2) .api_version( // Vulkan 1.0 doesn't like anything but 1.0 passed in here... @@ -653,8 +651,7 @@ impl crate::Instance for super::Instance { .find(|inst_layer| inst_layer.layer_name_as_c_str() == Ok(name)) } - let validation_layer_name = - CStr::from_bytes_with_nul(b"VK_LAYER_KHRONOS_validation\0").unwrap(); + let validation_layer_name = c"VK_LAYER_KHRONOS_validation"; let validation_layer_properties = find_layer(&instance_layers, validation_layer_name); // Determine if VK_EXT_validation_features is available, so we can enable @@ -678,11 +675,9 @@ impl crate::Instance for super::Instance { .intersects(wgt::InstanceFlags::GPU_BASED_VALIDATION) && validation_features_are_enabled; - let nv_optimus_layer = CStr::from_bytes_with_nul(b"VK_LAYER_NV_optimus\0").unwrap(); - let has_nv_optimus = find_layer(&instance_layers, nv_optimus_layer).is_some(); + let has_nv_optimus = find_layer(&instance_layers, c"VK_LAYER_NV_optimus").is_some(); - let obs_layer = CStr::from_bytes_with_nul(b"VK_LAYER_OBS_HOOK\0").unwrap(); - let has_obs_layer = find_layer(&instance_layers, obs_layer).is_some(); + let has_obs_layer = find_layer(&instance_layers, c"VK_LAYER_OBS_HOOK").is_some(); let mut layers: Vec<&'static CStr> = Vec::new(); diff --git a/wgpu/src/api/surface.rs b/wgpu/src/api/surface.rs index dddfd13ecf8..9c49996bc14 100644 --- a/wgpu/src/api/surface.rs +++ b/wgpu/src/api/surface.rs @@ -1,6 +1,5 @@ use alloc::{boxed::Box, string::String, vec, vec::Vec}; -use core::fmt; -use std::error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump +use core::{error, fmt}; use parking_lot::Mutex; use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; diff --git a/wgpu/src/api/surface_texture.rs b/wgpu/src/api/surface_texture.rs index 16aa4cc3c6f..7ceeffb9550 100644 --- a/wgpu/src/api/surface_texture.rs +++ b/wgpu/src/api/surface_texture.rs @@ -1,5 +1,4 @@ -use core::fmt; -use std::error; // TODO(https://github.com/gfx-rs/wgpu/issues/6826): use core::error after MSRV bump +use core::{error, fmt}; use std::thread; use crate::*;