Skip to content

Commit 5b300f7

Browse files
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](rust-lang/rust#123168).
1 parent e17f151 commit 5b300f7

File tree

9 files changed

+26
-26
lines changed

9 files changed

+26
-26
lines changed

wgpu-core/src/command/bundle.rs

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

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

107107
use hal::CommandEncoder as _;
@@ -876,7 +876,7 @@ fn multi_draw_indirect<A: HalApi>(
876876
.buffer_memory_init_actions
877877
.extend(buffer.initialization_status.read().create_action(
878878
&buffer,
879-
offset..(offset + mem::size_of::<wgt::DrawIndirectArgs>() as u64),
879+
offset..(offset + size_of::<wgt::DrawIndirectArgs>() as u64),
880880
MemoryInitKind::NeedsInitializedMemory,
881881
));
882882

wgpu-core/src/command/compute.rs

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

3434
use std::sync::Arc;
35-
use std::{fmt, mem, str};
35+
use std::{fmt, str};
3636

3737
use super::{bind::BinderError, memory_init::CommandBufferTextureMemoryActions, DynComputePass};
3838

@@ -877,7 +877,7 @@ fn dispatch_indirect<A: HalApi>(
877877
.merge_single(&buffer, hal::BufferUses::INDIRECT)?;
878878
buffer.check_usage(wgt::BufferUsages::INDIRECT)?;
879879

880-
let end_offset = offset + mem::size_of::<wgt::DispatchIndirectArgs>() as u64;
880+
let end_offset = offset + size_of::<wgt::DispatchIndirectArgs>() as u64;
881881
if end_offset > buffer.size {
882882
return Err(ComputePassErrorInner::IndirectBufferOverrun {
883883
offset,

wgpu-core/src/command/render.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ use serde::Deserialize;
4747
use serde::Serialize;
4848

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

5252
use super::render_command::ArcRenderCommand;
5353
use super::{
@@ -2465,8 +2465,8 @@ fn multi_draw_indirect<A: HalApi>(
24652465
state.is_ready(indexed)?;
24662466

24672467
let stride = match indexed {
2468-
false => mem::size_of::<wgt::DrawIndirectArgs>(),
2469-
true => mem::size_of::<wgt::DrawIndexedIndirectArgs>(),
2468+
false => size_of::<wgt::DrawIndirectArgs>(),
2469+
true => size_of::<wgt::DrawIndexedIndirectArgs>(),
24702470
};
24712471

24722472
if count.is_some() {
@@ -2543,8 +2543,8 @@ fn multi_draw_indirect_count<A: HalApi>(
25432543
state.is_ready(indexed)?;
25442544

25452545
let stride = match indexed {
2546-
false => mem::size_of::<wgt::DrawIndirectArgs>(),
2547-
true => mem::size_of::<wgt::DrawIndexedIndirectArgs>(),
2546+
false => size_of::<wgt::DrawIndirectArgs>(),
2547+
true => size_of::<wgt::DrawIndexedIndirectArgs>(),
25482548
} as u64;
25492549

25502550
state

wgpu-core/src/pipeline_cache.rs

Lines changed: 3 additions & 3 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
///
@@ -181,7 +181,7 @@ impl PipelineCacheHeader {
181181

182182
assert_eq!(
183183
reader.total_read,
184-
std::mem::size_of::<PipelineCacheHeader>()
184+
size_of::<PipelineCacheHeader>()
185185
);
186186

187187
Some((

wgpu-core/src/registry.rs

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

wgpu-hal/src/gles/command.rs

Lines changed: 3 additions & 3 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);
@@ -1080,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10801080
self.prepare_draw(0);
10811081
for draw in 0..draw_count as wgt::BufferAddress {
10821082
let indirect_offset =
1083-
offset + draw * mem::size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
1083+
offset + draw * size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
10841084
#[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation
10851085
self.cmd_buffer.commands.push(C::DrawIndirect {
10861086
topology: self.state.topology,
@@ -1103,7 +1103,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
11031103
};
11041104
for draw in 0..draw_count as wgt::BufferAddress {
11051105
let indirect_offset = offset
1106-
+ draw * mem::size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
1106+
+ draw * size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
11071107
#[allow(clippy::clone_on_copy)] // False positive when cloning glow::UniformLocation
11081108
self.cmd_buffer.commands.push(C::DrawIndexedIndirect {
11091109
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

@@ -956,7 +956,7 @@ impl super::Queue {
956956
let query_data = unsafe {
957957
slice::from_raw_parts(
958958
temp_query_results.as_ptr().cast::<u8>(),
959-
temp_query_results.len() * mem::size_of::<u64>(),
959+
temp_query_results.len() * size_of::<u64>(),
960960
)
961961
};
962962
match dst.raw {
@@ -1520,7 +1520,7 @@ impl super::Queue {
15201520
//
15211521
// This function is absolutely sketchy and we really should be using bytemuck.
15221522
unsafe fn get_data<T, const COUNT: usize>(data: &[u8], offset: u32) -> &[T; COUNT] {
1523-
let data_required = mem::size_of::<T>() * COUNT;
1523+
let data_required = size_of::<T>() * COUNT;
15241524

15251525
let raw = &data[(offset as usize)..][..data_required];
15261526

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;
@@ -1080,7 +1080,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10801080
let encoder = self.state.render.as_ref().unwrap();
10811081
for _ in 0..draw_count {
10821082
encoder.draw_primitives_indirect(self.state.raw_primitive_type, &buffer.raw, offset);
1083-
offset += mem::size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
1083+
offset += size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
10841084
}
10851085
}
10861086

@@ -1101,7 +1101,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
11011101
&buffer.raw,
11021102
offset,
11031103
);
1104-
offset += mem::size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
1104+
offset += size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
11051105
}
11061106
}
11071107

wgpu-hal/src/vulkan/command.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
992992
buffer.raw,
993993
offset,
994994
draw_count,
995-
mem::size_of::<wgt::DrawIndirectArgs>() as u32,
995+
size_of::<wgt::DrawIndirectArgs>() as u32,
996996
)
997997
};
998998
}
@@ -1008,7 +1008,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10081008
buffer.raw,
10091009
offset,
10101010
draw_count,
1011-
mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
1011+
size_of::<wgt::DrawIndexedIndirectArgs>() as u32,
10121012
)
10131013
};
10141014
}
@@ -1020,7 +1020,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10201020
count_offset: wgt::BufferAddress,
10211021
max_count: u32,
10221022
) {
1023-
let stride = mem::size_of::<wgt::DrawIndirectArgs>() as u32;
1023+
let stride = size_of::<wgt::DrawIndirectArgs>() as u32;
10241024
match self.device.extension_fns.draw_indirect_count {
10251025
Some(ref t) => {
10261026
unsafe {
@@ -1046,7 +1046,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10461046
count_offset: wgt::BufferAddress,
10471047
max_count: u32,
10481048
) {
1049-
let stride = mem::size_of::<wgt::DrawIndexedIndirectArgs>() as u32;
1049+
let stride = size_of::<wgt::DrawIndexedIndirectArgs>() as u32;
10501050
match self.device.extension_fns.draw_indirect_count {
10511051
Some(ref t) => {
10521052
unsafe {

0 commit comments

Comments
 (0)