bevy/crates/bevy_ecs/compile_fail/tests/ui
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
..
component_hook_call_signature_mismatch.rs allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
component_hook_call_signature_mismatch.stderr allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
component_hook_relationship.rs allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
component_hook_relationship.stderr allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
component_hook_struct_path.rs allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
component_hook_struct_path.stderr allow Call and Closure expressions in hook macro attributes (#18017) 2025-03-06 16:39:11 +00:00
entity_ref_mut_lifetime_safety.rs
entity_ref_mut_lifetime_safety.stderr
query_exact_sized_iterator_safety.rs
query_exact_sized_iterator_safety.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00
query_iter_combinations_mut_iterator_safety.rs
query_iter_combinations_mut_iterator_safety.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00
query_iter_many_mut_iterator_safety.rs
query_iter_many_mut_iterator_safety.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00
query_lens_lifetime_safety.rs Fix unsound lifetimes in Query::join and Query::join_filtered (#17972) 2025-03-10 21:30:34 +00:00
query_lens_lifetime_safety.stderr Fix unsound lifetimes in Query::join and Query::join_filtered (#17972) 2025-03-10 21:30:34 +00:00
query_lifetime_safety.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
query_lifetime_safety.stderr Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
query_to_readonly.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
query_to_readonly.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00
query_transmute_safety.rs Make Query::single (and friends) return a Result (#18082) 2025-03-02 19:51:56 +00:00
query_transmute_safety.stderr
system_param_derive_readonly.rs
system_param_derive_readonly.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00
system_query_get_lifetime_safety.rs
system_query_get_lifetime_safety.stderr
system_query_get_many_lifetime_safety.rs
system_query_get_many_lifetime_safety.stderr
system_query_get_many_mut_lifetime_safety.rs
system_query_get_many_mut_lifetime_safety.stderr
system_query_iter_lifetime_safety.rs
system_query_iter_lifetime_safety.stderr
system_query_iter_many_mut_lifetime_safety.rs
system_query_iter_many_mut_lifetime_safety.stderr
system_query_iter_sort_lifetime_safety.rs Fix unsoundness in QueryIter::sort_by (#17826) 2025-02-26 20:36:37 +00:00
system_query_iter_sort_lifetime_safety.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00
system_query_set_get_lifetime_safety.rs
system_query_set_get_lifetime_safety.stderr
system_query_set_iter_lifetime_safety.rs
system_query_set_iter_lifetime_safety.stderr
system_state_get_lifetime_safety.rs
system_state_get_lifetime_safety.stderr
system_state_iter_lifetime_safety.rs
system_state_iter_lifetime_safety.stderr
system_state_iter_mut_overlap_safety.rs
system_state_iter_mut_overlap_safety.stderr
world_query_derive.rs bevy_ecs: Replace panics in QueryData derive compile errors (#15691) 2024-10-07 16:30:34 +00:00
world_query_derive.stderr chore: update compile fail test stderr files (#18056) 2025-03-01 00:31:55 +00:00