Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/bevyengine/bevy"
documentation = "https://docs.rs/bevy"
rust-version = "1.88.0"
rust-version = "1.89.0"

[workspace]
resolver = "2"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["ecs", "game", "bevy"]
categories = ["game-engines", "data-structures"]
rust-version = "1.86.0"
rust-version = "1.89.0"

[features]
default = ["std", "bevy_reflect", "async_executor", "backtrace"]
Expand Down
20 changes: 9 additions & 11 deletions crates/bevy_ecs/src/component/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,18 @@ pub fn component_clone_via_reflect(source: &SourceComponent, ctx: &mut Component
// Try to clone using ReflectFromReflect
if let Some(reflect_from_reflect) =
registry.get_type_data::<bevy_reflect::ReflectFromReflect>(type_id)
{
if let Some(mut component) =
&& let Some(mut component) =
reflect_from_reflect.from_reflect(source_component_reflect.as_partial_reflect())
{
if let Some(reflect_component) =
registry.get_type_data::<crate::reflect::ReflectComponent>(type_id)
{
if let Some(reflect_component) =
registry.get_type_data::<crate::reflect::ReflectComponent>(type_id)
{
reflect_component.map_entities(&mut *component, ctx.entity_mapper());
}
drop(registry);

ctx.write_target_component_reflect(component);
return;
reflect_component.map_entities(&mut *component, ctx.entity_mapper());
}
drop(registry);

ctx.write_target_component_reflect(component);
return;
}
// Else, try to clone using ReflectDefault
if let Some(reflect_default) =
Expand Down
10 changes: 5 additions & 5 deletions crates/bevy_ecs/src/entity/clone_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,11 +1139,11 @@ impl OptOut {
#[inline]
fn filter_deny(&mut self, id: ComponentId, world: &World) {
self.deny.insert(id);
if self.attach_required_by_components {
if let Some(required_by) = world.components().get_required_by(id) {
self.deny.extend(required_by.iter());
};
}
if self.attach_required_by_components
&& let Some(required_by) = world.components().get_required_by(id)
{
self.deny.extend(required_by.iter());
};
}
}

Expand Down
33 changes: 17 additions & 16 deletions crates/bevy_ecs/src/error/bevy_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ mod tests {

// On mac backtraces can start with Backtrace::create
let mut skip = false;
if let Some(line) = lines.peek() {
if &line[6..] == "std::backtrace::Backtrace::create" {
skip = true;
}
if let Some(line) = lines.peek()
&& &line[6..] == "std::backtrace::Backtrace::create"
{
skip = true;
}

if skip {
Expand All @@ -212,10 +212,10 @@ mod tests {
let line = lines.next().unwrap();
assert_eq!(&line[6..], expected);
let mut skip = false;
if let Some(line) = lines.peek() {
if line.starts_with(" at") {
skip = true;
}
if let Some(line) = lines.peek()
&& line.starts_with(" at")
{
skip = true;
}

if skip {
Expand All @@ -225,19 +225,20 @@ mod tests {

// on linux there is a second call_once
let mut skip = false;
if let Some(line) = lines.peek() {
if &line[6..] == "core::ops::function::FnOnce::call_once" {
skip = true;
}
if let Some(line) = lines.peek()
&& &line[6..] == "core::ops::function::FnOnce::call_once"
{
skip = true;
}

if skip {
lines.next().unwrap();
}
let mut skip = false;
if let Some(line) = lines.peek() {
if line.starts_with(" at") {
skip = true;
}
if let Some(line) = lines.peek()
&& line.starts_with(" at")
{
skip = true;
}

if skip {
Expand Down
24 changes: 12 additions & 12 deletions crates/bevy_ecs/src/observer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,18 @@ impl World {
&& observers.entity_component_observers.is_empty()
{
cache.component_observers.remove(component);
if let Some(flag) = Observers::is_archetype_cached(event_key) {
if let Some(by_component) = archetypes.by_component.get(component) {
for archetype in by_component.keys() {
let archetype = &mut archetypes.archetypes[archetype.index()];
if archetype.contains(*component) {
let no_longer_observed = archetype
.iter_components()
.all(|id| !cache.component_observers.contains_key(&id));

if no_longer_observed {
archetype.flags.set(flag, false);
}
if let Some(flag) = Observers::is_archetype_cached(event_key)
&& let Some(by_component) = archetypes.by_component.get(component)
{
for archetype in by_component.keys() {
let archetype = &mut archetypes.archetypes[archetype.index()];
if archetype.contains(*component) {
let no_longer_observed = archetype
.iter_components()
.all(|id| !cache.component_observers.contains_key(&id));

if no_longer_observed {
archetype.flags.set(flag, false);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3208,10 +3208,10 @@ mod tests {

fn system(query: Query<EntityRef>) {
for entity_ref in &query {
if let Some(c) = entity_ref.get_ref::<C>() {
if !c.is_added() {
panic!("Expected C to be added");
}
if let Some(c) = entity_ref.get_ref::<C>()
&& !c.is_added()
{
panic!("Expected C to be added");
}
}
}
Expand Down
41 changes: 20 additions & 21 deletions crates/bevy_ecs/src/relationship/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,27 @@ pub trait Relationship: Component + Sized {
}
}
let target_entity = world.entity(entity).get::<Self>().unwrap().get();
if let Ok(mut target_entity_mut) = world.get_entity_mut(target_entity) {
if let Some(mut relationship_target) =
if let Ok(mut target_entity_mut) = world.get_entity_mut(target_entity)
&& let Some(mut relationship_target) =
target_entity_mut.get_mut::<Self::RelationshipTarget>()
{
relationship_target.collection_mut_risky().remove(entity);
if relationship_target.len() == 0 {
let command = |mut entity: EntityWorldMut| {
// this "remove" operation must check emptiness because in the event that an identical
// relationship is inserted on top, this despawn would result in the removal of that identical
// relationship ... not what we want!
if entity
.get::<Self::RelationshipTarget>()
.is_some_and(RelationshipTarget::is_empty)
{
entity.remove::<Self::RelationshipTarget>();
}
};

world
.commands()
.queue_silenced(command.with_entity(target_entity));
}
{
relationship_target.collection_mut_risky().remove(entity);
if relationship_target.len() == 0 {
let command = |mut entity: EntityWorldMut| {
// this "remove" operation must check emptiness because in the event that an identical
// relationship is inserted on top, this despawn would result in the removal of that identical
// relationship ... not what we want!
if entity
.get::<Self::RelationshipTarget>()
.is_some_and(RelationshipTarget::is_empty)
{
entity.remove::<Self::RelationshipTarget>();
}
};

world
.commands()
.queue_silenced(command.with_entity(target_entity));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/system/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ where
// Note that the `downcast_mut` check is based on the static type,
// and can be optimized out after monomorphization.
let any: &mut dyn Any = &mut value;
if let Some(err) = any.downcast_mut::<SystemParamValidationError>() {
if err.skipped {
return Self::Skipped(core::mem::replace(err, SystemParamValidationError::EMPTY));
}
if let Some(err) = any.downcast_mut::<SystemParamValidationError>()
&& err.skipped
{
return Self::Skipped(core::mem::replace(err, SystemParamValidationError::EMPTY));
}
Self::Failed(From::from(value))
}
Expand Down