Skip to content

Commit c229479

Browse files
chore: satisfy unused_qualifications from new prelude items in Rust 1.80
`std::mem::{size,align}_of{,_val}` was added to `std::prelude` in Rust 1.80; see [`rust`#123168](rust-lang/rust#123168).
1 parent 3617a60 commit c229479

File tree

9 files changed

+27
-30
lines changed

9 files changed

+27
-30
lines changed

wgpu-core/src/command/bundle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ use crate::{
100100
};
101101
use arrayvec::ArrayVec;
102102

103-
use std::{borrow::Cow, mem, num::NonZeroU32, ops::Range, sync::Arc};
103+
use std::{borrow::Cow, num::NonZeroU32, ops::Range, sync::Arc};
104104
use thiserror::Error;
105105

106106
use super::{
@@ -873,7 +873,7 @@ fn multi_draw_indirect(
873873
.buffer_memory_init_actions
874874
.extend(buffer.initialization_status.read().create_action(
875875
&buffer,
876-
offset..(offset + mem::size_of::<wgt::DrawIndirectArgs>() as u64),
876+
offset..(offset + size_of::<wgt::DrawIndirectArgs>() as u64),
877877
MemoryInitKind::NeedsInitializedMemory,
878878
));
879879

wgpu-core/src/command/compute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use thiserror::Error;
2929
use wgt::{BufferAddress, DynamicOffset};
3030

3131
use std::sync::Arc;
32-
use std::{fmt, mem, str};
32+
use std::{fmt, str};
3333

3434
use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions};
3535

@@ -854,7 +854,7 @@ fn dispatch_indirect(
854854
.merge_single(&buffer, hal::BufferUses::INDIRECT)?;
855855
buffer.check_usage(wgt::BufferUsages::INDIRECT)?;
856856

857-
let end_offset = offset + mem::size_of::<wgt::DispatchIndirectArgs>() as u64;
857+
let end_offset = offset + size_of::<wgt::DispatchIndirectArgs>() as u64;
858858
if end_offset > buffer.size {
859859
return Err(ComputePassErrorInner::IndirectBufferOverrun {
860860
offset,

wgpu-core/src/command/render.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use serde::Deserialize;
4545
use serde::Serialize;
4646

4747
use std::sync::Arc;
48-
use std::{borrow::Cow, fmt, iter, mem, num::NonZeroU32, ops::Range, str};
48+
use std::{borrow::Cow, fmt, iter, num::NonZeroU32, ops::Range, str};
4949

5050
use super::render_command::ArcRenderCommand;
5151
use super::{
@@ -2442,8 +2442,8 @@ fn multi_draw_indirect(
24422442
state.is_ready(indexed)?;
24432443

24442444
let stride = match indexed {
2445-
false => mem::size_of::<wgt::DrawIndirectArgs>(),
2446-
true => mem::size_of::<wgt::DrawIndexedIndirectArgs>(),
2445+
false => size_of::<wgt::DrawIndirectArgs>(),
2446+
true => size_of::<wgt::DrawIndexedIndirectArgs>(),
24472447
};
24482448

24492449
if count.is_some() {
@@ -2520,8 +2520,8 @@ fn multi_draw_indirect_count(
25202520
state.is_ready(indexed)?;
25212521

25222522
let stride = match indexed {
2523-
false => mem::size_of::<wgt::DrawIndirectArgs>(),
2524-
true => mem::size_of::<wgt::DrawIndexedIndirectArgs>(),
2523+
false => size_of::<wgt::DrawIndirectArgs>(),
2524+
true => size_of::<wgt::DrawIndexedIndirectArgs>(),
25252525
} as u64;
25262526

25272527
state

wgpu-core/src/pipeline_cache.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use thiserror::Error;
22
use wgt::AdapterInfo;
33

4-
pub const HEADER_LENGTH: usize = std::mem::size_of::<PipelineCacheHeader>();
4+
pub const HEADER_LENGTH: usize = size_of::<PipelineCacheHeader>();
55

66
#[derive(Debug, PartialEq, Eq, Clone, Error)]
77
#[non_exhaustive]
@@ -112,7 +112,7 @@ pub fn add_cache_header(
112112

113113
const MAGIC: [u8; 8] = *b"WGPUPLCH";
114114
const HEADER_VERSION: u32 = 1;
115-
const ABI: u32 = std::mem::size_of::<*const ()>() as u32;
115+
const ABI: u32 = size_of::<*const ()>() as u32;
116116

117117
/// The value used to fill [`PipelineCacheHeader::hash_space`]
118118
///
@@ -179,10 +179,7 @@ impl PipelineCacheHeader {
179179
let data_size = reader.read_u64()?;
180180
let data_hash = reader.read_u64()?;
181181

182-
assert_eq!(
183-
reader.total_read,
184-
std::mem::size_of::<PipelineCacheHeader>()
185-
);
182+
assert_eq!(reader.total_read, size_of::<PipelineCacheHeader>());
186183

187184
Some((
188185
PipelineCacheHeader {

wgpu-core/src/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<T: StorageItem> Registry<T> {
125125
pub(crate) fn generate_report(&self) -> RegistryReport {
126126
let storage = self.storage.read();
127127
let mut report = RegistryReport {
128-
element_size: std::mem::size_of::<T>(),
128+
element_size: size_of::<T>(),
129129
..Default::default()
130130
};
131131
report.num_allocated = self.identity.values.lock().count();

wgpu-hal/src/gles/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl super::CommandBuffer {
8282

8383
fn add_push_constant_data(&mut self, data: &[u32]) -> Range<u32> {
8484
let data_raw =
85-
unsafe { std::slice::from_raw_parts(data.as_ptr().cast(), mem::size_of_val(data)) };
85+
unsafe { std::slice::from_raw_parts(data.as_ptr().cast(), size_of_val(data)) };
8686
let start = self.data_bytes.len();
8787
assert!(start < u32::MAX as usize);
8888
self.data_bytes.extend_from_slice(data_raw);
@@ -1083,7 +1083,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10831083
self.prepare_draw(0);
10841084
for draw in 0..draw_count as wgt::BufferAddress {
10851085
let indirect_offset =
1086-
offset + draw * mem::size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
1086+
offset + draw * size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
10871087
#[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation
10881088
self.cmd_buffer.commands.push(C::DrawIndirect {
10891089
topology: self.state.topology,
@@ -1105,8 +1105,8 @@ impl crate::CommandEncoder for super::CommandEncoder {
11051105
wgt::IndexFormat::Uint32 => glow::UNSIGNED_INT,
11061106
};
11071107
for draw in 0..draw_count as wgt::BufferAddress {
1108-
let indirect_offset = offset
1109-
+ draw * mem::size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
1108+
let indirect_offset =
1109+
offset + draw * size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
11101110
#[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation
11111111
self.cmd_buffer.commands.push(C::DrawIndexedIndirect {
11121112
topology: self.state.topology,

wgpu-hal/src/gles/queue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{conv::is_layered_target, Command as C, PrivateCapabilities};
22
use arrayvec::ArrayVec;
33
use glow::HasContext;
44
use std::{
5-
mem, slice,
5+
slice,
66
sync::{atomic::Ordering, Arc},
77
};
88

@@ -1012,7 +1012,7 @@ impl super::Queue {
10121012
let query_data = unsafe {
10131013
slice::from_raw_parts(
10141014
temp_query_results.as_ptr().cast::<u8>(),
1015-
temp_query_results.len() * mem::size_of::<u64>(),
1015+
temp_query_results.len() * size_of::<u64>(),
10161016
)
10171017
};
10181018
match dst.raw {
@@ -1576,7 +1576,7 @@ impl super::Queue {
15761576
//
15771577
// This function is absolutely sketchy and we really should be using bytemuck.
15781578
unsafe fn get_data<T, const COUNT: usize>(data: &[u8], offset: u32) -> &[T; COUNT] {
1579-
let data_required = mem::size_of::<T>() * COUNT;
1579+
let data_required = size_of::<T>() * COUNT;
15801580

15811581
let raw = &data[(offset as usize)..][..data_required];
15821582

wgpu-hal/src/metal/command.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{conv, AsNative, TimestampQuerySupport};
22
use crate::CommandEncoder as _;
3-
use std::{borrow::Cow, mem, ops::Range};
3+
use std::{borrow::Cow, ops::Range};
44

55
// has to match `Temp::binding_sizes`
66
const WORD_SIZE: usize = 4;
@@ -1083,7 +1083,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10831083
let encoder = self.state.render.as_ref().unwrap();
10841084
for _ in 0..draw_count {
10851085
encoder.draw_primitives_indirect(self.state.raw_primitive_type, &buffer.raw, offset);
1086-
offset += mem::size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
1086+
offset += size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
10871087
}
10881088
}
10891089

@@ -1104,7 +1104,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
11041104
&buffer.raw,
11051105
offset,
11061106
);
1107-
offset += mem::size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
1107+
offset += size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
11081108
}
11091109
}
11101110

wgpu-hal/src/vulkan/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10121012
buffer.raw,
10131013
offset,
10141014
draw_count,
1015-
mem::size_of::<wgt::DrawIndirectArgs>() as u32,
1015+
size_of::<wgt::DrawIndirectArgs>() as u32,
10161016
)
10171017
};
10181018
}
@@ -1028,7 +1028,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10281028
buffer.raw,
10291029
offset,
10301030
draw_count,
1031-
mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
1031+
size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
10321032
)
10331033
};
10341034
}
@@ -1040,7 +1040,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10401040
count_offset: wgt::BufferAddress,
10411041
max_count: u32,
10421042
) {
1043-
let stride = mem::size_of::<wgt::DrawIndirectArgs>() as u32;
1043+
let stride = size_of::<wgt::DrawIndirectArgs>() as u32;
10441044
match self.device.extension_fns.draw_indirect_count {
10451045
Some(ref t) => {
10461046
unsafe {
@@ -1066,7 +1066,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10661066
count_offset: wgt::BufferAddress,
10671067
max_count: u32,
10681068
) {
1069-
let stride = mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u32;
1069+
let stride = size_of::<wgt::DrawIndexedIndirectArgs>() as u32;
10701070
match self.device.extension_fns.draw_indirect_count {
10711071
Some(ref t) => {
10721072
unsafe {

0 commit comments

Comments
 (0)