simplify std::mem references (#15315)

# Objective
- Fixes #15314

## Solution

- Remove unnecessary usings and simplify references to those functions.

## Testing

CI
This commit is contained in:
Benjamin Brienen 2024-09-19 23:28:16 +02:00 committed by GitHub
parent 612897becd
commit 1b8c1c1242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 13 additions and 24 deletions

View file

@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://github.com/bevyengine/bevy" repository = "https://github.com/bevyengine/bevy"
documentation = "https://docs.rs/bevy" documentation = "https://docs.rs/bevy"
rust-version = "1.79.0" rust-version = "1.80.0"
[workspace] [workspace]
exclude = [ exclude = [

View file

@ -1,5 +1,3 @@
use std::mem::size_of;
use bevy_ecs::{ use bevy_ecs::{
component::Component, component::Component,
entity::Entity, entity::Entity,

View file

@ -1115,7 +1115,7 @@ impl Termination for AppExit {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::{iter, marker::PhantomData, mem::size_of, sync::Mutex}; use std::{iter, marker::PhantomData, sync::Mutex};
use bevy_ecs::{ use bevy_ecs::{
change_detection::{DetectChanges, ResMut}, change_detection::{DetectChanges, ResMut},

View file

@ -26,7 +26,6 @@ use futures_io::{AsyncRead, AsyncSeek, AsyncWrite};
use futures_lite::{ready, Stream}; use futures_lite::{ready, Stream};
use std::{ use std::{
io::SeekFrom, io::SeekFrom,
mem::size_of,
path::{Path, PathBuf}, path::{Path, PathBuf},
pin::Pin, pin::Pin,
sync::Arc, sync::Arc,

View file

@ -1006,7 +1006,6 @@ impl EntityLocation {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::mem::size_of;
#[test] #[test]
fn entity_niche_optimization() { fn entity_niche_optimization() {

View file

@ -505,7 +505,7 @@ mod tests {
use crate::{component::Component, ptr::OwningPtr, world::World}; use crate::{component::Component, ptr::OwningPtr, world::World};
use super::BlobVec; use super::BlobVec;
use std::{alloc::Layout, cell::RefCell, mem::align_of, rc::Rc}; use std::{alloc::Layout, cell::RefCell, rc::Rc};
/// # Safety /// # Safety
/// ///

View file

@ -2502,7 +2502,7 @@ impl World {
/// total += info.layout().size(); /// total += info.layout().size();
/// } /// }
/// println!("Total size: {} bytes", total); /// println!("Total size: {} bytes", total);
/// # assert_eq!(total, std::mem::size_of::<A>() + std::mem::size_of::<B>()); /// # assert_eq!(total, size_of::<A>() + size_of::<B>());
/// ``` /// ```
/// ///
/// ## Dynamically running closures for resources matching specific `TypeId`s /// ## Dynamically running closures for resources matching specific `TypeId`s

View file

@ -13,7 +13,7 @@ use bevy_render::{
renderer::{RenderDevice, RenderQueue}, renderer::{RenderDevice, RenderQueue},
}; };
use bevy_utils::HashMap; use bevy_utils::HashMap;
use std::{mem::size_of, ops::Range, sync::Arc}; use std::{ops::Range, sync::Arc};
/// Manages uploading [`MeshletMesh`] asset data to the GPU. /// Manages uploading [`MeshletMesh`] asset data to the GPU.
#[derive(Resource)] #[derive(Resource)]

View file

@ -2,7 +2,7 @@ use super::{
asset::{Meshlet, MeshletBoundingSpheres}, asset::{Meshlet, MeshletBoundingSpheres},
persistent_buffer::PersistentGpuBufferable, persistent_buffer::PersistentGpuBufferable,
}; };
use std::{mem::size_of, sync::Arc}; use std::sync::Arc;
const MESHLET_VERTEX_SIZE_IN_BYTES: u32 = 48; const MESHLET_VERTEX_SIZE_IN_BYTES: u32 = 48;

View file

@ -21,7 +21,6 @@ use binding_types::*;
use encase::internal::WriteInto; use encase::internal::WriteInto;
use std::{ use std::{
array, iter, array, iter,
mem::size_of,
sync::{atomic::AtomicBool, Arc}, sync::{atomic::AtomicBool, Arc},
}; };

View file

@ -4,7 +4,6 @@ use bevy_math::Mat4;
use bevy_render::{ use bevy_render::{
mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice, texture::GpuImage, mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice, texture::GpuImage,
}; };
use std::mem::size_of;
use crate::render::skin::MAX_JOINTS; use crate::render::skin::MAX_JOINTS;

View file

@ -1,4 +1,4 @@
use std::{iter, mem, mem::size_of}; use std::{iter, mem};
use bevy_ecs::entity::EntityHashMap; use bevy_ecs::entity::EntityHashMap;
use bevy_ecs::prelude::*; use bevy_ecs::prelude::*;

View file

@ -603,7 +603,6 @@ trait DebugEnsureAligned {
impl<T: Sized> DebugEnsureAligned for *mut T { impl<T: Sized> DebugEnsureAligned for *mut T {
#[track_caller] #[track_caller]
fn debug_ensure_aligned(self) -> Self { fn debug_ensure_aligned(self) -> Self {
use core::mem::align_of;
let align = align_of::<T>(); let align = align_of::<T>();
// Implementation shamelessly borrowed from the currently unstable // Implementation shamelessly borrowed from the currently unstable
// ptr.is_aligned_to. // ptr.is_aligned_to.

View file

@ -11,7 +11,7 @@ use bevy_hierarchy::Children;
use bevy_math::Vec3; use bevy_math::Vec3;
use bevy_reflect::prelude::*; use bevy_reflect::prelude::*;
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use std::{iter, mem::size_of}; use std::iter;
use thiserror::Error; use thiserror::Error;
const MAX_TEXTURE_WIDTH: u32 = 2048; const MAX_TEXTURE_WIDTH: u32 = 2048;

View file

@ -1,4 +1,4 @@
use std::{iter, marker::PhantomData, mem::size_of}; use std::{iter, marker::PhantomData};
use crate::{ use crate::{
render_resource::Buffer, render_resource::Buffer,
@ -123,7 +123,7 @@ impl<T: NoUninit> RawBufferVec<T> {
} }
/// Creates a [`Buffer`] on the [`RenderDevice`] with size /// Creates a [`Buffer`] on the [`RenderDevice`] with size
/// at least `std::mem::size_of::<T>() * capacity`, unless a such a buffer already exists. /// at least `size_of::<T>() * capacity`, unless a such a buffer already exists.
/// ///
/// If a [`Buffer`] exists, but is too small, references to it will be discarded, /// If a [`Buffer`] exists, but is too small, references to it will be discarded,
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s /// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
@ -302,7 +302,7 @@ where
} }
/// Creates a [`Buffer`] on the [`RenderDevice`] with size /// Creates a [`Buffer`] on the [`RenderDevice`] with size
/// at least `std::mem::size_of::<T>() * capacity`, unless such a buffer already exists. /// at least `size_of::<T>() * capacity`, unless such a buffer already exists.
/// ///
/// If a [`Buffer`] exists, but is too small, references to it will be discarded, /// If a [`Buffer`] exists, but is too small, references to it will be discarded,
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s /// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s

View file

@ -537,7 +537,6 @@ mod test {
use super::*; use super::*;
use bevy_app::prelude::*; use bevy_app::prelude::*;
use bevy_hierarchy::BuildChildren; use bevy_hierarchy::BuildChildren;
use std::mem::size_of;
fn visibility_bundle(visibility: Visibility) -> VisibilityBundle { fn visibility_bundle(visibility: Visibility) -> VisibilityBundle {
VisibilityBundle { VisibilityBundle {

View file

@ -3,7 +3,7 @@
//! This example show how you can create components dynamically, spawn entities with those components //! This example show how you can create components dynamically, spawn entities with those components
//! as well as query for entities with those components. //! as well as query for entities with those components.
use std::{alloc::Layout, io::Write, mem::size_of, ptr::NonNull}; use std::{alloc::Layout, io::Write, ptr::NonNull};
use bevy::prelude::*; use bevy::prelude::*;
use bevy::{ use bevy::{

View file

@ -36,7 +36,6 @@ use bevy::{
}, },
}; };
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use std::mem::size_of;
/// A marker component that represents an entity that is to be rendered using /// A marker component that represents an entity that is to be rendered using
/// our custom phase item. /// our custom phase item.

View file

@ -17,7 +17,6 @@ use bevy::{
}, },
}; };
use crossbeam_channel::{Receiver, Sender}; use crossbeam_channel::{Receiver, Sender};
use std::mem::size_of;
/// This example uses a shader source file from the assets subdirectory /// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PATH: &str = "shaders/gpu_readback.wgsl"; const SHADER_ASSET_PATH: &str = "shaders/gpu_readback.wgsl";

View file

@ -27,7 +27,6 @@ use bevy::{
}, },
}; };
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use std::mem::size_of;
/// This example uses a shader source file from the assets subdirectory /// This example uses a shader source file from the assets subdirectory
const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl"; const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl";