bevy/crates/bevy_ecs/src
Chris Russell 6df711ce7f
Fix unsound lifetimes in Query::join and Query::join_filtered (#17972)
# Objective

Fix unsound lifetimes in `Query::join` and `Query::join_filtered`.  

The joined query allowed access from either input query, but it only
took the `'world` lifetime from `self`, not from `other`. This meant
that after the borrow of `other` ended, the joined query would unsoundly
alias `other`.

## Solution

Change the lifetimes on `join` and `join_filtered` to require mutable
borrows of the *same* lifetime for the input queries. This ensures both
input queries are borrowed for the full lifetime of the joined query.

Change `join_inner` to take `other` by value instead of reference so
that the returned query is still usable without needing to borrow from a
local variable.

## Testing

Added a compile-fail test.
2025-03-10 21:30:34 +00:00
..
entity Add no_std support to bevy (#17955) 2025-03-07 03:39:46 +00:00
error Backtrace: std and threadsafe bevy_error_panic_hook (#18235) 2025-03-10 21:16:14 +00:00
event Improve derive(Event) and simplify macro code (#18083) 2025-03-07 02:01:23 +00:00
identifier Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
observer Improve derive(Event) and simplify macro code (#18083) 2025-03-07 02:01:23 +00:00
query Remove lifetime from QueryEntityError (#18157) 2025-03-09 20:05:22 +00:00
reflect Preserve spawned RelationshipTarget order and other improvements (#17858) 2025-03-05 22:18:57 +00:00
relationship Update Component docs to point to Relationship trait (#18179) 2025-03-07 23:32:43 +00:00
schedule BevyError: Bevy's new catch-all error type (#18144) 2025-03-07 01:50:07 +00:00
storage Handle TriggerTargets that are combinations for components/entities (#18024) 2025-02-24 23:57:34 +00:00
system Fix unsound lifetimes in Query::join and Query::join_filtered (#17972) 2025-03-10 21:30:34 +00:00
world Deprecate insert_or_spawn function family (#18147) 2025-03-06 17:04:16 +00:00
archetype.rs Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
batching.rs Fix *most* clippy lints (#15906) 2024-10-14 20:52:35 +00:00
bundle.rs Preserve spawned RelationshipTarget order and other improvements (#17858) 2025-03-05 22:18:57 +00:00
change_detection.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
component.rs Update Component docs to point to Relationship trait (#18179) 2025-03-07 23:32:43 +00:00
entity_disabling.rs Allow users to register their own disabling components / default query filters (#17768) 2025-02-11 18:25:32 +00:00
hierarchy.rs Update ChildOf deprecation advice to match new layout (#18089) 2025-02-28 23:15:23 +00:00
intern.rs Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
label.rs do_not_recommend interned Labels (#17950) 2025-02-25 23:46:21 +00:00
lib.rs BevyError: Bevy's new catch-all error type (#18144) 2025-03-07 01:50:07 +00:00
name.rs Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
removal_detection.rs Harden proc macro path resolution and add integration tests. (#17330) 2025-02-09 19:45:45 +00:00
resource.rs Move Resource trait to its own file (#17469) 2025-01-21 19:47:08 +00:00
spawn.rs Improved Spawn APIs and Bundle Effects (#17521) 2025-02-09 23:32:56 +00:00
traversal.rs Relationships (non-fragmenting, one-to-many) (#17398) 2025-01-18 22:20:30 +00:00