Skip to content

Commit 1b8c1c1

Browse files
simplify std::mem references (#15315)
# Objective - Fixes #15314 ## Solution - Remove unnecessary usings and simplify references to those functions. ## Testing CI
1 parent 612897b commit 1b8c1c1

File tree

20 files changed

+13
-24
lines changed

20 files changed

+13
-24
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
1010
license = "MIT OR Apache-2.0"
1111
repository = "https://github.com/bevyengine/bevy"
1212
documentation = "https://docs.rs/bevy"
13-
rust-version = "1.79.0"
13+
rust-version = "1.80.0"
1414

1515
[workspace]
1616
exclude = [

benches/benches/bevy_ecs/world/commands.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::mem::size_of;
2-
31
use bevy_ecs::{
42
component::Component,
53
entity::Entity,

crates/bevy_app/src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ impl Termination for AppExit {
11151115

11161116
#[cfg(test)]
11171117
mod tests {
1118-
use std::{iter, marker::PhantomData, mem::size_of, sync::Mutex};
1118+
use std::{iter, marker::PhantomData, sync::Mutex};
11191119

11201120
use bevy_ecs::{
11211121
change_detection::{DetectChanges, ResMut},

crates/bevy_asset/src/io/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use futures_io::{AsyncRead, AsyncSeek, AsyncWrite};
2626
use futures_lite::{ready, Stream};
2727
use std::{
2828
io::SeekFrom,
29-
mem::size_of,
3029
path::{Path, PathBuf},
3130
pin::Pin,
3231
sync::Arc,

crates/bevy_ecs/src/entity/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@ impl EntityLocation {
10061006
#[cfg(test)]
10071007
mod tests {
10081008
use super::*;
1009-
use std::mem::size_of;
10101009

10111010
#[test]
10121011
fn entity_niche_optimization() {

crates/bevy_ecs/src/storage/blob_vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ mod tests {
505505
use crate::{component::Component, ptr::OwningPtr, world::World};
506506

507507
use super::BlobVec;
508-
use std::{alloc::Layout, cell::RefCell, mem::align_of, rc::Rc};
508+
use std::{alloc::Layout, cell::RefCell, rc::Rc};
509509

510510
/// # Safety
511511
///

crates/bevy_ecs/src/world/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ impl World {
25022502
/// total += info.layout().size();
25032503
/// }
25042504
/// println!("Total size: {} bytes", total);
2505-
/// # assert_eq!(total, std::mem::size_of::<A>() + std::mem::size_of::<B>());
2505+
/// # assert_eq!(total, size_of::<A>() + size_of::<B>());
25062506
/// ```
25072507
///
25082508
/// ## Dynamically running closures for resources matching specific `TypeId`s

crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use bevy_render::{
1313
renderer::{RenderDevice, RenderQueue},
1414
};
1515
use bevy_utils::HashMap;
16-
use std::{mem::size_of, ops::Range, sync::Arc};
16+
use std::{ops::Range, sync::Arc};
1717

1818
/// Manages uploading [`MeshletMesh`] asset data to the GPU.
1919
#[derive(Resource)]

crates/bevy_pbr/src/meshlet/persistent_buffer_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::{
22
asset::{Meshlet, MeshletBoundingSpheres},
33
persistent_buffer::PersistentGpuBufferable,
44
};
5-
use std::{mem::size_of, sync::Arc};
5+
use std::sync::Arc;
66

77
const MESHLET_VERTEX_SIZE_IN_BYTES: u32 = 48;
88

crates/bevy_pbr/src/meshlet/resource_manager.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use binding_types::*;
2121
use encase::internal::WriteInto;
2222
use std::{
2323
array, iter,
24-
mem::size_of,
2524
sync::{atomic::AtomicBool, Arc},
2625
};
2726

crates/bevy_pbr/src/render/mesh_bindings.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use bevy_math::Mat4;
44
use bevy_render::{
55
mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice, texture::GpuImage,
66
};
7-
use std::mem::size_of;
87

98
use crate::render::skin::MAX_JOINTS;
109

crates/bevy_pbr/src/render/morph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{iter, mem, mem::size_of};
1+
use std::{iter, mem};
22

33
use bevy_ecs::entity::EntityHashMap;
44
use bevy_ecs::prelude::*;

crates/bevy_ptr/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,6 @@ trait DebugEnsureAligned {
603603
impl<T: Sized> DebugEnsureAligned for *mut T {
604604
#[track_caller]
605605
fn debug_ensure_aligned(self) -> Self {
606-
use core::mem::align_of;
607606
let align = align_of::<T>();
608607
// Implementation shamelessly borrowed from the currently unstable
609608
// ptr.is_aligned_to.

crates/bevy_render/src/mesh/morph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use bevy_hierarchy::Children;
1111
use bevy_math::Vec3;
1212
use bevy_reflect::prelude::*;
1313
use bytemuck::{Pod, Zeroable};
14-
use std::{iter, mem::size_of};
14+
use std::iter;
1515
use thiserror::Error;
1616

1717
const MAX_TEXTURE_WIDTH: u32 = 2048;

crates/bevy_render/src/render_resource/buffer_vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{iter, marker::PhantomData, mem::size_of};
1+
use std::{iter, marker::PhantomData};
22

33
use crate::{
44
render_resource::Buffer,
@@ -123,7 +123,7 @@ impl<T: NoUninit> RawBufferVec<T> {
123123
}
124124

125125
/// Creates a [`Buffer`] on the [`RenderDevice`] with size
126-
/// at least `std::mem::size_of::<T>() * capacity`, unless a such a buffer already exists.
126+
/// at least `size_of::<T>() * capacity`, unless a such a buffer already exists.
127127
///
128128
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
129129
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
@@ -302,7 +302,7 @@ where
302302
}
303303

304304
/// Creates a [`Buffer`] on the [`RenderDevice`] with size
305-
/// at least `std::mem::size_of::<T>() * capacity`, unless such a buffer already exists.
305+
/// at least `size_of::<T>() * capacity`, unless such a buffer already exists.
306306
///
307307
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
308308
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s

crates/bevy_render/src/view/visibility/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,6 @@ mod test {
537537
use super::*;
538538
use bevy_app::prelude::*;
539539
use bevy_hierarchy::BuildChildren;
540-
use std::mem::size_of;
541540

542541
fn visibility_bundle(visibility: Visibility) -> VisibilityBundle {
543542
VisibilityBundle {

examples/ecs/dynamic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This example show how you can create components dynamically, spawn entities with those components
44
//! as well as query for entities with those components.
55
6-
use std::{alloc::Layout, io::Write, mem::size_of, ptr::NonNull};
6+
use std::{alloc::Layout, io::Write, ptr::NonNull};
77

88
use bevy::prelude::*;
99
use bevy::{
@@ -41,7 +41,7 @@ query, q Query for entities
4141
4242
Accesses: 'A' with, '&A' read, '&mut A' write
4343
Operators: '||' or, ',' and, '?' optional
44-
44+
4545
e.g. &A || &B, &mut C, D, ?E";
4646

4747
fn main() {

examples/shader/custom_phase_item.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use bevy::{
3636
},
3737
};
3838
use bytemuck::{Pod, Zeroable};
39-
use std::mem::size_of;
4039

4140
/// A marker component that represents an entity that is to be rendered using
4241
/// our custom phase item.

examples/shader/gpu_readback.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use bevy::{
1717
},
1818
};
1919
use crossbeam_channel::{Receiver, Sender};
20-
use std::mem::size_of;
2120

2221
/// This example uses a shader source file from the assets subdirectory
2322
const SHADER_ASSET_PATH: &str = "shaders/gpu_readback.wgsl";

examples/shader/shader_instancing.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use bevy::{
2727
},
2828
};
2929
use bytemuck::{Pod, Zeroable};
30-
use std::mem::size_of;
3130

3231
/// This example uses a shader source file from the assets subdirectory
3332
const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl";

0 commit comments

Comments
 (0)