diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd0eec4925..480667ea45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,12 +34,12 @@ env: # We sometimes need nightly to use special things in CI. # # In order to prevent CI regressions, we pin the nightly version. - NIGHTLY_VERSION: "nightly-2023-12-17" + NIGHTLY_VERSION: "nightly-2024-08-11" # This is the MSRV used by `wgpu` itself and all surrounding infrastructure. - REPO_MSRV: "1.76" + REPO_MSRV: "1.80.1" # 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.80.1" # # Environment variables diff --git a/Cargo.lock b/Cargo.lock index a5ed912f5f..4e420f17de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -461,6 +461,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "cgl" version = "0.3.2" @@ -1345,7 +1351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18fcd4ae4e86d991ad1300b8f57166e5be0c95ef1f63f3f5b827f8a164548746" dependencies = [ "bitflags 2.6.0", - "cfg_aliases", + "cfg_aliases 0.1.1", "cgl", "core-foundation", "dispatch", @@ -1367,7 +1373,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebcdfba24f73b8412c5181e56f092b5eff16671c514ce896b258a0a64bd7735" dependencies = [ - "cfg_aliases", + "cfg_aliases 0.1.1", "glutin", "raw-window-handle 0.5.2", "winit", @@ -2042,7 +2048,7 @@ dependencies = [ "arrayvec", "bit-set", "bitflags 2.6.0", - "cfg_aliases", + "cfg_aliases 0.2.1", "codespan-reporting", "diff", "env_logger", @@ -3787,7 +3793,7 @@ name = "wgpu" version = "23.0.1" dependencies = [ "arrayvec", - "cfg_aliases", + "cfg_aliases 0.2.1", "document-features", "js-sys", "log", @@ -3815,7 +3821,6 @@ dependencies = [ "criterion", "naga", "nanorand", - "once_cell", "pollster", "profiling", "rayon", @@ -3831,7 +3836,7 @@ dependencies = [ "bit-vec", "bitflags 2.6.0", "bytemuck", - "cfg_aliases", + "cfg_aliases 0.2.1", "document-features", "indexmap", "log", @@ -3892,7 +3897,7 @@ dependencies = [ "block", "bytemuck", "cfg-if", - "cfg_aliases", + "cfg_aliases 0.2.1", "core-graphics-types", "env_logger", "glam", @@ -3913,7 +3918,6 @@ dependencies = [ "naga", "ndk-sys", "objc", - "once_cell", "parking_lot", "profiling", "range-alloc", @@ -4335,7 +4339,7 @@ dependencies = [ "bitflags 2.6.0", "bytemuck", "calloop", - "cfg_aliases", + "cfg_aliases 0.1.1", "core-foundation", "core-graphics", "cursor-icon", diff --git a/Cargo.toml b/Cargo.toml index a46e7599e1..8093055845 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ default-members = [ [workspace.package] edition = "2021" -rust-version = "1.76" +rust-version = "1.80.1" keywords = ["graphics"] license = "MIT OR Apache-2.0" homepage = "https://wgpu.rs/" @@ -77,7 +77,7 @@ bincode = "1" bit-vec = "0.8" bitflags = "2.6" bytemuck = { version = "1.20" } -cfg_aliases = "0.1" +cfg_aliases = "0.2.1" cfg-if = "1" criterion = "0.5" codespan-reporting = "0.11" diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 82207d5105..d3e4966502 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -21,6 +21,11 @@ path = "benches/root.rs" # tracy = ["dep:tracy-client", "profiling/profile-with-tracy"] # superluminal = ["profiling/profile-with-superluminal"] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(feature, values("tracy"))', +] } + [dependencies] bincode.workspace = true bytemuck.workspace = true @@ -38,7 +43,6 @@ naga = { workspace = true, features = [ "wgsl-out", ] } nanorand.workspace = true -once_cell.workspace = true pollster.workspace = true profiling.workspace = true rayon.workspace = true diff --git a/benches/benches/computepass.rs b/benches/benches/computepass.rs index a8e693974f..1ac14c092a 100644 --- a/benches/benches/computepass.rs +++ b/benches/benches/computepass.rs @@ -5,8 +5,8 @@ use std::{ use criterion::{criterion_group, Criterion, Throughput}; use nanorand::{Rng, WyRand}; -use once_cell::sync::Lazy; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::sync::LazyLock; use crate::DeviceState; @@ -424,7 +424,7 @@ impl ComputepassState { } fn run_bench(ctx: &mut Criterion) { - let state = Lazy::new(ComputepassState::new); + let state = LazyLock::new(ComputepassState::new); let dispatch_count = dispatch_count(); let dispatch_count_bindless = dispatch_count_bindless(); @@ -449,7 +449,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{cpasses} computepasses x {dispatch_per_pass} dispatches ({label})"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -498,7 +498,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{threads} threads x {dispatch_per_pass} dispatch"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -538,7 +538,7 @@ fn run_bench(ctx: &mut Criterion) { group.throughput(Throughput::Elements(dispatch_count_bindless as _)); group.bench_function(format!("{dispatch_count_bindless} dispatch"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -579,7 +579,7 @@ fn run_bench(ctx: &mut Criterion) { texture_count + storage_texture_count + storage_buffer_count ), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter(|| state.device_state.queue.submit([])); }, diff --git a/benches/benches/renderpass.rs b/benches/benches/renderpass.rs index 7f4ab06bbc..5471fb94c4 100644 --- a/benches/benches/renderpass.rs +++ b/benches/benches/renderpass.rs @@ -5,8 +5,8 @@ use std::{ use criterion::{criterion_group, Criterion, Throughput}; use nanorand::{Rng, WyRand}; -use once_cell::sync::Lazy; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::sync::LazyLock; use crate::DeviceState; @@ -427,7 +427,7 @@ impl RenderpassState { } fn run_bench(ctx: &mut Criterion) { - let state = Lazy::new(RenderpassState::new); + let state = LazyLock::new(RenderpassState::new); let draw_count = draw_count(); let vertex_buffer_count = draw_count * VERTEX_BUFFERS_PER_DRAW; @@ -450,7 +450,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{rpasses} renderpasses x {draws_per_pass} draws ({label})"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -502,7 +502,7 @@ fn run_bench(ctx: &mut Criterion) { for threads in [2, 4, 8] { let draws_per_pass = draw_count / threads; group.bench_function(format!("{threads} threads x {draws_per_pass} draws"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -541,7 +541,7 @@ fn run_bench(ctx: &mut Criterion) { group.throughput(Throughput::Elements(draw_count as _)); group.bench_function(format!("{draw_count} draws"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); @@ -577,7 +577,7 @@ fn run_bench(ctx: &mut Criterion) { texture_count + vertex_buffer_count ), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter(|| state.device_state.queue.submit([])); }, diff --git a/benches/benches/resource_creation.rs b/benches/benches/resource_creation.rs index da0c79a406..8423192ddc 100644 --- a/benches/benches/resource_creation.rs +++ b/benches/benches/resource_creation.rs @@ -1,13 +1,13 @@ use std::time::{Duration, Instant}; use criterion::{criterion_group, Criterion, Throughput}; -use once_cell::sync::Lazy; use rayon::iter::{IntoParallelIterator, ParallelIterator}; +use std::sync::LazyLock; use crate::DeviceState; fn run_bench(ctx: &mut Criterion) { - let state = Lazy::new(DeviceState::new); + let state = LazyLock::new(DeviceState::new); const RESOURCES_TO_CREATE: usize = 8; @@ -19,7 +19,7 @@ fn run_bench(ctx: &mut Criterion) { group.bench_function( format!("{threads} threads x {resources_per_thread} resource"), |b| { - Lazy::force(&state); + LazyLock::force(&state); b.iter_custom(|iters| { profiling::scope!("benchmark invocation"); diff --git a/examples/src/boids/mod.rs b/examples/src/boids/mod.rs index 53e4239f39..6971a3ef18 100644 --- a/examples/src/boids/mod.rs +++ b/examples/src/boids/mod.rs @@ -2,7 +2,6 @@ // adapted from https://github.com/austinEng/webgpu-samples/blob/master/src/examples/computeBoids.ts use nanorand::{Rng, WyRand}; -use std::mem::size_of; use wgpu::util::DeviceExt; // number of boid particles to simulate diff --git a/examples/src/bunnymark/mod.rs b/examples/src/bunnymark/mod.rs index 56b0eb730c..9158d17c11 100644 --- a/examples/src/bunnymark/mod.rs +++ b/examples/src/bunnymark/mod.rs @@ -1,6 +1,6 @@ use bytemuck::{Pod, Zeroable}; use nanorand::{Rng, WyRand}; -use std::{borrow::Cow, mem::size_of}; +use std::borrow::Cow; use wgpu::util::DeviceExt; use winit::{ event::{ElementState, KeyEvent}, diff --git a/examples/src/cube/mod.rs b/examples/src/cube/mod.rs index 984592d442..ddeeadc6be 100644 --- a/examples/src/cube/mod.rs +++ b/examples/src/cube/mod.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{f32::consts, mem::size_of}; +use std::f32::consts; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/hello_compute/mod.rs b/examples/src/hello_compute/mod.rs index 60de01b074..cc9f5aa81f 100644 --- a/examples/src/hello_compute/mod.rs +++ b/examples/src/hello_compute/mod.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of_val, str::FromStr}; +use std::str::FromStr; use wgpu::util::DeviceExt; // Indicates a u32 overflow in an intermediate Collatz value diff --git a/examples/src/hello_synchronization/mod.rs b/examples/src/hello_synchronization/mod.rs index 128609bb97..fee20eeafa 100644 --- a/examples/src/hello_synchronization/mod.rs +++ b/examples/src/hello_synchronization/mod.rs @@ -1,5 +1,3 @@ -use std::mem::size_of_val; - const ARR_SIZE: usize = 128; struct ExecuteResults { diff --git a/examples/src/hello_workgroups/mod.rs b/examples/src/hello_workgroups/mod.rs index 26b6cccfe5..13535f79c7 100644 --- a/examples/src/hello_workgroups/mod.rs +++ b/examples/src/hello_workgroups/mod.rs @@ -7,8 +7,6 @@ //! //! Only parts specific to this example will be commented. -use std::mem::size_of_val; - use wgpu::util::DeviceExt; async fn run() { diff --git a/examples/src/mipmap/mod.rs b/examples/src/mipmap/mod.rs index fa5bedf8cb..0b5f1de764 100644 --- a/examples/src/mipmap/mod.rs +++ b/examples/src/mipmap/mod.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{f32::consts, mem::size_of}; +use std::f32::consts; use wgpu::util::DeviceExt; const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb; diff --git a/examples/src/msaa_line/mod.rs b/examples/src/msaa_line/mod.rs index 1f49b90f4a..d2cbe62018 100644 --- a/examples/src/msaa_line/mod.rs +++ b/examples/src/msaa_line/mod.rs @@ -7,7 +7,7 @@ //! * Set the primitive_topology to PrimitiveTopology::LineList. //! * Vertices and Indices describe the two points that make up a line. -use std::{iter, mem::size_of}; +use std::iter; use bytemuck::{Pod, Zeroable}; use wgpu::util::DeviceExt; diff --git a/examples/src/repeated_compute/mod.rs b/examples/src/repeated_compute/mod.rs index a84ab4ed67..d5b29c7baa 100644 --- a/examples/src/repeated_compute/mod.rs +++ b/examples/src/repeated_compute/mod.rs @@ -5,8 +5,6 @@ //! hello-compute example does not such as mapping buffers //! and why use the async channels. -use std::mem::size_of_val; - const OVERFLOW: u32 = 0xffffffff; async fn run() { diff --git a/examples/src/shadow/mod.rs b/examples/src/shadow/mod.rs index 44ad84a73f..109fae8a76 100644 --- a/examples/src/shadow/mod.rs +++ b/examples/src/shadow/mod.rs @@ -1,4 +1,4 @@ -use std::{f32::consts, iter, mem::size_of, ops::Range, sync::Arc}; +use std::{f32::consts, iter, ops::Range, sync::Arc}; use bytemuck::{Pod, Zeroable}; use wgpu::util::{align_to, DeviceExt}; diff --git a/examples/src/skybox/mod.rs b/examples/src/skybox/mod.rs index 095a1e9fbb..b772935cdd 100644 --- a/examples/src/skybox/mod.rs +++ b/examples/src/skybox/mod.rs @@ -1,5 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{f32::consts, mem::size_of}; +use std::f32::consts; use wgpu::{util::DeviceExt, AstcBlock, AstcChannel}; const IMAGE_SIZE: u32 = 256; diff --git a/examples/src/srgb_blend/mod.rs b/examples/src/srgb_blend/mod.rs index ac0343f690..d56cea7bce 100644 --- a/examples/src/srgb_blend/mod.rs +++ b/examples/src/srgb_blend/mod.rs @@ -1,5 +1,4 @@ use bytemuck::{Pod, Zeroable}; -use std::mem::size_of; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/stencil_triangles/mod.rs b/examples/src/stencil_triangles/mod.rs index fcd37f813e..761a9ef602 100644 --- a/examples/src/stencil_triangles/mod.rs +++ b/examples/src/stencil_triangles/mod.rs @@ -1,5 +1,4 @@ use bytemuck::{Pod, Zeroable}; -use std::mem::size_of; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/storage_texture/mod.rs b/examples/src/storage_texture/mod.rs index 7fcafecca2..7c647835a3 100644 --- a/examples/src/storage_texture/mod.rs +++ b/examples/src/storage_texture/mod.rs @@ -14,8 +14,6 @@ //! A lot of things aren't explained here via comments. See hello-compute and //! repeated-compute for code that is more thoroughly commented. -use std::mem::size_of_val; - #[cfg(not(target_arch = "wasm32"))] use crate::utils::output_image_native; #[cfg(target_arch = "wasm32")] diff --git a/examples/src/texture_arrays/mod.rs b/examples/src/texture_arrays/mod.rs index 26c39a6cc2..7cac05c384 100644 --- a/examples/src/texture_arrays/mod.rs +++ b/examples/src/texture_arrays/mod.rs @@ -1,8 +1,5 @@ use bytemuck::{Pod, Zeroable}; -use std::{ - mem::size_of, - num::{NonZeroU32, NonZeroU64}, -}; +use std::num::{NonZeroU32, NonZeroU64}; use wgpu::util::DeviceExt; #[repr(C)] diff --git a/examples/src/timestamp_queries/mod.rs b/examples/src/timestamp_queries/mod.rs index 69f5c57dd6..9ed80a8b93 100644 --- a/examples/src/timestamp_queries/mod.rs +++ b/examples/src/timestamp_queries/mod.rs @@ -17,8 +17,6 @@ //! The period, i.e. the unit of time, of the timestamps in wgpu is undetermined and needs to be queried with `wgpu::Queue::get_timestamp_period` //! in order to get comparable results. -use std::mem::size_of; - use wgpu::util::DeviceExt; struct Queries { diff --git a/examples/src/uniform_values/mod.rs b/examples/src/uniform_values/mod.rs index a5c1e14c54..e58e18a2b5 100644 --- a/examples/src/uniform_values/mod.rs +++ b/examples/src/uniform_values/mod.rs @@ -16,7 +16,7 @@ //! The usage of the uniform buffer within the shader itself is pretty self-explanatory given //! some understanding of WGSL. -use std::{mem::size_of, sync::Arc}; +use std::sync::Arc; // We won't bring StorageBuffer into scope as that might be too easy to confuse // with actual GPU-allocated WGPU storage buffers. use encase::ShaderType; diff --git a/examples/src/water/mod.rs b/examples/src/water/mod.rs index a60dc0279e..7e2980f43c 100644 --- a/examples/src/water/mod.rs +++ b/examples/src/water/mod.rs @@ -3,7 +3,7 @@ mod point_gen; use bytemuck::{Pod, Zeroable}; use glam::Vec3; use nanorand::{Rng, WyRand}; -use std::{f32::consts, iter, mem::size_of}; +use std::{f32::consts, iter}; use wgpu::util::DeviceExt; /// diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 818713e6f8..9c0271fa6e 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -15,7 +15,7 @@ autotests = false # 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.80.0" [[test]] name = "naga-test" diff --git a/naga/src/back/msl/mod.rs b/naga/src/back/msl/mod.rs index 0c85c8a9e4..ff6488a8f8 100644 --- a/naga/src/back/msl/mod.rs +++ b/naga/src/back/msl/mod.rs @@ -697,6 +697,5 @@ pub fn write_string( #[test] fn test_error_size() { - use std::mem::size_of; assert_eq!(size_of::(), 32); } diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index edd13313e5..083cada100 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -17,9 +17,6 @@ use std::ops::Range; use termcolor::{ColorChoice, NoColor, StandardStream}; use thiserror::Error; -#[cfg(test)] -use std::mem::size_of; - #[derive(Clone, Debug)] pub struct ParseError { message: String, diff --git a/naga/src/non_max_u32.rs b/naga/src/non_max_u32.rs index 2ad402e497..7cb641b4e9 100644 --- a/naga/src/non_max_u32.rs +++ b/naga/src/non_max_u32.rs @@ -140,6 +140,5 @@ impl<'de> serde::Deserialize<'de> for NonMaxU32 { #[test] fn size() { - use core::mem::size_of; assert_eq!(size_of::>(), size_of::()); } diff --git a/naga/src/proc/typifier.rs b/naga/src/proc/typifier.rs index 1e1a4c93a4..ab5698f4e3 100644 --- a/naga/src/proc/typifier.rs +++ b/naga/src/proc/typifier.rs @@ -918,6 +918,5 @@ impl<'a> ResolveContext<'a> { #[test] fn test_error_size() { - use std::mem::size_of; assert_eq!(size_of::(), 32); } diff --git a/player/tests/test.rs b/player/tests/test.rs index f9cad8b4ea..26b59eea70 100644 --- a/player/tests/test.rs +++ b/player/tests/test.rs @@ -14,7 +14,6 @@ use player::GlobalPlay; use std::{ fs::{read_to_string, File}, io::{Read, Seek, SeekFrom}, - mem::size_of, path::{Path, PathBuf}, slice, }; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 45bb8d6d51..a561eb92f0 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.76" +channel = "1.80.1" components = ["rustfmt", "clippy"] targets = ["wasm32-unknown-unknown"] diff --git a/tests/tests/compute_pass_ownership.rs b/tests/tests/compute_pass_ownership.rs index df50f51e05..c05185828e 100644 --- a/tests/tests/compute_pass_ownership.rs +++ b/tests/tests/compute_pass_ownership.rs @@ -1,7 +1,7 @@ //! Tests that compute passes take ownership of resources that are associated with. //! I.e. once a resource is passed in to a compute pass, it can be dropped. -use std::{mem::size_of, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu::util::DeviceExt as _; use wgpu_test::{gpu_test, valid, GpuTestConfiguration, TestParameters, TestingContext}; diff --git a/tests/tests/occlusion_query/mod.rs b/tests/tests/occlusion_query/mod.rs index 2cedab0299..98c50095ae 100644 --- a/tests/tests/occlusion_query/mod.rs +++ b/tests/tests/occlusion_query/mod.rs @@ -1,4 +1,3 @@ -use std::mem::size_of; use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration, TestParameters}; #[gpu_test] diff --git a/tests/tests/render_pass_ownership.rs b/tests/tests/render_pass_ownership.rs index 7c41c85916..cdbd1f45ff 100644 --- a/tests/tests/render_pass_ownership.rs +++ b/tests/tests/render_pass_ownership.rs @@ -9,7 +9,7 @@ //! * rpass.multi_draw_indirect_count //! * rpass.multi_draw_indexed_indirect_count //! -use std::{mem::size_of, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu::util::DeviceExt as _; use wgpu_test::{gpu_test, valid, GpuTestConfiguration, TestParameters, TestingContext}; diff --git a/tests/tests/subgroup_operations/mod.rs b/tests/tests/subgroup_operations/mod.rs index 84de70ee5e..25fddf120d 100644 --- a/tests/tests/subgroup_operations/mod.rs +++ b/tests/tests/subgroup_operations/mod.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters}; diff --git a/tests/tests/vertex_formats/mod.rs b/tests/tests/vertex_formats/mod.rs index c8a538c4f6..2f2b16a9c7 100644 --- a/tests/tests/vertex_formats/mod.rs +++ b/tests/tests/vertex_formats/mod.rs @@ -1,6 +1,6 @@ //! Tests that vertex formats pass through to vertex shaders accurately. -use std::{mem::size_of_val, num::NonZeroU64}; +use std::num::NonZeroU64; use wgpu::util::{BufferInitDescriptor, DeviceExt}; diff --git a/tests/tests/vertex_indices/mod.rs b/tests/tests/vertex_indices/mod.rs index 300a97eeb8..7dd4779964 100644 --- a/tests/tests/vertex_indices/mod.rs +++ b/tests/tests/vertex_indices/mod.rs @@ -3,7 +3,7 @@ //! We need tests for these as the backends use various schemes to work around the lack //! of support for things like `gl_BaseInstance` in shaders. -use std::{mem::size_of_val, num::NonZeroU64, ops::Range}; +use std::{num::NonZeroU64, ops::Range}; use itertools::Itertools; use strum::IntoEnumIterator; diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 6f2be185c9..3d5b8de251 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.80.0" [package.metadata.docs.rs] all-features = true diff --git a/wgpu-core/build.rs b/wgpu-core/build.rs index 2f715fdb2a..1dfa8f035e 100644 --- a/wgpu-core/build.rs +++ b/wgpu-core/build.rs @@ -10,4 +10,6 @@ fn main() { metal: { all(any(target_os = "ios", target_os = "macos"), feature = "metal") }, vulkan: { all(not(target_arch = "wasm32"), feature = "vulkan") } } + println!("cargo::rustc-check-cfg=cfg(wgpu_core_doc)"); + println!("cargo::rustc-check-cfg=cfg(wgpu_validate_locks)"); } diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index ac7a5280bf..a6d1e39710 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -103,7 +103,7 @@ use crate::{ }; use arrayvec::ArrayVec; -use std::{borrow::Cow, mem::size_of, num::NonZeroU32, ops::Range, sync::Arc}; +use std::{borrow::Cow, num::NonZeroU32, ops::Range, sync::Arc}; use thiserror::Error; use super::{ diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 44b65b6d6e..18b8e88703 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -30,7 +30,7 @@ use wgt::{BufferAddress, DynamicOffset}; use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions}; use crate::ray_tracing::TlasAction; -use std::{fmt, mem::size_of, str, sync::Arc}; +use std::{fmt, str, sync::Arc}; pub struct ComputePass { /// All pass data & records is stored here. diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 788c85e5c6..8d273d2b39 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -45,7 +45,7 @@ use serde::Deserialize; #[cfg(feature = "serde")] use serde::Serialize; -use std::{borrow::Cow, fmt, iter, mem::size_of, num::NonZeroU32, ops::Range, str, sync::Arc}; +use std::{borrow::Cow, fmt, iter, num::NonZeroU32, ops::Range, str, sync::Arc}; use super::render_command::ArcRenderCommand; use super::{ diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index fbf366982d..96a0b7a25e 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -4,7 +4,6 @@ use std::{ fmt::{self, Debug}, hash::Hash, marker::PhantomData, - mem::size_of, num::NonZeroU64, }; use wgt::WasmNotSendSync; diff --git a/wgpu-core/src/indirect_validation.rs b/wgpu-core/src/indirect_validation.rs index 3045965435..aa9ecbbab6 100644 --- a/wgpu-core/src/indirect_validation.rs +++ b/wgpu-core/src/indirect_validation.rs @@ -1,4 +1,3 @@ -use std::mem::size_of; use std::num::NonZeroU64; use thiserror::Error; diff --git a/wgpu-core/src/lib.rs b/wgpu-core/src/lib.rs index 9362eeeb93..e619d35507 100644 --- a/wgpu-core/src/lib.rs +++ b/wgpu-core/src/lib.rs @@ -42,6 +42,7 @@ )] #![warn( clippy::ptr_as_ptr, + clippy::ref_as_ptr, trivial_casts, trivial_numeric_casts, unsafe_op_in_unsafe_fn, diff --git a/wgpu-core/src/pipeline_cache.rs b/wgpu-core/src/pipeline_cache.rs index e506d2cd5b..057223fb57 100644 --- a/wgpu-core/src/pipeline_cache.rs +++ b/wgpu-core/src/pipeline_cache.rs @@ -1,5 +1,3 @@ -use std::mem::size_of; - use thiserror::Error; use wgt::AdapterInfo; diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index b3349235e9..aded1a3c72 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of, sync::Arc}; +use std::sync::Arc; use crate::{ id::Id, diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 968c65be60..7cdd206ae6 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.80.0" [package.metadata.docs.rs] # Ideally we would enable all the features. @@ -108,6 +108,9 @@ device_lost_panic = [] # Only affects the d3d12 and vulkan backends. internal_error_panic = [] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(web_sys_unstable_apis)'] } + [[example]] name = "halmark" @@ -121,7 +124,6 @@ parking_lot.workspace = true profiling = { workspace = true, default-features = false } raw-window-handle.workspace = true thiserror.workspace = true -once_cell.workspace = true # backends common arrayvec.workspace = true diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 1418e67191..05b7db14f0 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -14,9 +14,7 @@ use winit::{ use std::{ borrow::{Borrow, Cow}, - iter, - mem::size_of, - ptr, + iter, ptr, time::Instant, }; diff --git a/wgpu-hal/examples/ray-traced-triangle/main.rs b/wgpu-hal/examples/ray-traced-triangle/main.rs index b81ef86525..2d63038f39 100644 --- a/wgpu-hal/examples/ray-traced-triangle/main.rs +++ b/wgpu-hal/examples/ray-traced-triangle/main.rs @@ -8,9 +8,7 @@ use raw_window_handle::{HasDisplayHandle, HasWindowHandle}; use glam::{Affine3A, Mat4, Vec3}; use std::{ borrow::{Borrow, Cow}, - iter, - mem::size_of, - ptr, + iter, ptr, time::Instant, }; use winit::window::WindowButtons; diff --git a/wgpu-hal/src/auxil/dxgi/time.rs b/wgpu-hal/src/auxil/dxgi/time.rs index 1b312fd651..752a4845a6 100644 --- a/wgpu-hal/src/auxil/dxgi/time.rs +++ b/wgpu-hal/src/auxil/dxgi/time.rs @@ -62,7 +62,11 @@ impl PresentationTimer { let kernelbase = libloading::os::windows::Library::open_already_loaded("kernelbase.dll").unwrap(); // No concerns about lifetimes here as kernelbase is always there. - let ptr = unsafe { kernelbase.get(b"QueryInterruptTimePrecise\0").unwrap() }; + let ptr = unsafe { + kernelbase + .get(c"QueryInterruptTimePrecise".to_bytes()) + .unwrap() + }; Self::IPresentationManager { fnQueryInterruptTimePrecise: *ptr, } diff --git a/wgpu-hal/src/auxil/renderdoc.rs b/wgpu-hal/src/auxil/renderdoc.rs index 3879bb9545..a18c63aed5 100644 --- a/wgpu-hal/src/auxil/renderdoc.rs +++ b/wgpu-hal/src/auxil/renderdoc.rs @@ -69,7 +69,7 @@ impl RenderDoc { }; let get_api: libloading::Symbol = - match unsafe { renderdoc_lib.get(b"RENDERDOC_GetAPI\0") } { + match unsafe { renderdoc_lib.get(c"RENDERDOC_GetAPI".to_bytes()) } { Ok(api) => api, Err(e) => { return RenderDoc::NotAvailable { diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index e9be55c1f8..eee841356a 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -1,9 +1,4 @@ -use std::{ - mem::{size_of, size_of_val}, - ptr, - sync::Arc, - thread, -}; +use std::{ptr, sync::Arc, thread}; use parking_lot::Mutex; use windows::{ diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index a983a92011..57d56fae92 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -1,6 +1,5 @@ use std::{ - ffi, - mem::{self, size_of, size_of_val}, + ffi, mem, num::NonZeroU32, ptr, sync::Arc, @@ -25,7 +24,7 @@ use crate::{ }; // this has to match Naga's HLSL backend, and also needs to be null-terminated -const NAGA_LOCATION_SEMANTIC: &[u8] = b"LOC\0"; +const NAGA_LOCATION_SEMANTIC: &[u8] = c"LOC".to_bytes(); impl super::Device { pub(super) fn new( diff --git a/wgpu-hal/src/dx12/instance.rs b/wgpu-hal/src/dx12/instance.rs index 17fe1236e5..339d72451d 100644 --- a/wgpu-hal/src/dx12/instance.rs +++ b/wgpu-hal/src/dx12/instance.rs @@ -1,4 +1,4 @@ -use std::{mem::size_of_val, sync::Arc}; +use std::sync::Arc; use parking_lot::RwLock; use windows::{ diff --git a/wgpu-hal/src/dx12/mod.rs b/wgpu-hal/src/dx12/mod.rs index e0f27119df..930490aa95 100644 --- a/wgpu-hal/src/dx12/mod.rs +++ b/wgpu-hal/src/dx12/mod.rs @@ -116,7 +116,8 @@ impl D3D12Lib { riid: *const windows_core::GUID, ppdevice: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"D3D12CreateDevice\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"D3D12CreateDevice".to_bytes()) }?; let mut result__: Option = None; @@ -157,7 +158,7 @@ impl D3D12Lib { pperrorblob: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; let func: libloading::Symbol = - unsafe { self.lib.get(b"D3D12SerializeRootSignature\0") }?; + unsafe { self.lib.get(c"D3D12SerializeRootSignature".to_bytes()) }?; let desc = Direct3D12::D3D12_ROOT_SIGNATURE_DESC { NumParameters: parameters.len() as _, @@ -196,7 +197,8 @@ impl D3D12Lib { riid: *const windows_core::GUID, ppvdebug: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"D3D12GetDebugInterface\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"D3D12GetDebugInterface".to_bytes()) }?; let mut result__ = None; @@ -233,7 +235,8 @@ impl DxgiLib { riid: *const windows_core::GUID, pdebug: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"DXGIGetDebugInterface1\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"DXGIGetDebugInterface1".to_bytes()) }?; let mut result__ = None; @@ -262,7 +265,8 @@ impl DxgiLib { riid: *const windows_core::GUID, ppfactory: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"CreateDXGIFactory2\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"CreateDXGIFactory2".to_bytes()) }?; let mut result__ = None; @@ -284,7 +288,8 @@ impl DxgiLib { riid: *const windows_core::GUID, ppfactory: *mut *mut core::ffi::c_void, ) -> windows_core::HRESULT; - let func: libloading::Symbol = unsafe { self.lib.get(b"CreateDXGIFactory1\0") }?; + let func: libloading::Symbol = + unsafe { self.lib.get(c"CreateDXGIFactory1".to_bytes()) }?; let mut result__ = None; diff --git a/wgpu-hal/src/dx12/shader_compilation.rs b/wgpu-hal/src/dx12/shader_compilation.rs index 9739627017..e030c28c64 100644 --- a/wgpu-hal/src/dx12/shader_compilation.rs +++ b/wgpu-hal/src/dx12/shader_compilation.rs @@ -112,7 +112,7 @@ impl DxcLib { -> windows_core::HRESULT; let func: libloading::Symbol = - self.lib.get(b"DxcCreateInstance\0")?; + self.lib.get(c"DxcCreateInstance".to_bytes())?; dxc_create_instance::(|clsid, iid, ppv| func(clsid, iid, ppv)) } } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index a95511908e..b8b2535b5e 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -200,7 +200,9 @@ impl super::Adapter { // emscripten doesn't enable "WEBGL_debug_renderer_info" extension by default. so, we do it manually. // See https://github.com/gfx-rs/wgpu/issues/3245 for context #[cfg(Emscripten)] - if unsafe { super::emscripten::enable_extension("WEBGL_debug_renderer_info\0") } { + if unsafe { + super::emscripten::enable_extension(c"WEBGL_debug_renderer_info".to_str().unwrap()) + } { (GL_UNMASKED_VENDOR_WEBGL, GL_UNMASKED_RENDERER_WEBGL) } else { (glow::VENDOR, glow::RENDERER) diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 0f495b4834..032367db86 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -1,9 +1,6 @@ use super::{conv, Command as C}; use arrayvec::ArrayVec; -use std::{ - mem::{self, size_of, size_of_val}, - ops::Range, -}; +use std::{mem, ops::Range}; #[derive(Clone, Copy, Debug, Default)] struct TextureSlotDesc { diff --git a/wgpu-hal/src/gles/egl.rs b/wgpu-hal/src/gles/egl.rs index 42aec2b253..6eee4ba8e8 100644 --- a/wgpu-hal/src/gles/egl.rs +++ b/wgpu-hal/src/gles/egl.rs @@ -1,9 +1,9 @@ use glow::HasContext; -use once_cell::sync::Lazy; use parking_lot::{MappedMutexGuard, Mutex, MutexGuard, RwLock}; use std::{ - collections::HashMap, ffi, mem::ManuallyDrop, os::raw, ptr, rc::Rc, sync::Arc, time::Duration, + collections::HashMap, ffi, mem::ManuallyDrop, os::raw, ptr, rc::Rc, sync::Arc, sync::LazyLock, + time::Duration, }; /// The amount of time to wait while trying to obtain a lock to the adapter context @@ -143,7 +143,7 @@ impl Drop for DisplayOwner { match self.display { DisplayRef::X11(ptr) => unsafe { let func: libloading::Symbol = - self.library.get(b"XCloseDisplay\0").unwrap(); + self.library.get(c"XCloseDisplay".to_bytes()).unwrap(); func(ptr.as_ptr()); }, DisplayRef::Wayland => {} @@ -155,7 +155,8 @@ fn open_x_display() -> Option { log::debug!("Loading X11 library to get the current display"); unsafe { let library = find_library(&["libX11.so.6", "libX11.so"])?; - let func: libloading::Symbol = library.get(b"XOpenDisplay\0").unwrap(); + let func: libloading::Symbol = + library.get(c"XOpenDisplay".to_bytes()).unwrap(); let result = func(ptr::null()); ptr::NonNull::new(result).map(|ptr| DisplayOwner { display: DisplayRef::X11(ptr), @@ -181,10 +182,12 @@ fn test_wayland_display() -> Option { log::debug!("Loading Wayland library to get the current display"); let library = unsafe { let client_library = find_library(&["libwayland-client.so.0", "libwayland-client.so"])?; - let wl_display_connect: libloading::Symbol = - client_library.get(b"wl_display_connect\0").unwrap(); - let wl_display_disconnect: libloading::Symbol = - client_library.get(b"wl_display_disconnect\0").unwrap(); + let wl_display_connect: libloading::Symbol = client_library + .get(c"wl_display_connect".to_bytes()) + .unwrap(); + let wl_display_disconnect: libloading::Symbol = client_library + .get(c"wl_display_disconnect".to_bytes()) + .unwrap(); let display = ptr::NonNull::new(wl_display_connect(ptr::null()))?; wl_display_disconnect(display.as_ptr()); find_library(&["libwayland-egl.so.1", "libwayland-egl.so"])? @@ -466,7 +469,8 @@ struct Inner { // Different calls to `eglGetPlatformDisplay` may return the same `Display`, making it a global // state of all our `EglContext`s. This forces us to track the number of such context to prevent // terminating the display if it's currently used by another `EglContext`. -static DISPLAYS_REFERENCE_COUNT: Lazy>> = Lazy::new(Default::default); +static DISPLAYS_REFERENCE_COUNT: LazyLock>> = + LazyLock::new(Default::default); fn initialize_display( egl: &EglInstance, @@ -1296,7 +1300,7 @@ impl crate::Surface for Surface { (WindowKind::Wayland, Rwh::Wayland(handle)) => { let library = &self.wsi.display_owner.as_ref().unwrap().library; let wl_egl_window_create: libloading::Symbol = - unsafe { library.get(b"wl_egl_window_create\0") }.unwrap(); + unsafe { library.get(c"wl_egl_window_create".to_bytes()) }.unwrap(); let window = unsafe { wl_egl_window_create(handle.surface.as_ptr(), 640, 480) } .cast(); @@ -1405,7 +1409,7 @@ impl crate::Surface for Surface { if let Some(window) = wl_window { let library = &self.wsi.display_owner.as_ref().unwrap().library; let wl_egl_window_resize: libloading::Symbol = - unsafe { library.get(b"wl_egl_window_resize\0") }.unwrap(); + unsafe { library.get(c"wl_egl_window_resize".to_bytes()) }.unwrap(); unsafe { wl_egl_window_resize( window, @@ -1477,7 +1481,7 @@ impl crate::Surface for Surface { .expect("unsupported window") .library; let wl_egl_window_destroy: libloading::Symbol = - unsafe { library.get(b"wl_egl_window_destroy\0") }.unwrap(); + unsafe { library.get(c"wl_egl_window_destroy".to_bytes()) }.unwrap(); unsafe { wl_egl_window_destroy(window) }; } } diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 8896aa4ed0..061d8fda61 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -2,7 +2,6 @@ use super::{conv::is_layered_target, Command as C, PrivateCapabilities}; use arrayvec::ArrayVec; use glow::HasContext; use std::{ - mem::size_of, slice, sync::{atomic::Ordering, Arc}, }; diff --git a/wgpu-hal/src/gles/wgl.rs b/wgpu-hal/src/gles/wgl.rs index 2d6c91aee0..b9b76d250b 100644 --- a/wgpu-hal/src/gles/wgl.rs +++ b/wgpu-hal/src/gles/wgl.rs @@ -1,12 +1,12 @@ use std::{ collections::HashSet, ffi::{c_void, CStr, CString}, - mem::{self, size_of, size_of_val, ManuallyDrop}, + mem::{self, ManuallyDrop}, os::raw::c_int, ptr, sync::{ mpsc::{sync_channel, SyncSender}, - Arc, + Arc, LazyLock, }, thread, time::Duration, @@ -17,7 +17,6 @@ use glutin_wgl_sys::wgl_extra::{ Wgl, CONTEXT_CORE_PROFILE_BIT_ARB, CONTEXT_DEBUG_BIT_ARB, CONTEXT_FLAGS_ARB, CONTEXT_PROFILE_MASK_ARB, }; -use once_cell::sync::Lazy; use parking_lot::{Mutex, MutexGuard, RwLock}; use raw_window_handle::{RawDisplayHandle, RawWindowHandle}; use wgt::InstanceFlags; @@ -319,8 +318,8 @@ fn create_global_window_class() -> Result { } fn get_global_window_class() -> Result { - static GLOBAL: Lazy> = - Lazy::new(create_global_window_class); + static GLOBAL: LazyLock> = + LazyLock::new(create_global_window_class); GLOBAL.clone() } @@ -434,14 +433,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 12234d6364..9a2fcc1e4e 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -227,6 +227,7 @@ )] #![warn( clippy::ptr_as_ptr, + clippy::ref_as_ptr, trivial_casts, trivial_numeric_casts, unsafe_op_in_unsafe_fn, diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index c0b8331fb5..83a81ecb89 100644 --- a/wgpu-hal/src/metal/command.rs +++ b/wgpu-hal/src/metal/command.rs @@ -1,6 +1,6 @@ use super::{conv, AsNative, TimestampQuerySupport}; use crate::CommandEncoder as _; -use std::{borrow::Cow, mem::size_of, ops::Range}; +use std::{borrow::Cow, ops::Range}; // has to match `Temp::binding_sizes` const WORD_SIZE: usize = 4; diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index 8c6c5281fe..17585d6ef7 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -3,11 +3,7 @@ use super::conv; use arrayvec::ArrayVec; use ash::vk; -use std::{ - mem::{self, size_of}, - ops::Range, - slice, -}; +use std::{mem, ops::Range, slice}; const ALLOCATION_GRANULARITY: u32 = 16; const DST_IMAGE_LAYOUT: vk::ImageLayout = vk::ImageLayout::TRANSFER_DST_OPTIMAL; diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index 4a342fcfa1..6eec11c425 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -9,7 +9,7 @@ use std::{ borrow::Cow, collections::{hash_map::Entry, BTreeMap}, ffi::{CStr, CString}, - mem::{self, size_of, MaybeUninit}, + mem::{self, MaybeUninit}, num::NonZeroU32, ptr, slice, sync::Arc, diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 5292fa628a..94ddfdb0b4 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -30,8 +30,7 @@ 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") }; + const KHRONOS_VALIDATION_LAYER: &CStr = c"Khronos Validation Layer"; if let Some(layer_properties) = user_data.validation_layer_properties.as_ref() { if layer_properties.layer_description.as_ref() == KHRONOS_VALIDATION_LAYER && layer_properties.layer_spec_version >= vk::make_api_version(0, 1, 3, 240) @@ -599,7 +598,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... @@ -641,8 +640,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 @@ -666,10 +664,10 @@ 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 nv_optimus_layer = c"VK_LAYER_NV_optimus"; let has_nv_optimus = find_layer(&instance_layers, nv_optimus_layer).is_some(); - let obs_layer = CStr::from_bytes_with_nul(b"VK_LAYER_OBS_HOOK\0").unwrap(); + let obs_layer = c"VK_LAYER_OBS_HOOK"; let has_obs_layer = find_layer(&instance_layers, obs_layer).is_some(); let mut layers: Vec<&'static CStr> = Vec::new(); diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 5caf34eec9..2e123ce053 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/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.80.0" [package.metadata.docs.rs] all-features = true @@ -34,6 +34,9 @@ serde = ["dep:serde"] # Enables some internal instrumentation for debugging purposes. counters = [] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(web_sys_unstable_apis)'] } + [dependencies] bitflags = { workspace = true, features = ["serde"] } serde = { workspace = true, features = ["derive"], optional = true } diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index fa7dbe173c..f3d2078291 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -6,14 +6,18 @@ // We don't use syntax sugar where it's not necessary. clippy::match_like_matches_macro, )] -#![warn(clippy::ptr_as_ptr, missing_docs, unsafe_op_in_unsafe_fn)] +#![warn( + clippy::ptr_as_ptr, + clippy::ref_as_ptr, + missing_docs, + unsafe_op_in_unsafe_fn +)] #[cfg(any(feature = "serde", test))] use serde::Deserialize; #[cfg(any(feature = "serde", test))] use serde::Serialize; use std::hash::{Hash, Hasher}; -use std::mem::size_of; use std::path::PathBuf; use std::{num::NonZeroU32, ops::Range}; diff --git a/wgpu/src/macros.rs b/wgpu/src/macros.rs index db9548d90c..4acbb30e89 100644 --- a/wgpu/src/macros.rs +++ b/wgpu/src/macros.rs @@ -32,8 +32,6 @@ macro_rules! vertex_attr_array { #[test] fn test_vertex_attr_array() { - use std::mem::size_of; - let attrs = vertex_attr_array![0 => Float32x2, 3 => Uint16x4]; // VertexAttribute does not support PartialEq, so we cannot test directly assert_eq!(attrs.len(), 2); diff --git a/wgpu/src/util/mod.rs b/wgpu/src/util/mod.rs index 9d181eba93..1b02562dae 100644 --- a/wgpu/src/util/mod.rs +++ b/wgpu/src/util/mod.rs @@ -9,11 +9,7 @@ mod encoder; mod init; use std::sync::Arc; -use std::{ - borrow::Cow, - mem::{align_of, size_of}, - ptr::copy_nonoverlapping, -}; +use std::{borrow::Cow, ptr::copy_nonoverlapping}; pub use belt::StagingBelt; pub use device::{BufferInitDescriptor, DeviceExt};