diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index 30d70ca17efab..04731b45cffd0 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -1130,18 +1130,12 @@ mod tests { #[test] fn remove_bundle() { let mut world = World::default(); - world - .spawn() - .insert_bundle((A(1), B(1), TableStored("1"))) - .id(); + world.spawn().insert_bundle((A(1), B(1), TableStored("1"))); let e2 = world .spawn() .insert_bundle((A(2), B(2), TableStored("2"))) .id(); - world - .spawn() - .insert_bundle((A(3), B(3), TableStored("3"))) - .id(); + world.spawn().insert_bundle((A(3), B(3), TableStored("3"))); let mut query = world.query::<(&B, &TableStored)>(); let results = query diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index 6de329856cf2a..e2a2a5a2222a0 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -372,6 +372,7 @@ impl<'w, 's, 'a> EntityCommands<'w, 's, 'a> { /// # my_system.system(); /// ``` #[inline] + #[must_use = "Omit the .id() call if you do not need to store the `Entity` identifier."] pub fn id(&self) -> Entity { self.entity } diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index a5b4c68bce010..9eec231db3cc4 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -493,8 +493,8 @@ mod tests { world.clear_trackers(); // Then, try removing a component - world.spawn().insert(W(3)).id(); - world.spawn().insert(W(4)).id(); + world.spawn().insert(W(3)); + world.spawn().insert(W(4)); world.entity_mut(entity_to_remove_w_from).remove::>(); fn validate_remove( diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index b85fa2b74f0f2..eda55333fb51f 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -26,6 +26,7 @@ impl<'w> EntityRef<'w> { } #[inline] + #[must_use = "Omit the .id() call if you do not need to store the `Entity` identifier."] pub fn id(&self) -> Entity { self.entity } @@ -113,6 +114,7 @@ impl<'w> EntityMut<'w> { } #[inline] + #[must_use = "Omit the .id() call if you do not need to store the `Entity` identifier."] pub fn id(&self) -> Entity { self.entity }