Simpler lint fixes: makes ci lints work but disables a lint for now (#15376)

Takes the first two commits from #15375 and adds suggestions from this
comment:
https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366968300

See #15375 for more reasoning/motivation.

## Rebasing (rerunning)

```rust
git switch simpler-lint-fixes
git reset --hard main
cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate
cargo fmt --all
git add --update
git commit --message "rustfmt"
cargo clippy --workspace --all-targets --all-features --fix
cargo fmt --all -- --unstable-features --config normalize_comments=true,imports_granularity=Crate
cargo fmt --all
git add --update
git commit --message "clippy"
git cherry-pick e6c0b94f6795222310fb812fa5c4512661fc7887
```
This commit is contained in:
Clar Fon 2024-09-24 07:42:59 -04:00 committed by GitHub
parent 1d9ee56457
commit efda7f3f9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
373 changed files with 1615 additions and 1345 deletions

View file

@ -45,6 +45,9 @@ ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
ref_as_ptr = "warn"
# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219
too_long_first_doc_paragraph = "allow"
[workspace.lints.rust]
missing_docs = "warn"
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] }

View file

@ -21,8 +21,7 @@ use bevy_ecs::{
schedule::SystemSet,
system::Resource,
};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
#[derive(Event, Deref, DerefMut)]

View file

@ -1,7 +1,9 @@
//! The animation graph, which allows animations to be blended together.
use std::io::{self, Write};
use std::ops::{Index, IndexMut};
use std::{
io::{self, Write},
ops::{Index, IndexMut},
};
use bevy_asset::{io::Reader, Asset, AssetId, AssetLoader, AssetPath, Handle, LoadContext};
use bevy_reflect::{Reflect, ReflectSerialize};

View file

@ -1,20 +1,27 @@
//! Keyframes of animation clips.
use std::any::TypeId;
use std::fmt::{self, Debug, Formatter};
use std::{
any::TypeId,
fmt::{self, Debug, Formatter},
};
use bevy_asset::Handle;
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::component::Component;
use bevy_ecs::world::{EntityMutExcept, Mut};
use bevy_ecs::{
component::Component,
world::{EntityMutExcept, Mut},
};
use bevy_math::{Quat, Vec3};
use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath, Typed};
use bevy_render::mesh::morph::MorphWeights;
use bevy_transform::prelude::Transform;
use crate::graph::AnimationGraph;
use crate::prelude::{Animatable, GetKeyframe};
use crate::{animatable, AnimationEvaluationError, AnimationPlayer, Interpolation};
use crate::{
animatable,
graph::AnimationGraph,
prelude::{Animatable, GetKeyframe},
AnimationEvaluationError, AnimationPlayer, Interpolation,
};
/// A value on a component that Bevy can animate.
///

View file

@ -13,34 +13,33 @@ pub mod keyframes;
pub mod transition;
mod util;
use std::any::{Any, TypeId};
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::iter;
use std::{
any::{Any, TypeId},
cell::RefCell,
collections::BTreeMap,
fmt::Debug,
hash::{Hash, Hasher},
iter,
};
use bevy_app::{App, Plugin, PostUpdate};
use bevy_asset::{Asset, AssetApp, Assets, Handle};
use bevy_core::Name;
use bevy_ecs::entity::MapEntities;
use bevy_ecs::prelude::*;
use bevy_ecs::reflect::ReflectMapEntities;
use bevy_ecs::world::EntityMutExcept;
use bevy_ecs::{
entity::MapEntities, prelude::*, reflect::ReflectMapEntities, world::EntityMutExcept,
};
use bevy_math::FloatExt;
use bevy_reflect::utility::NonGenericTypeInfoCell;
use bevy_reflect::{prelude::ReflectDefault, Reflect};
use bevy_reflect::{
ApplyError, DynamicStruct, FieldIter, FromReflect, FromType, GetTypeRegistration, NamedField,
PartialReflect, ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct,
StructInfo, TypeInfo, TypePath, TypeRegistration, Typed,
prelude::ReflectDefault, utility::NonGenericTypeInfoCell, ApplyError, DynamicStruct, FieldIter,
FromReflect, FromType, GetTypeRegistration, NamedField, PartialReflect, Reflect,
ReflectFromPtr, ReflectKind, ReflectMut, ReflectOwned, ReflectRef, Struct, StructInfo,
TypeInfo, TypePath, TypeRegistration, Typed,
};
use bevy_time::Time;
use bevy_transform::prelude::Transform;
use bevy_transform::TransformSystem;
use bevy_transform::{prelude::Transform, TransformSystem};
use bevy_ui::UiSystem;
use bevy_utils::hashbrown::HashMap;
use bevy_utils::{
hashbrown::HashMap,
tracing::{trace, warn},
NoOpHash,
};

View file

@ -15,11 +15,9 @@ use bevy_utils::tracing::info_span;
use bevy_utils::{tracing::debug, HashMap};
use std::{
fmt::Debug,
process::{ExitCode, Termination},
};
use std::{
num::NonZero,
panic::{catch_unwind, resume_unwind, AssertUnwindSafe},
process::{ExitCode, Termination},
};
use thiserror::Error;

View file

@ -78,6 +78,7 @@ pub struct First;
pub struct PreUpdate;
/// Runs the [`FixedMain`] schedule in a loop according until all relevant elapsed time has been "consumed".
///
/// If you need to order your variable timestep systems
/// before or after the fixed update logic, use the [`RunFixedMainLoopSystem`] system set.
///

View file

@ -6,8 +6,7 @@
//! For more fine-tuned control over panic behavior, disable the [`PanicHandlerPlugin`] or
//! `DefaultPlugins` during app initialization.
use crate::App;
use crate::Plugin;
use crate::{App, Plugin};
/// Adds sensible panic handlers to Apps. This plugin is part of the `DefaultPlugins`. Adding
/// this plugin will setup a panic hook appropriate to your target platform:

View file

@ -1,5 +1,8 @@
use crate::{App, AppError, Plugin};
use bevy_utils::{tracing::debug, tracing::warn, TypeIdMap};
use bevy_utils::{
tracing::{debug, warn},
TypeIdMap,
};
use std::any::TypeId;
/// A macro for generating a well-documented [`PluginGroup`] from a list of [`Plugin`] paths.
@ -185,6 +188,7 @@ fn type_id_of_val<T: 'static>(_: &T) -> TypeId {
}
/// Facilitates the creation and configuration of a [`PluginGroup`].
///
/// Provides a build ordering to ensure that [`Plugin`]s which produce/require a [`Resource`](bevy_ecs::system::Resource)
/// are built before/after dependent/depending [`Plugin`]s. [`Plugin`]s inside the group
/// can be disabled, enabled or reordered.

View file

