From 9dea0582d0b622b66c723703d155c67e6ec70157 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Mon, 12 Aug 2024 11:43:07 +0100 Subject: [PATCH] chore: satisfy `unused_qualifications` lint after Rust 1.80 `std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust 1.80; see [`rust`#123168](https://github.com/rust-lang/rust/pull/123168/). --- wgpu-core/src/command/bundle.rs | 4 ++-- wgpu-core/src/command/compute.rs | 4 ++-- wgpu-core/src/command/render.rs | 10 +++++----- wgpu-core/src/pipeline_cache.rs | 9 +++------ wgpu-core/src/registry.rs | 2 +- wgpu-hal/src/gles/command.rs | 8 ++++---- wgpu-hal/src/gles/queue.rs | 6 +++--- wgpu-hal/src/metal/command.rs | 6 +++--- wgpu-hal/src/vulkan/command.rs | 8 ++++---- 9 files changed, 27 insertions(+), 30 deletions(-) diff --git a/wgpu-core/src/command/bundle.rs b/wgpu-core/src/command/bundle.rs index 542c52b886f..a5cf652b01f 100644 --- a/wgpu-core/src/command/bundle.rs +++ b/wgpu-core/src/command/bundle.rs @@ -101,7 +101,7 @@ use crate::{ }; use arrayvec::ArrayVec; -use std::{borrow::Cow, mem, num::NonZeroU32, ops::Range, sync::Arc}; +use std::{borrow::Cow, num::NonZeroU32, ops::Range, sync::Arc}; use thiserror::Error; use hal::CommandEncoder as _; @@ -876,7 +876,7 @@ fn multi_draw_indirect( .buffer_memory_init_actions .extend(buffer.initialization_status.read().create_action( &buffer, - offset..(offset + mem::size_of::() as u64), + offset..(offset + size_of::() as u64), MemoryInitKind::NeedsInitializedMemory, )); diff --git a/wgpu-core/src/command/compute.rs b/wgpu-core/src/command/compute.rs index 643e5ffa63b..8b700030c62 100644 --- a/wgpu-core/src/command/compute.rs +++ b/wgpu-core/src/command/compute.rs @@ -32,7 +32,7 @@ use thiserror::Error; use wgt::{BufferAddress, DynamicOffset}; use std::sync::Arc; -use std::{fmt, mem, str}; +use std::{fmt, str}; use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions, DynComputePass}; @@ -877,7 +877,7 @@ fn dispatch_indirect( .merge_single(&buffer, hal::BufferUses::INDIRECT)?; buffer.check_usage(wgt::BufferUsages::INDIRECT)?; - let end_offset = offset + mem::size_of::() as u64; + let end_offset = offset + size_of::() as u64; if end_offset > buffer.size { return Err(ComputePassErrorInner::IndirectBufferOverrun { offset, diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index 8c00e0d3026..82fb2a1a641 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -47,7 +47,7 @@ use serde::Deserialize; use serde::Serialize; use std::sync::Arc; -use std::{borrow::Cow, fmt, iter, mem, num::NonZeroU32, ops::Range, str}; +use std::{borrow::Cow, fmt, iter, num::NonZeroU32, ops::Range, str}; use super::render_command::ArcRenderCommand; use super::{ @@ -2465,8 +2465,8 @@ fn multi_draw_indirect( state.is_ready(indexed)?; let stride = match indexed { - false => mem::size_of::(), - true => mem::size_of::(), + false => size_of::(), + true => size_of::(), }; if count.is_some() { @@ -2543,8 +2543,8 @@ fn multi_draw_indirect_count( state.is_ready(indexed)?; let stride = match indexed { - false => mem::size_of::(), - true => mem::size_of::(), + false => size_of::(), + true => size_of::(), } as u64; state diff --git a/wgpu-core/src/pipeline_cache.rs b/wgpu-core/src/pipeline_cache.rs index b88fc21dda5..057223fb573 100644 --- a/wgpu-core/src/pipeline_cache.rs +++ b/wgpu-core/src/pipeline_cache.rs @@ -1,7 +1,7 @@ use thiserror::Error; use wgt::AdapterInfo; -pub const HEADER_LENGTH: usize = std::mem::size_of::(); +pub const HEADER_LENGTH: usize = size_of::(); #[derive(Debug, PartialEq, Eq, Clone, Error)] #[non_exhaustive] @@ -112,7 +112,7 @@ pub fn add_cache_header( const MAGIC: [u8; 8] = *b"WGPUPLCH"; const HEADER_VERSION: u32 = 1; -const ABI: u32 = std::mem::size_of::<*const ()>() as u32; +const ABI: u32 = size_of::<*const ()>() as u32; /// The value used to fill [`PipelineCacheHeader::hash_space`] /// @@ -179,10 +179,7 @@ impl PipelineCacheHeader { let data_size = reader.read_u64()?; let data_hash = reader.read_u64()?; - assert_eq!( - reader.total_read, - std::mem::size_of::() - ); + assert_eq!(reader.total_read, size_of::()); Some(( PipelineCacheHeader { diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index 9183cc83bb7..9902bc5db8d 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -129,7 +129,7 @@ impl Registry { pub(crate) fn generate_report(&self) -> RegistryReport { let storage = self.storage.read(); let mut report = RegistryReport { - element_size: std::mem::size_of::(), + element_size: size_of::(), ..Default::default() }; report.num_allocated = self.identity.values.lock().count(); diff --git a/wgpu-hal/src/gles/command.rs b/wgpu-hal/src/gles/command.rs index 2fcbc7cffe4..74ab4899948 100644 --- a/wgpu-hal/src/gles/command.rs +++ b/wgpu-hal/src/gles/command.rs @@ -82,7 +82,7 @@ impl super::CommandBuffer { fn add_push_constant_data(&mut self, data: &[u32]) -> Range { let data_raw = - unsafe { std::slice::from_raw_parts(data.as_ptr().cast(), mem::size_of_val(data)) }; + unsafe { std::slice::from_raw_parts(data.as_ptr().cast(), size_of_val(data)) }; let start = self.data_bytes.len(); assert!(start < u32::MAX as usize); self.data_bytes.extend_from_slice(data_raw); @@ -1080,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder { self.prepare_draw(0); for draw in 0..draw_count as wgt::BufferAddress { let indirect_offset = - offset + draw * mem::size_of::() as wgt::BufferAddress; + offset + draw * size_of::() as wgt::BufferAddress; #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation self.cmd_buffer.commands.push(C::DrawIndirect { topology: self.state.topology, @@ -1102,8 +1102,8 @@ impl crate::CommandEncoder for super::CommandEncoder { wgt::IndexFormat::Uint32 => glow::UNSIGNED_INT, }; for draw in 0..draw_count as wgt::BufferAddress { - let indirect_offset = offset - + draw * mem::size_of::() as wgt::BufferAddress; + let indirect_offset = + offset + draw * size_of::() as wgt::BufferAddress; #[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation self.cmd_buffer.commands.push(C::DrawIndexedIndirect { topology: self.state.topology, diff --git a/wgpu-hal/src/gles/queue.rs b/wgpu-hal/src/gles/queue.rs index 398e37ffe67..4212469231e 100644 --- a/wgpu-hal/src/gles/queue.rs +++ b/wgpu-hal/src/gles/queue.rs @@ -2,7 +2,7 @@ use super::{conv::is_layered_target, Command as C, PrivateCapabilities}; use arrayvec::ArrayVec; use glow::HasContext; use std::{ - mem, slice, + slice, sync::{atomic::Ordering, Arc}, }; @@ -956,7 +956,7 @@ impl super::Queue { let query_data = unsafe { slice::from_raw_parts( temp_query_results.as_ptr().cast::(), - temp_query_results.len() * mem::size_of::(), + temp_query_results.len() * size_of::(), ) }; match dst.raw { @@ -1520,7 +1520,7 @@ impl super::Queue { // // This function is absolutely sketchy and we really should be using bytemuck. unsafe fn get_data(data: &[u8], offset: u32) -> &[T; COUNT] { - let data_required = mem::size_of::() * COUNT; + let data_required = size_of::() * COUNT; let raw = &data[(offset as usize)..][..data_required]; diff --git a/wgpu-hal/src/metal/command.rs b/wgpu-hal/src/metal/command.rs index fafe3478fd8..3719dbb961f 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, ops::Range}; +use std::{borrow::Cow, ops::Range}; // has to match `Temp::binding_sizes` const WORD_SIZE: usize = 4; @@ -1080,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder { let encoder = self.state.render.as_ref().unwrap(); for _ in 0..draw_count { encoder.draw_primitives_indirect(self.state.raw_primitive_type, &buffer.raw, offset); - offset += mem::size_of::() as wgt::BufferAddress; + offset += size_of::() as wgt::BufferAddress; } } @@ -1101,7 +1101,7 @@ impl crate::CommandEncoder for super::CommandEncoder { &buffer.raw, offset, ); - offset += mem::size_of::() as wgt::BufferAddress; + offset += size_of::() as wgt::BufferAddress; } } diff --git a/wgpu-hal/src/vulkan/command.rs b/wgpu-hal/src/vulkan/command.rs index 4f36e6f86c7..e1bbefebd86 100644 --- a/wgpu-hal/src/vulkan/command.rs +++ b/wgpu-hal/src/vulkan/command.rs @@ -992,7 +992,7 @@ impl crate::CommandEncoder for super::CommandEncoder { buffer.raw, offset, draw_count, - mem::size_of::() as u32, + size_of::() as u32, ) }; } @@ -1008,7 +1008,7 @@ impl crate::CommandEncoder for super::CommandEncoder { buffer.raw, offset, draw_count, - mem::size_of::() as u32, + size_of::() as u32, ) }; } @@ -1020,7 +1020,7 @@ impl crate::CommandEncoder for super::CommandEncoder { count_offset: wgt::BufferAddress, max_count: u32, ) { - let stride = mem::size_of::() as u32; + let stride = size_of::() as u32; match self.device.extension_fns.draw_indirect_count { Some(ref t) => { unsafe { @@ -1046,7 +1046,7 @@ impl crate::CommandEncoder for super::CommandEncoder { count_offset: wgt::BufferAddress, max_count: u32, ) { - let stride = mem::size_of::() as u32; + let stride = size_of::() as u32; match self.device.extension_fns.draw_indirect_count { Some(ref t) => { unsafe {