@ -1,5 +1,7 @@
use crate::{self as bevy_asset};
use crate::{Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle, UntypedHandle};
use crate::{
self as bevy_asset, Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle,
UntypedHandle,
};
use bevy_ecs::{
prelude::EventWriter,
system::{Res, ResMut, Resource},

View file

@ -303,6 +303,7 @@ impl PartialOrd for UntypedAssetId {
}
/// An asset id without static or dynamic types associated with it.
///
/// This exist to support efficient type erased id drop tracking. We
/// could use [`UntypedAssetId`] for this, but the [`TypeId`] is unnecessary.
///

View file

@ -3,8 +3,7 @@ use crate::io::{
memory::Dir,
AssetSourceEvent, AssetWatcher,
};
use bevy_utils::tracing::warn;
use bevy_utils::{Duration, HashMap};
use bevy_utils::{tracing::warn, Duration, HashMap};
use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, FileIdMap};
use parking_lot::RwLock;
use std::{

View file

@ -1,7 +1,8 @@
use crate::io::{AssetSourceEvent, AssetWatcher};
use crate::path::normalize_path;
use bevy_utils::tracing::error;
use bevy_utils::Duration;
use crate::{
io::{AssetSourceEvent, AssetWatcher},
path::normalize_path,
};
use bevy_utils::{tracing::error, Duration};
use crossbeam_channel::Sender;
use notify_debouncer_full::{
new_debouncer,

View file

@ -3,8 +3,8 @@ use bevy_utils::HashMap;
use futures_io::{AsyncRead, AsyncSeek};
use futures_lite::{ready, Stream};
use parking_lot::RwLock;
use std::io::SeekFrom;
use std::{
io::SeekFrom,
path::{Path, PathBuf},
pin::Pin,
sync::Arc,

View file

@ -6,9 +6,7 @@ use crate::{
use async_lock::RwLockReadGuardArc;
use bevy_utils::tracing::trace;
use futures_io::{AsyncRead, AsyncSeek};
use std::io::SeekFrom;
use std::task::Poll;
use std::{path::Path, pin::Pin, sync::Arc};
use std::{io::SeekFrom, path::Path, pin::Pin, sync::Arc, task::Poll};
use super::ErasedAssetReader;

View file

@ -4,8 +4,10 @@ use crate::{
};
use atomicow::CowArc;
use bevy_ecs::system::Resource;
use bevy_utils::tracing::{error, warn};
use bevy_utils::{Duration, HashMap};
use bevy_utils::{
tracing::{error, warn},
Duration, HashMap,
};
use std::{fmt::Display, hash::Hash, sync::Arc};
use thiserror::Error;

View file

@ -617,9 +617,9 @@ mod tests {
};
use bevy_app::{App, Update};
use bevy_core::TaskPoolPlugin;
use bevy_ecs::prelude::*;
use bevy_ecs::{
event::EventCursor,
prelude::*,
schedule::{LogLevel, ScheduleBuildSettings},
};
use bevy_log::LogPlugin;

View file

@ -310,6 +310,7 @@ pub enum DeserializeMetaError {
}
/// A context that provides access to assets in [`AssetLoader`]s, tracks dependencies, and collects asset load state.
///
/// Any asset state accessed by [`LoadContext`] will be tracked and stored for use in dependency events and asset preprocessing.
pub struct LoadContext<'a> {
pub(crate) asset_server: &'a AssetServer,

View file

@ -7,8 +7,7 @@ use crate::{
Asset, AssetLoadError, AssetPath, ErasedAssetLoader, ErasedLoadedAsset, Handle, LoadContext,
LoadDirectError, LoadedAsset, LoadedUntypedAsset,
};
use std::any::TypeId;
use std::sync::Arc;
use std::{any::TypeId, sync::Arc};
// Utility type for handling the sources of reader references
enum ReaderRef<'a> {

View file

@ -1,5 +1,7 @@
use crate::{self as bevy_asset, DeserializeMetaError, VisitAssetDependencies};
use crate::{loader::AssetLoader, processor::Process, Asset, AssetPath};
use crate::{
self as bevy_asset, loader::AssetLoader, processor::Process, Asset, AssetPath,
DeserializeMetaError, VisitAssetDependencies,
};
use bevy_utils::tracing::error;
use downcast_rs::{impl_downcast, Downcast};
use ron::ser::PrettyConfig;

View file

@ -1,7 +1,6 @@
use crate::AssetPath;
use async_fs::File;
use bevy_utils::tracing::error;
use bevy_utils::HashSet;
use bevy_utils::{tracing::error, HashSet};
use futures_lite::{AsyncReadExt, AsyncWriteExt};
use std::path::PathBuf;
use thiserror::Error;
@ -15,6 +14,7 @@ pub(crate) enum LogEntry {
}
/// A "write ahead" logger that helps ensure asset importing is transactional.
///
/// Prior to processing an asset, we write to the log to indicate it has started
/// After processing an asset, we write to the log to indicate it has finished.
/// On startup, the log can be read to determine if any transactions were incomplete.

View file

@ -58,13 +58,15 @@ use crate::{
};
use bevy_ecs::prelude::*;
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{debug, error, trace, warn};
use bevy_utils::{
tracing::{debug, error, trace, warn},
HashMap, HashSet,
};
#[cfg(feature = "trace")]
use bevy_utils::{
tracing::{info_span, instrument::Instrument},
ConditionalSendFuture,
};
use bevy_utils::{HashMap, HashSet};
use futures_io::ErrorKind;
use futures_lite::{AsyncReadExt, AsyncWriteExt, StreamExt};
use parking_lot::RwLock;

View file

@ -1,14 +1,12 @@
use crate::io::SliceReader;
use crate::transformer::IdentityAssetTransformer;
use crate::{
io::{
AssetReaderError, AssetWriterError, MissingAssetWriterError,
MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, Writer,
MissingProcessedAssetReaderError, MissingProcessedAssetWriterError, SliceReader, Writer,
},
meta::{AssetAction, AssetMeta, AssetMetaDyn, ProcessDependencyInfo, ProcessedInfo, Settings},
processor::AssetProcessor,
saver::{AssetSaver, SavedAsset},
transformer::{AssetTransformer, TransformedAsset},
transformer::{AssetTransformer, IdentityAssetTransformer, TransformedAsset},
AssetLoadError, AssetLoader, AssetPath, DeserializeMetaError, ErasedLoadedAsset,
MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError,
};

View file

@ -1,6 +1,7 @@
use crate::transformer::TransformedAsset;
use crate::{io::Writer, meta::Settings, Asset, ErasedLoadedAsset};
use crate::{AssetLoader, Handle, LabeledAsset, UntypedHandle};
use crate::{
io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader,
ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle,
};
use atomicow::CowArc;
use bevy_utils::{BoxedFuture, ConditionalSendFuture, HashMap};
use serde::{Deserialize, Serialize};

View file

@ -6,8 +6,7 @@ use crate::{
};
use bevy_ecs::world::World;
use bevy_tasks::Task;
use bevy_utils::tracing::warn;
use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap};
use bevy_utils::{tracing::warn, Entry, HashMap, HashSet, TypeIdMap};
use crossbeam_channel::Sender;
use std::{
any::TypeId,

View file

@ -4,13 +4,15 @@ use crate::{
};
use async_broadcast::RecvError;
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{error, warn};
use bevy_utils::{
tracing::{error, warn},
HashMap, TypeIdMap,
};
#[cfg(feature = "trace")]
use bevy_utils::{
tracing::{info_span, instrument::Instrument},
ConditionalSendFuture,
};
use bevy_utils::{HashMap, TypeIdMap};
use std::{any::TypeId, sync::Arc};
use thiserror::Error;

View file

@ -20,16 +20,22 @@ use crate::{
use atomicow::CowArc;
use bevy_ecs::prelude::*;
use bevy_tasks::IoTaskPool;
use bevy_utils::tracing::{error, info};
use bevy_utils::HashSet;
use bevy_utils::{
tracing::{error, info},
HashSet,
};
use crossbeam_channel::{Receiver, Sender};
use futures_lite::{FutureExt, StreamExt};
use info::*;
use loaders::*;
use parking_lot::RwLock;
use std::{any::Any, path::PathBuf};
use std::{any::TypeId, path::Path, sync::Arc};
use std::{future::Future, panic::AssertUnwindSafe};
use std::{
any::{Any, TypeId},
future::Future,
panic::AssertUnwindSafe,
path::{Path, PathBuf},
sync::Arc,
};
use thiserror::Error;
/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and

View file

@ -44,6 +44,7 @@ pub enum PlaybackMode {
}
/// Initial settings to be used when audio starts playing.
///
/// If you would like to control the audio while it is playing, query for the
/// [`AudioSink`][crate::AudioSink] or [`SpatialAudioSink`][crate::SpatialAudioSink]
/// components. Changes to this component will *not* be applied to already-playing audio.

View file

@ -73,6 +73,7 @@ impl AssetLoader for AudioLoader {
}
/// A type implementing this trait can be converted to a [`rodio::Source`] type.
///
/// It must be [`Send`] and [`Sync`] in order to be registered.
/// Types that implement this trait usually contain raw sound data that can be converted into an iterator of samples.
/// This trait is implemented for [`AudioSource`].

View file

@ -48,9 +48,7 @@ pub use audio::*;
pub use audio_source::*;
pub use pitch::*;
pub use rodio::cpal::Sample as CpalSample;
pub use rodio::source::Source;
pub use rodio::Sample;
pub use rodio::{cpal::Sample as CpalSample, source::Source, Sample};
pub use sinks::*;
use bevy_app::prelude::*;

View file

@ -1,7 +1,10 @@
use crate::{AudioSourceBundle, Decodable};
use bevy_asset::Asset;
use bevy_reflect::TypePath;
use rodio::{source::SineWave, source::TakeDuration, Source};
use rodio::{
source::{SineWave, TakeDuration},
Source,
};
/// A source of sine wave sound
#[derive(Asset, Debug, Clone, TypePath)]

View file

@ -66,8 +66,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::palettes::basic;
use crate::Srgba;
use crate::{palettes::basic, Srgba};
#[test]
fn test_color_curve() {

View file

@ -22,8 +22,7 @@ impl<T: Mix> ColorRange<T> for Range<T> {
#[cfg(test)]
mod tests {
use super::*;
use crate::palettes::basic;
use crate::{LinearRgba, Srgba};
use crate::{palettes::basic, LinearRgba, Srgba};
#[test]
fn test_color_range() {

View file

@ -57,7 +57,6 @@
//! a form of chromaticity, while `y` defines an illuminance level.
//!
//! See also the [Wikipedia article on color spaces](https://en.wikipedia.org/wiki/Color_space).
//!
#![doc = include_str!("../docs/conversion.md")]
//! <div>
#![doc = include_str!("../docs/diagrams/model_graph.svg")]
@ -115,18 +114,10 @@ mod xyza;
///
/// This includes the most common types in this crate, re-exported for your convenience.
pub mod prelude {
pub use crate::color::*;
pub use crate::color_ops::*;
pub use crate::hsla::*;
pub use crate::hsva::*;
pub use crate::hwba::*;
pub use crate::laba::*;
pub use crate::lcha::*;
pub use crate::linear_rgba::*;
pub use crate::oklaba::*;
pub use crate::oklcha::*;
pub use crate::srgba::*;
pub use crate::xyza::*;
pub use crate::{
color::*, color_ops::*, hsla::*, hsva::*, hwba::*, laba::*, lcha::*, linear_rgba::*,
oklaba::*, oklcha::*, srgba::*, xyza::*,
};
}
pub use color::*;

View file

@ -3,29 +3,27 @@
//!
//! Generated from Tailwind 3.4.1.
/*
MIT License
Copyright (c) Tailwind Labs, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// MIT License
//
// Copyright (c) Tailwind Labs, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
use crate::Srgba;

View file

@ -1,7 +1,6 @@
use crate::color_difference::EuclideanDistance;
use crate::{
impl_componentwise_vector_space, Alpha, ColorToComponents, ColorToPacked, Gray, LinearRgba,
Luminance, Mix, StandardColor, Xyza,
color_difference::EuclideanDistance, impl_componentwise_vector_space, Alpha, ColorToComponents,
ColorToPacked, Gray, LinearRgba, Luminance, Mix, StandardColor, Xyza,
};
use bevy_math::{ops, Vec3, Vec4};
#[cfg(feature = "bevy_reflect")]
@ -185,7 +184,6 @@ impl Srgba {
/// * `b` - Blue channel. [0, 255]
///
/// See also [`Srgba::new`], [`Srgba::rgba_u8`], [`Srgba::hex`].
///
pub fn rgb_u8(r: u8, g: u8, b: u8) -> Self {
Self::from_u8_array_no_alpha([r, g, b])
}
@ -202,7 +200,6 @@ impl Srgba {
/// * `a` - Alpha channel. [0, 255]
///
/// See also [`Srgba::new`], [`Srgba::rgb_u8`], [`Srgba::hex`].
///
pub fn rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Self {
Self::from_u8_array([r, g, b, a])
}

View file

@ -1,7 +1,6 @@
use bevy_ecs::query::QueryData;
#[cfg(feature = "bevy_reflect")]
use bevy_ecs::reflect::ReflectComponent;
use bevy_ecs::{component::Component, entity::Entity};
use bevy_ecs::{component::Component, entity::Entity, query::QueryData};
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::std_traits::ReflectDefault;
@ -141,7 +140,7 @@ impl<'a> std::fmt::Display for NameOrEntityItem<'a> {
}
}
/* Conversions from strings */
// Conversions from strings
impl From<&str> for Name {
#[inline(always)]
@ -156,7 +155,7 @@ impl From<String> for Name {
}
}
/* Conversions to strings */
// Conversions to strings
impl AsRef<str> for Name {
#[inline(always)]

View file

@ -8,8 +8,7 @@ use serde::{
Deserialize, Deserializer, Serialize, Serializer,
};
use super::name::Name;
use super::FrameCount;
use super::{name::Name, FrameCount};
impl Serialize for Name {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {

View file

@ -6,8 +6,7 @@ use bevy_render::{
};
use bevy_utils::{Entry, HashMap};
use super::pipeline::AutoExposureUniform;
use super::AutoExposure;
use super::{pipeline::AutoExposureUniform, AutoExposure};
#[derive(Resource, Default)]
pub(super) struct AutoExposureBuffers {

View file

@ -1,17 +1,15 @@
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, AssetApp, Assets, Handle};
use bevy_ecs::prelude::*;
use bevy_render::extract_component::ExtractComponentPlugin;
use bevy_render::render_asset::RenderAssetPlugin;
use bevy_render::render_resource::Shader;
use bevy_render::ExtractSchedule;
use bevy_render::{
extract_component::ExtractComponentPlugin,
render_asset::RenderAssetPlugin,
render_graph::RenderGraphApp,
render_resource::{
Buffer, BufferDescriptor, BufferUsages, PipelineCache, SpecializedComputePipelines,
Buffer, BufferDescriptor, BufferUsages, PipelineCache, Shader, SpecializedComputePipelines,
},
renderer::RenderDevice,
Render, RenderApp, RenderSet,
ExtractSchedule, Render, RenderApp, RenderSet,
};
mod buffers;
@ -29,8 +27,10 @@ use pipeline::{
#[allow(deprecated)]
pub use settings::{AutoExposure, AutoExposureSettings};
use crate::auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve;
use crate::core_3d::graph::{Core3d, Node3d};
use crate::{
auto_exposure::compensation_curve::GpuAutoExposureCompensationCurve,
core_3d::graph::{Core3d, Node3d},
};
/// Plugin for the auto exposure feature.
///

View file

@ -3,8 +3,7 @@ use std::ops::RangeInclusive;
use super::compensation_curve::AutoExposureCompensationCurve;
use bevy_asset::Handle;
use bevy_ecs::{prelude::Component, reflect::ReflectComponent};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{extract_component::ExtractComponent, texture::Image};
use bevy_utils::default;
@ -23,7 +22,6 @@ use bevy_utils::default;
/// # Usage Notes
///
/// **Auto Exposure requires compute shaders and is not compatible with WebGL2.**
///
#[derive(Component, Clone, Reflect, ExtractComponent)]
#[reflect(Component, Default)]
pub struct AutoExposure {

View file

@ -6,8 +6,7 @@ use crate::{
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, Handle};
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
extract_component::{ExtractComponent, ExtractComponentPlugin, UniformComponentPlugin},
prelude::Camera,

View file

@ -1,15 +1,16 @@
use crate::core_2d::graph::Core2d;
use crate::tonemapping::{DebandDither, Tonemapping};
use crate::{
core_2d::graph::Core2d,
tonemapping::{DebandDither, Tonemapping},
};
use bevy_ecs::prelude::*;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_render::prelude::Msaa;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
camera::{
Camera, CameraMainTextureUsages, CameraProjection, CameraRenderGraph,
OrthographicProjection,
},
extract_component::ExtractComponent,
prelude::Msaa,
primitives::Frustum,
view::VisibleEntities,
};

View file

@ -3,15 +3,13 @@ use crate::{
tonemapping::{DebandDither, Tonemapping},
};
use bevy_ecs::prelude::*;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::view::Msaa;
use bevy_reflect::{std_traits::ReflectDefault, Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::{
camera::{Camera, CameraMainTextureUsages, CameraRenderGraph, Exposure, Projection},
extract_component::ExtractComponent,
primitives::Frustum,
render_resource::{LoadOp, TextureUsages},
view::{ColorGrading, VisibleEntities},
view::{ColorGrading, Msaa, VisibleEntities},
};
use bevy_transform::prelude::{GlobalTransform, Transform};
use serde::{Deserialize, Serialize};

View file

@ -1,13 +1,11 @@
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryItem;
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_render::render_graph::ViewNode;
use bevy_render::render_phase::{TrackedRenderPass, ViewBinnedRenderPhases};
use bevy_render::render_resource::{CommandEncoderDescriptor, StoreOp};
use bevy_render::{
camera::ExtractedCamera,
render_graph::{NodeRunError, RenderGraphContext},
render_resource::RenderPassDescriptor,
render_phase::{TrackedRenderPass, ViewBinnedRenderPhases},
render_resource::{CommandEncoderDescriptor, RenderPassDescriptor, StoreOp},
renderer::RenderContext,
view::ViewDepthTexture,
};

View file

@ -10,8 +10,7 @@ use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
extract_component::{ExtractComponent, ExtractComponentPlugin},
prelude::Camera,
render_graph::RenderGraphApp,
render_graph::ViewNodeRunner,
render_graph::{RenderGraphApp, ViewNodeRunner},
render_resource::{
binding_types::{sampler, texture_2d},
*,

View file

@ -1,8 +1,7 @@
use std::sync::Mutex;
use crate::fxaa::{CameraFxaaPipeline, Fxaa, FxaaPipeline};
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryItem;
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_render::{
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{

View file

@ -5,17 +5,15 @@ use crate::{
};
use bevy_app::{App, Plugin};
use bevy_color::LinearRgba;
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryItem;
use bevy_render::render_graph::{ViewNode, ViewNodeRunner};
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_render::{
camera::ExtractedCamera,
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext},
render_graph::{NodeRunError, RenderGraphApp, RenderGraphContext, ViewNode, ViewNodeRunner},
render_resource::*,
renderer::RenderContext,
view::{Msaa, ViewTarget},
Render, RenderSet,
Render, RenderApp, RenderSet,
};
use bevy_render::{render_resource::*, RenderApp};
/// This enables "msaa writeback" support for the `core_2d` and `core_3d` pipelines, which can be enabled on cameras
/// using [`bevy_render::camera::Camera::msaa_writeback`]. See the docs on that field for more information.

View file

@ -32,8 +32,7 @@ use std::ops::Range;
use bevy_asset::UntypedAssetId;
use bevy_ecs::prelude::*;
use bevy_math::Mat4;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
render_phase::{
BinnedPhaseItem, CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem,

View file

@ -1,5 +1,4 @@
use bevy_ecs::prelude::*;
use bevy_ecs::query::QueryItem;
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_render::{
camera::ExtractedCamera,
diagnostic::RecordDiagnostics,

View file

@ -15,8 +15,7 @@ use bevy_ecs::{
world::{FromWorld, World},
};
use bevy_math::vec2;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
camera::{ExtractedCamera, MipBias, TemporalJitter},
prelude::{Camera, Projection},

View file

@ -2,19 +2,21 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, Assets, Handle};
use bevy_ecs::prelude::*;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::Reflect;
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
use bevy_render::extract_resource::{ExtractResource, ExtractResourcePlugin};
use bevy_render::render_asset::{RenderAssetUsages, RenderAssets};
use bevy_render::render_resource::binding_types::{
sampler, texture_2d, texture_3d, uniform_buffer,
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::{
camera::Camera,
extract_component::{ExtractComponent, ExtractComponentPlugin},
extract_resource::{ExtractResource, ExtractResourcePlugin},
render_asset::{RenderAssetUsages, RenderAssets},
render_resource::{
binding_types::{sampler, texture_2d, texture_3d, uniform_buffer},
*,
},
renderer::RenderDevice,
texture::{CompressedImageFormats, FallbackImage, GpuImage, Image, ImageSampler, ImageType},
view::{ExtractedView, ViewTarget, ViewUniform},
Render, RenderApp, RenderSet,
};
use bevy_render::renderer::RenderDevice;
use bevy_render::texture::{CompressedImageFormats, GpuImage, Image, ImageSampler, ImageType};
use bevy_render::view::{ExtractedView, ViewTarget, ViewUniform};
use bevy_render::{camera::Camera, texture::FallbackImage};
use bevy_render::{render_resource::*, Render, RenderApp, RenderSet};
#[cfg(not(feature = "tonemapping_luts"))]
use bevy_utils::tracing::error;
use bitflags::bitflags;

View file

@ -1,9 +1,12 @@
use crate::blit::{BlitPipeline, BlitPipelineKey};
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;
use bevy_render::camera::{CameraOutputMode, ExtractedCamera};
use bevy_render::view::ViewTarget;
use bevy_render::{render_resource::*, Render, RenderApp, RenderSet};
use bevy_render::{
camera::{CameraOutputMode, ExtractedCamera},
render_resource::*,
view::ViewTarget,
Render, RenderApp, RenderSet,
};
use bevy_utils::HashSet;
mod node;

View file

@ -1,8 +1,7 @@
use crate::{blit::BlitPipeline, upscaling::ViewUpscalingPipeline};
use bevy_ecs::{prelude::*, query::QueryItem};
use bevy_render::camera::{ClearColor, ClearColorConfig};
use bevy_render::{
camera::{CameraOutputMode, ExtractedCamera},
camera::{CameraOutputMode, ClearColor, ClearColorConfig, ExtractedCamera},
render_graph::{NodeRunError, RenderGraphContext, ViewNode},
render_resource::{
BindGroup, BindGroupEntries, PipelineCache, RenderPassDescriptor, TextureViewId,

View file

@ -1,5 +1,8 @@
use std::hash::{Hash, Hasher};
use std::{borrow::Cow, collections::VecDeque};
use std::{
borrow::Cow,
collections::VecDeque,
hash::{Hash, Hasher},
};
use bevy_app::{App, SubApp};
use bevy_ecs::system::{Deferred, Res, Resource, SystemBuffer, SystemParam};

View file

@ -2,8 +2,10 @@ use super::{Diagnostic, DiagnosticPath, DiagnosticsStore};
use bevy_app::prelude::*;
use bevy_ecs::prelude::*;
use bevy_time::{Real, Time, Timer, TimerMode};
use bevy_utils::tracing::{debug, info};
use bevy_utils::Duration;
use bevy_utils::{
tracing::{debug, info},
Duration,
};
/// An App Plugin that logs diagnostics to the console.
///

View file

@ -90,7 +90,6 @@ impl BatchingStrategy {
/// # Panics
///
/// Panics if `thread_count` is 0.
///
#[inline]
pub fn calc_batch_size(&self, max_items: impl FnOnce() -> usize, thread_count: usize) -> usize {
if self.batch_size_limits.is_empty() {

View file

@ -1446,9 +1446,7 @@ fn initialize_dynamic_bundle(
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::component::ComponentId;
use crate::prelude::*;
use crate::world::DeferredWorld;
use crate::{component::ComponentId, prelude::*, world::DeferredWorld};
#[derive(Component)]
struct A;

View file

@ -8,10 +8,12 @@ use crate::{
#[cfg(feature = "track_change_detection")]
use bevy_ptr::ThinSlicePtr;
use bevy_ptr::{Ptr, UnsafeCellDeref};
use std::mem;
use std::ops::{Deref, DerefMut};
#[cfg(feature = "track_change_detection")]
use std::{cell::UnsafeCell, panic::Location};
use std::{
mem,
ops::{Deref, DerefMut},
};
/// The (arbitrarily chosen) minimum number of world tick increments between `check_tick` scans.
///
@ -102,7 +104,6 @@ pub trait DetectChanges {
/// resource.0 = 42; // triggers change detection via [`DerefMut`]
/// }
/// ```
///
pub trait DetectChangesMut: DetectChanges {
/// The type contained within this smart pointer
///

View file

@ -21,11 +21,12 @@ use std::{
alloc::Layout,
any::{Any, TypeId},
borrow::Cow,
cell::UnsafeCell,
fmt::Debug,
marker::PhantomData,
mem::needs_drop,
sync::Arc,
};
use std::{cell::UnsafeCell, fmt::Debug};
/// A data type that can be used to store data for an [entity].
///
@ -266,7 +267,6 @@ use std::{cell::UnsafeCell, fmt::Debug};
/// fn my_on_insert_hook<T1, T2>(world: DeferredWorld, _: T1, _: T2) {
/// // ...
/// }
///
/// ```
///
/// # Implementing the trait for foreign types

View file

@ -221,9 +221,8 @@ impl<'m> SceneEntityMapper<'m> {
#[cfg(test)]
mod tests {
use crate::entity::DynEntityMapper;
use crate::{
entity::{Entity, EntityHashMap, EntityMapper, SceneEntityMapper},
entity::{DynEntityMapper, Entity, EntityHashMap, EntityMapper, SceneEntityMapper},
world::World,
};
use bevy_utils::assert_object_safe;

View file

@ -8,8 +8,10 @@ use bevy_ecs::{
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_utils::detailed_trace;
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
use std::{
marker::PhantomData,
ops::{Deref, DerefMut},
};
/// An event collection that represents the events that occurred within the last two
/// [`Events::update`] calls.

View file

@ -96,7 +96,6 @@ impl<'w, 's, E: Event> EventMutator<'w, 's, E> {
/// // all events were processed
/// assert_eq!(counter.into_inner(), 4950);
/// ```
///
#[cfg(feature = "multi_threaded")]
pub fn par_read(&mut self) -> EventMutParIter<'_, E> {
self.reader.par_read_mut(&mut self.events)

View file

@ -68,7 +68,6 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
/// // all events were processed
/// assert_eq!(counter.into_inner(), 4950);
/// ```
///
#[cfg(feature = "multi_threaded")]
pub fn par_read(&mut self) -> EventParIter<'_, E> {
self.reader.par_read(&self.events)

View file

@ -14,6 +14,7 @@ pub(crate) mod kinds;
pub(crate) mod masks;
/// A unified identifier for all entity and similar IDs.
///
/// Has the same size as a `u64` integer, but the layout is split between a 32-bit low
/// segment, a 31-bit high segment, and the significant bit reserved as type flags to denote
/// entity kinds.

View file

@ -24,7 +24,6 @@ use bevy_utils::HashSet;
/// Two interned values are only guaranteed to compare equal if they were interned using
/// the same [`Interner`] instance.
// NOTE: This type must NEVER implement Borrow since it does not obey that trait's invariants.
///
/// ```
/// # use bevy_ecs::intern::*;
/// #[derive(PartialEq, Eq, Hash, Debug)]

View file

@ -77,23 +77,22 @@ pub mod prelude {
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::prelude::Or;
use crate::world::EntityMut;
use crate::{
bundle::Bundle,
change_detection::Ref,
component::{Component, ComponentId},
entity::Entity,
prelude::Or,
query::{Added, Changed, FilteredAccess, QueryFilter, With, Without},
system::Resource,
world::{EntityRef, Mut, World},
world::{EntityMut, EntityRef, Mut, World},
};
use bevy_tasks::{ComputeTaskPool, TaskPool};
use bevy_utils::HashSet;
use std::num::NonZero;
use std::{
any::TypeId,
marker::PhantomData,
num::NonZero,
sync::{
atomic::{AtomicUsize, Ordering},
Arc, Mutex,

View file

@ -7,14 +7,22 @@ mod trigger_event;
pub use runner::*;
pub use trigger_event::*;
use crate::entity::EntityHashMap;
use crate::observer::entity_observer::ObservedBy;
use crate::{archetype::ArchetypeFlags, system::IntoObserverSystem, world::*};
use crate::{component::ComponentId, prelude::*, world::DeferredWorld};
use crate::{
archetype::ArchetypeFlags,
component::ComponentId,
entity::EntityHashMap,
observer::entity_observer::ObservedBy,
prelude::*,
system::IntoObserverSystem,
world::{DeferredWorld, *},
};
use bevy_ptr::Ptr;
use bevy_utils::HashMap;
use std::ops::{Deref, DerefMut};
use std::{fmt::Debug, marker::PhantomData};
use std::{
fmt::Debug,
marker::PhantomData,
ops::{Deref, DerefMut},
};
/// Type containing triggered [`Event`] information for a given run of an [`Observer`]. This contains the
/// [`Event`] data itself. If it was triggered for a specific [`Entity`], it includes that as well. It also
@ -525,11 +533,11 @@ mod tests {
use bevy_ptr::OwningPtr;
use crate as bevy_ecs;
use crate::observer::{
EmitDynamicTrigger, Observer, ObserverDescriptor, ObserverState, OnReplace,
use crate::{
observer::{EmitDynamicTrigger, Observer, ObserverDescriptor, ObserverState, OnReplace},
prelude::*,
traversal::Traversal,
};
use crate::prelude::*;
use crate::traversal::Traversal;
#[derive(Component)]
struct A;

View file

@ -86,6 +86,7 @@ impl Component for ObserverState {
}
/// Type for function that is run when an observer is triggered.
///
/// Typically refers to the default runner that runs the system stored in the associated [`Observer`] component,
/// but can be overridden for custom behaviour.
pub type ObserverRunner = fn(DeferredWorld, ObserverTrigger, PtrMut, propagate: &mut bool);

View file

@ -100,6 +100,7 @@ fn trigger_event<E: Event, Targets: TriggerTargets>(
}
/// Represents a collection of targets for a specific [`Trigger`] of an [`Event`]. Targets can be of type [`Entity`] or [`ComponentId`].
///
/// When a trigger occurs for a given event and [`TriggerTargets`], any [`Observer`] that watches for that specific event-target combination
/// will run.
///

View file

@ -1,8 +1,7 @@
use crate::storage::SparseSetIndex;
use core::fmt;
use fixedbitset::FixedBitSet;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::{fmt::Debug, marker::PhantomData};
/// A wrapper struct to make Debug representations of [`FixedBitSet`] easier
/// to read, when used to store [`SparseSetIndex`].
@ -1277,8 +1276,9 @@ impl<T: SparseSetIndex> Default for FilteredAccessSet<T> {
#[cfg(test)]
mod tests {
use crate::query::access::AccessFilters;
use crate::query::{Access, AccessConflicts, FilteredAccess, FilteredAccessSet};
use crate::query::{
access::AccessFilters, Access, AccessConflicts, FilteredAccess, FilteredAccessSet,
};
use fixedbitset::FixedBitSet;
use std::marker::PhantomData;

View file

@ -1,7 +1,9 @@
use std::marker::PhantomData;
use crate::component::StorageType;
use crate::{component::ComponentId, prelude::*};
use crate::{
component::{ComponentId, StorageType},
prelude::*,
};
use super::{FilteredAccess, QueryData, QueryFilter};
@ -32,7 +34,7 @@ use super::{FilteredAccess, QueryData, QueryFilter};
///
/// // Consume the QueryState
/// let (entity, b) = query.single(&world);
///```
/// ```
pub struct QueryBuilder<'w, D: QueryData = (), F: QueryFilter = ()> {
access: FilteredAccess<ComponentId>,
world: &'w mut World,
@ -275,8 +277,7 @@ impl<'w, D: QueryData, F: QueryFilter> QueryBuilder<'w, D, F> {
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::prelude::*;
use crate::world::FilteredEntityRef;
use crate::{prelude::*, world::FilteredEntityRef};
#[derive(Component, PartialEq, Debug)]
struct A(usize);

View file

@ -1005,7 +1005,6 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryIter<'w, 's, D, F> {
/// # Panics
///
/// This will panic if `next` has been called on `QueryIter` before, unless the underlying `Query` is empty.
///
pub fn sort_by_cached_key<L: ReadOnlyQueryData + 'w, K>(
self,
mut f: impl FnMut(&L::Item<'w>) -> K,
@ -1582,7 +1581,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter, const K: usize> QueryCombinationIter<
/// The lifetime here is not restrictive enough for Fetch with &mut access,
/// as calling `fetch_next_aliased_unchecked` multiple times can produce multiple
/// references to the same component, leading to unique reference aliasing.
///.
/// .
/// It is always safe for shared access.
#[inline]
unsafe fn fetch_next_aliased_unchecked(&mut self) -> Option<[D::Item<'w>; K]> {

View file

@ -103,16 +103,17 @@ impl<T> DebugCheckedUnwrap for Option<T> {
#[cfg(test)]
mod tests {
use crate::prelude::{AnyOf, Changed, Entity, Or, QueryState, With, Without};
use crate::query::{ArchetypeFilter, Has, QueryCombinationIter, ReadOnlyQueryData};
use crate::schedule::{IntoSystemConfigs, Schedule};
use crate::system::{IntoSystem, Query, System, SystemState};
use crate::{self as bevy_ecs, component::Component, world::World};
use crate::{
self as bevy_ecs,
component::Component,
prelude::{AnyOf, Changed, Entity, Or, QueryState, With, Without},
query::{ArchetypeFilter, Has, QueryCombinationIter, ReadOnlyQueryData},
schedule::{IntoSystemConfigs, Schedule},
system::{IntoSystem, Query, System, SystemState},
world::World,
};
use bevy_ecs_macros::{QueryData, QueryFilter};
use std::any::type_name;
use std::collections::HashSet;
use std::fmt::Debug;
use std::hash::Hash;
use std::{any::type_name, collections::HashSet, fmt::Debug, hash::Hash};
#[derive(Component, Debug, Hash, Eq, PartialEq, Clone, Copy, PartialOrd, Ord)]
struct A(usize);

View file

@ -1719,8 +1719,9 @@ impl<D: QueryData, F: QueryFilter> From<QueryBuilder<'_, D, F>> for QueryState<D
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::world::FilteredEntityRef;
use crate::{component::Component, prelude::*, query::QueryEntityError};
use crate::{
component::Component, prelude::*, query::QueryEntityError, world::FilteredEntityRef,
};
#[test]
fn get_many_unchecked_manual_uniqueness() {

View file

@ -1,15 +1,12 @@
use crate::prelude::Mut;
use crate::reflect::AppTypeRegistry;
use crate::system::{EntityCommands, Resource};
use crate::world::Command;
use crate::{
entity::Entity,
reflect::{ReflectBundle, ReflectComponent},
world::World,
prelude::Mut,
reflect::{AppTypeRegistry, ReflectBundle, ReflectComponent},
system::{EntityCommands, Resource},
world::{Command, World},
};
use bevy_reflect::{PartialReflect, TypeRegistry};
use std::borrow::Cow;
use std::marker::PhantomData;
use std::{borrow::Cow, marker::PhantomData};
/// An extension trait for [`EntityCommands`] for reflection related functions
pub trait ReflectCommandExt {
@ -86,7 +83,6 @@ pub trait ReflectCommandExt {
/// .spawn_empty()
/// .insert_reflect(prefab.data.clone_value());
/// }
///
/// ```
fn insert_reflect(&mut self, component: Box<dyn PartialReflect>) -> &mut Self;
@ -161,7 +157,6 @@ pub trait ReflectCommandExt {
/// commands.entity(prefab.entity)
/// .remove_reflect(prefab.data.reflect_type_path().to_owned());
/// }
///
/// ```
fn remove_reflect(&mut self, component_type_name: impl Into<Cow<'static, str>>) -> &mut Self;
/// Same as [`remove_reflect`](ReflectCommandExt::remove_reflect), but using the `T` resource as type registry instead of
@ -351,10 +346,15 @@ impl<T: Resource + AsRef<TypeRegistry>> Command for RemoveReflectWithRegistry<T>
#[cfg(test)]
mod tests {
use crate::prelude::{AppTypeRegistry, ReflectComponent};
use crate::reflect::{ReflectBundle, ReflectCommandExt};
use crate::system::{Commands, SystemState};
use crate::{self as bevy_ecs, bundle::Bundle, component::Component, world::World};
use crate::{
self as bevy_ecs,
bundle::Bundle,
component::Component,
prelude::{AppTypeRegistry, ReflectComponent},
reflect::{ReflectBundle, ReflectCommandExt},
system::{Commands, SystemState},
world::World,
};
use bevy_ecs_macros::Resource;
use bevy_reflect::{PartialReflect, Reflect, TypeRegistry};

View file

@ -6,6 +6,7 @@ use crate::{
use bevy_reflect::FromType;
/// For a specific type of component, this maps any fields with values of type [`Entity`] to a new world.
///
/// Since a given `Entity` ID is only valid for the world it came from, when performing deserialization
/// any stored IDs need to be re-allocated in the destination world.
///
@ -75,6 +76,7 @@ impl<C: Component + MapEntities> FromType<C> for ReflectMapEntities {
}
/// For a specific type of resource, this maps any fields with values of type [`Entity`] to a new world.
///
/// Since a given `Entity` ID is only valid for the world it came from, when performing deserialization
/// any stored IDs need to be re-allocated in the destination world.
///

View file

@ -1,13 +1,15 @@
//! Types that enable reflection support.
use std::any::TypeId;
use std::ops::{Deref, DerefMut};
use std::{
any::TypeId,
ops::{Deref, DerefMut},
};
use crate as bevy_ecs;
use crate::{system::Resource, world::World};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::{
PartialReflect, Reflect, ReflectFromReflect, TypePath, TypeRegistry, TypeRegistryArc,
std_traits::ReflectDefault, PartialReflect, Reflect, ReflectFromReflect, TypePath,
TypeRegistry, TypeRegistryArc,
};
mod bundle;

View file

@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::ops::Not;
use std::{borrow::Cow, ops::Not};
use crate::system::{
Adapt, AdapterSystem, CombinatorSystem, Combine, IntoSystem, ReadOnlySystem, System, SystemIn,
@ -1351,12 +1350,14 @@ where
mod tests {
use super::{common_conditions::*, Condition};
use crate as bevy_ecs;
use crate::component::Component;
use crate::schedule::IntoSystemConfigs;
use crate::system::Local;
use crate::{change_detection::ResMut, schedule::Schedule, world::World};
use bevy_ecs_macros::Event;
use bevy_ecs_macros::Resource;
use crate::{
change_detection::ResMut,
component::Component,
schedule::{IntoSystemConfigs, Schedule},
system::Local,
world::World,
};
use bevy_ecs_macros::{Event, Resource};
#[derive(Resource, Default)]
struct Counter(usize);

View file

@ -2,9 +2,11 @@ mod multi_threaded;
mod simple;
mod single_threaded;
pub use self::multi_threaded::{MainThreadExecutor, MultiThreadedExecutor};
pub use self::simple::SimpleExecutor;
pub use self::single_threaded::SingleThreadedExecutor;
pub use self::{
multi_threaded::{MainThreadExecutor, MultiThreadedExecutor},
simple::SimpleExecutor,
single_threaded::SingleThreadedExecutor,
};
use fixedbitset::FixedBitSet;
@ -127,6 +129,7 @@ pub(super) fn is_apply_deferred(system: &BoxedSystem) -> bool {
}
/// These functions hide the bottom of the callstack from `RUST_BACKTRACE=1` (assuming the default panic handler is used).
///
/// The full callstack will still be visible with `RUST_BACKTRACE=full`.
/// They are specialized for `System::run` & co instead of being generic over closures because this avoids an
/// extra frame in the backtrace.

View file

@ -4,10 +4,9 @@ use std::{
};
use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor};
use bevy_utils::default;
use bevy_utils::syncunsafecell::SyncUnsafeCell;
#[cfg(feature = "trace")]
use bevy_utils::tracing::{info_span, Span};
use bevy_utils::{default, syncunsafecell::SyncUnsafeCell};
use std::panic::AssertUnwindSafe;
use concurrent_queue::ConcurrentQueue;

View file

@ -9,12 +9,8 @@ mod schedule;
mod set;
mod stepping;
pub use self::condition::*;
pub use self::config::*;
pub use self::executor::*;
use self::graph_utils::*;
pub use self::schedule::*;
pub use self::set::*;
pub use self::{condition::*, config::*, executor::*, schedule::*, set::*};
pub use self::graph_utils::NodeId;
@ -24,9 +20,11 @@ mod tests {
use std::sync::atomic::{AtomicU32, Ordering};
pub use crate as bevy_ecs;
pub use crate::schedule::{Schedule, SystemSet};
pub use crate::system::{Res, ResMut};
pub use crate::{prelude::World, system::Resource};
pub use crate::{
prelude::World,
schedule::{Schedule, SystemSet},
system::{Res, ResMut, Resource},
};
#[derive(SystemSet, Clone, Debug, PartialEq, Eq, Hash)]
enum TestSet {
@ -1158,7 +1156,7 @@ mod tests {
world.allow_ambiguous_resource::<R>();
let mut schedule = Schedule::new(TestSchedule);
//check resource
// check resource
schedule.add_systems((resmut_system, res_system));
schedule.initialize(&mut world).unwrap();
assert!(schedule.graph().conflicting_systems().is_empty());

View file

@ -5,9 +5,9 @@ use std::{
#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;
use bevy_utils::{default, tracing::info};
use bevy_utils::{
tracing::{error, warn},
default,
tracing::{error, info, warn},
HashMap, HashSet,
};
use disqualified::ShortName;
@ -24,8 +24,7 @@ use crate::{
world::World,
};
use crate::query::AccessConflicts;
use crate::storage::SparseSetIndex;
use crate::{query::AccessConflicts, storage::SparseSetIndex};
pub use stepping::Stepping;
/// Resource that stores [`Schedule`]s mapped to [`ScheduleLabel`]s excluding the current running [`Schedule`].

View file

@ -1,7 +1,9 @@
use std::any::TypeId;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::{
any::TypeId,
fmt::Debug,
hash::{Hash, Hasher},
marker::PhantomData,
};
pub use crate::label::DynEq;
pub use bevy_ecs_macros::{ScheduleLabel, SystemSet};

View file

@ -1,6 +1,5 @@
use fixedbitset::FixedBitSet;
use std::any::TypeId;
use std::collections::HashMap;
use std::{any::TypeId, collections::HashMap};
use crate::{
schedule::{InternedScheduleLabel, NodeId, Schedule, ScheduleLabel},
@ -827,8 +826,7 @@ impl ScheduleState {
#[cfg(all(test, feature = "bevy_debug_stepping"))]
mod tests {
use super::*;
use crate::prelude::*;
use crate::schedule::ScheduleLabel;
use crate::{prelude::*, schedule::ScheduleLabel};
pub use crate as bevy_ecs;

View file

@ -1,7 +1,9 @@
use crate::archetype::ArchetypeComponentId;
use crate::change_detection::{MaybeLocation, MaybeUnsafeCellLocation, MutUntyped, TicksMut};
use crate::component::{ComponentId, ComponentTicks, Components, Tick, TickCells};
use crate::storage::{blob_vec::BlobVec, SparseSet};
use crate::{
archetype::ArchetypeComponentId,
change_detection::{MaybeLocation, MaybeUnsafeCellLocation, MutUntyped, TicksMut},
component::{ComponentId, ComponentTicks, Components, Tick, TickCells},
storage::{blob_vec::BlobVec, SparseSet},
};
use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref};
#[cfg(feature = "track_change_detection")]
use std::panic::Location;

View file

@ -6,6 +6,7 @@ use crate::{
use bevy_ptr::PtrMut;
/// Very similar to a normal [`Column`], but with the capacities and lengths cut out for performance reasons.
///
/// This type is used by [`Table`], because all of the capacities and lengths of the [`Table`]'s columns must match.
///
/// Like many other low-level storage types, [`ThinColumn`] has a limited and highly unsafe
@ -411,7 +412,6 @@ impl Column {
///
/// # Safety
/// `row` must be within the range `[0, self.len())`.
///
#[inline]
pub(crate) unsafe fn swap_remove_unchecked(&mut self, row: TableRow) {
self.data.swap_remove_and_drop_unchecked(row.as_usize());

View file

@ -10,9 +10,10 @@ use bevy_utils::HashMap;
pub use column::*;
#[cfg(feature = "track_change_detection")]
use std::panic::Location;
use std::{alloc::Layout, num::NonZeroUsize};
use std::{
alloc::Layout,
cell::UnsafeCell,
num::NonZeroUsize,
ops::{Index, IndexMut},
};
mod column;
@ -814,13 +815,11 @@ impl Drop for Table {
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::component::Component;
use crate::ptr::OwningPtr;
use crate::storage::Storages;
use crate::{
component::{Components, Tick},
component::{Component, Components, Tick},
entity::Entity,
storage::{TableBuilder, TableRow},
ptr::OwningPtr,
storage::{Storages, TableBuilder, TableRow},
};
#[cfg(feature = "track_change_detection")]
use std::panic::Location;

View file

@ -1,8 +1,10 @@
use crate::query::DebugCheckedUnwrap;
use std::alloc::{alloc, handle_alloc_error, realloc, Layout};
use std::mem::{needs_drop, size_of};
use std::num::NonZeroUsize;
use std::ptr::{self, NonNull};
use std::{
alloc::{alloc, handle_alloc_error, realloc, Layout},
mem::{needs_drop, size_of},
num::NonZeroUsize,
ptr::{self, NonNull},
};
/// Similar to [`Vec<T>`], but with the capacity and length cut out for performance reasons.
///

View file

@ -71,7 +71,7 @@ use super::{init_query_param, Res, ResMut, Resource, SystemState};
/// .build_system(single_parameter_system);
///
/// world.run_system_once(system);
///```
/// ```
///
/// # Safety
///
@ -227,6 +227,7 @@ unsafe impl<P: SystemParam, B: SystemParamBuilder<P>> SystemParamBuilder<Vec<P>>
}
/// A [`SystemParamBuilder`] for a [`ParamSet`].
///
/// To build a [`ParamSet`] with a tuple of system parameters, pass a tuple of matching [`SystemParamBuilder`]s.
/// To build a [`ParamSet`] with a `Vec` of system parameters, pass a `Vec` of matching [`SystemParamBuilder`]s.
pub struct ParamSetBuilder<T>(pub T);
@ -348,9 +349,11 @@ unsafe impl<'s, T: FromWorld + Send + 'static> SystemParamBuilder<Local<'s, T>>
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::entity::Entities;
use crate::prelude::{Component, Query};
use crate::system::{Local, RunSystemOnce};
use crate::{
entity::Entities,
prelude::{Component, Query},
system::{Local, RunSystemOnce},
};
use super::*;

View file

@ -1777,6 +1777,7 @@ unsafe fn insert_by_id<T: Send + 'static>(
}
/// An [`EntityCommand`] that removes components from an entity.
///
/// For a [`Bundle`] type `T`, this will remove any components in the bundle.
/// Any components in the bundle that aren't found on the entity will be ignored.
fn remove<T: Bundle>(entity: Entity, world: &mut World) {
@ -1807,6 +1808,7 @@ fn clear() -> impl EntityCommand {
}
/// An [`EntityCommand`] that removes components from an entity.
///
/// For a [`Bundle`] type `T`, this will remove all components except those in the bundle.
/// Any components in the bundle that aren't found on the entity will be ignored.
fn retain<T: Bundle>(entity: Entity, world: &mut World) {

View file

@ -39,7 +39,7 @@ struct ParallelCommandQueue {
/// });
/// }
/// # bevy_ecs::system::assert_is_system(parallel_command_system);
///```
/// ```
#[derive(SystemParam)]
pub struct ParallelCommands<'w, 's> {
state: Deferred<'s, ParallelCommandQueue>,

View file

@ -4,8 +4,7 @@ use crate::{
system::{Local, SystemMeta, SystemParam, SystemState},
world::World,
};
use bevy_utils::all_tuples;
use bevy_utils::synccell::SyncCell;
use bevy_utils::{all_tuples, synccell::SyncCell};
use std::marker::PhantomData;
/// A parameter that can be used in an exclusive system (a system with an `&mut World` parameter).
@ -125,9 +124,7 @@ all_tuples!(
#[cfg(test)]
mod tests {
use crate as bevy_ecs;
use crate::schedule::Schedule;
use crate::system::Local;
use crate::world::World;
use crate::{schedule::Schedule, system::Local, world::World};
use bevy_ecs_macros::Resource;
use std::marker::PhantomData;

View file

@ -307,8 +307,6 @@ mod tests {
use bevy_utils::default;
use std::any::TypeId;
use crate::prelude::EntityRef;
use crate::world::EntityMut;
use crate::{
self as bevy_ecs,
archetype::{ArchetypeComponentId, Archetypes},
@ -316,7 +314,7 @@ mod tests {
change_detection::DetectChanges,
component::{Component, Components, Tick},
entity::{Entities, Entity},
prelude::AnyOf,
prelude::{AnyOf, EntityRef},
query::{Added, Changed, Or, With, Without},
removal_detection::RemovedComponents,
schedule::{
@ -327,7 +325,7 @@ mod tests {
Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, Res, ResMut,
Resource, StaticSystemParam, System, SystemState,
},
world::{FromWorld, World},
world::{EntityMut, FromWorld, World},
};
#[derive(Resource, PartialEq, Debug)]

View file

@ -1,16 +1,16 @@
use bevy_utils::tracing::warn;
use core::fmt::Debug;
use crate::component::Tick;
use crate::schedule::InternedSystemSet;
use crate::system::input::SystemInput;
use crate::system::SystemIn;
use crate::world::unsafe_world_cell::UnsafeWorldCell;
use crate::world::DeferredWorld;
use crate::{archetype::ArchetypeComponentId, component::ComponentId, query::Access, world::World};
use crate::{
archetype::ArchetypeComponentId,
component::{ComponentId, Tick},
query::Access,
schedule::InternedSystemSet,
system::{input::SystemInput, SystemIn},
world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, World},
};
use std::any::TypeId;
use std::borrow::Cow;
use std::{any::TypeId, borrow::Cow};
use super::IntoSystem;

View file

@ -1,9 +1,10 @@
use crate::component::Tick;
use crate::prelude::World;
use crate::system::{ExclusiveSystemParam, ReadOnlySystemParam, SystemMeta, SystemParam};
use crate::world::unsafe_world_cell::UnsafeWorldCell;
use std::borrow::Cow;
use std::ops::Deref;
use crate::{
component::Tick,
prelude::World,
system::{ExclusiveSystemParam, ReadOnlySystemParam, SystemMeta, SystemParam},
world::unsafe_world_cell::UnsafeWorldCell,
};
use std::{borrow::Cow, ops::Deref};
/// [`SystemParam`] that returns the name of the system which it is used in.
///
@ -105,8 +106,10 @@ impl ExclusiveSystemParam for SystemName<'_> {
#[cfg(test)]
mod tests {
use crate::system::{IntoSystem, RunSystemOnce, SystemName};
use crate::world::World;
use crate::{
system::{IntoSystem, RunSystemOnce, SystemName},
world::World,
};
#[test]
fn test_system_name_regular_param() {

View file

@ -1,5 +1,4 @@
pub use crate::change_detection::{NonSendMut, Res, ResMut};
use crate::storage::SparseSetIndex;
use crate::{
archetype::{Archetype, Archetypes},
bundle::Bundles,
@ -7,16 +6,15 @@ use crate::{
component::{ComponentId, ComponentTicks, Components, Tick},
entity::Entities,
query::{
Access, FilteredAccess, FilteredAccessSet, QueryData, QueryFilter, QueryState,
ReadOnlyQueryData,
Access, AccessConflicts, FilteredAccess, FilteredAccessSet, QueryData, QueryFilter,
QueryState, ReadOnlyQueryData,
},
storage::{ResourceData, SparseSetIndex},
system::{Query, SystemMeta},
world::{unsafe_world_cell::UnsafeWorldCell, DeferredWorld, FromWorld, World},
};
use crate::{query::AccessConflicts, storage::ResourceData};
use bevy_ecs_macros::impl_param_set;
pub use bevy_ecs_macros::Resource;
pub use bevy_ecs_macros::SystemParam;
pub use bevy_ecs_macros::{Resource, SystemParam};
use bevy_ptr::UnsafeCellDeref;
use bevy_utils::{all_tuples, synccell::SyncCell};
#[cfg(feature = "track_change_detection")]
@ -69,7 +67,7 @@ use std::{
/// # eventwriter:
/// EventWriter<'w, SomeEvent>
/// # }
///```
/// ```
/// ## `PhantomData`
///
/// [`PhantomData`] is a special type of `SystemParam` that does nothing.
@ -494,7 +492,7 @@ fn assert_component_access_compatibility(
/// )),)
/// .build_state(&mut world)
/// .build_system(buildable_system);
///world.run_system_once(system);
/// world.run_system_once(system);
///
/// fn buildable_system(mut set: ParamSet<(Query<&mut Health>, Query<&mut Health>, &World)>) {
/// // The first parameter is built from the first builder,
@ -1874,7 +1872,6 @@ pub mod lifetimeless {
/// # bevy_ecs::system::assert_is_system(do_thing_generically::<T>);
/// # }
/// ```
///
pub struct StaticSystemParam<'w, 's, P: SystemParam>(SystemParamItem<'w, 's, P>);
impl<'w, 's, P: SystemParam> Deref for StaticSystemParam<'w, 's, P> {
@ -1973,6 +1970,7 @@ unsafe impl<T: ?Sized> SystemParam for PhantomData<T> {
unsafe impl<T: ?Sized> ReadOnlySystemParam for PhantomData<T> {}
/// A [`SystemParam`] with a type that can be configured at runtime.
///
/// To be useful, this must be configured using a [`DynParamBuilder`](crate::system::DynParamBuilder) to build the system using a [`SystemParamBuilder`](crate::prelude::SystemParamBuilder).
///
/// # Examples

View file

@ -1,10 +1,11 @@
use crate::bundle::Bundle;
use crate::change_detection::Mut;
use crate::entity::Entity;
use crate::system::input::SystemInput;
use crate::system::{BoxedSystem, IntoSystem, System, SystemIn};
use crate::world::{Command, World};
use crate::{self as bevy_ecs};
use crate::{
bundle::Bundle,
change_detection::Mut,
entity::Entity,
system::{input::SystemInput, BoxedSystem, IntoSystem, System, SystemIn},
world::{Command, World},
{self as bevy_ecs},
};
use bevy_ecs_macros::{Component, Resource};
use thiserror::Error;

View file

@ -26,7 +26,6 @@ struct CommandMeta {
}
/// Densely and efficiently stores a queue of heterogenous types implementing [`Command`].
//
// NOTE: [`CommandQueue`] is implemented via a `Vec<MaybeUninit<u8>>` instead of a `Vec<Box<dyn Command>>`
// as an optimization. Since commands are used frequently in systems as a way to spawn
// entities/components/resources, and it's not currently possible to parallelize these

View file

@ -555,6 +555,7 @@ impl<'a> TryFrom<&'a mut FilteredEntityMut<'_>> for EntityMut<'a> {
}
/// A mutable reference to a particular [`Entity`], and the entire world.
///
/// This is essentially a performance-optimized `(Entity, &mut World)` tuple,
/// which caches the [`EntityLocation`] to reduce duplicate lookups.
///
@ -1049,7 +1050,6 @@ impl<'w> EntityWorldMut<'w> {
/// this fn as if the code here was written inline
///
/// when DROP is true removed components will be dropped otherwise they will be forgotten
///
// We use a const generic here so that we are less reliant on
// inlining for rustc to optimize out the `match DROP`
#[allow(clippy::too_many_arguments)]
@ -1488,7 +1488,6 @@ impl<'w> EntityWorldMut<'w> {
/// # let mut entity = world.get_entity_mut(entity_id).unwrap();
/// entity.entry::<Comp>().and_modify(|mut c| c.0 += 1);
/// assert_eq!(world.query::<&Comp>().single(&world).0, 5);
///
/// ```
pub fn entry<'a, T: Component>(&'a mut self) -> Entry<'w, 'a, T> {
if self.contains::<T>() {
@ -2787,9 +2786,13 @@ mod tests {
use bevy_ptr::OwningPtr;
use std::panic::AssertUnwindSafe;
use crate::system::RunSystemOnce as _;
use crate::world::{FilteredEntityMut, FilteredEntityRef};
use crate::{self as bevy_ecs, component::ComponentId, prelude::*, system::assert_is_system};
use crate::{
self as bevy_ecs,
component::ComponentId,
prelude::*,
system::{assert_is_system, RunSystemOnce as _},
world::{FilteredEntityMut, FilteredEntityRef},
};
use super::{EntityMutExcept, EntityRefExcept};

Some files were not shown because too many files have changed in this diff Show more