bevy/crates
Sludge 41db723c5c
Fix soundness of UnsafeWorldCell usage example (#10941)
# Objective

- The example in the docs is unsound.

Demo:

```rust
#[derive(Resource)]
struct MyRes(u32);

fn main() {
    let mut w = World::new();
    w.insert_resource(MyRes(0));

    let (mut res, comp) = split_world_access(&mut w);
    let mut r1 = res.get_resource_mut::<MyRes>().unwrap();
    let mut r2 = res.get_resource_mut::<MyRes>().unwrap();

    *r1 = MyRes(1);
    *r2 = MyRes(2);
}
```

The API in the example allows aliasing mutable references to the same
resource. Miri also complains when running this.

## Solution

- Change the example API to make the returned `Mut` borrow from the
`OnlyResourceAccessWorld` instead of borrowing from the world via `'w`.
This prevents obtaining more than one `Mut` at the same time from it.
2023-12-13 00:55:30 +00:00
..
bevy_a11y Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_animation Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_app Remove reference to default schedule (#10918) 2023-12-09 14:21:43 +00:00
bevy_asset Refactor process_handle_drop_internal() in bevy_asset (#10920) 2023-12-12 19:46:37 +00:00
bevy_audio Non-Intrusive refactor of play_queued_audio_system() (#10910) 2023-12-09 14:27:39 +00:00
bevy_core Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_core_pipeline Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_diagnostic Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_dylib Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_dynamic_plugin Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_ecs Fix soundness of UnsafeWorldCell usage example (#10941) 2023-12-13 00:55:30 +00:00
bevy_ecs_compile_fail_tests Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_encase_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gilrs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_gizmos Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_gltf Add GltfLoaderSettings (#10804) 2023-11-30 00:34:45 +00:00
bevy_hierarchy Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_input Rename Input to ButtonInput (#10859) 2023-12-06 20:32:34 +00:00
bevy_internal Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_log Add helper macro's for logging only once (#10808) 2023-12-05 01:56:40 +00:00
bevy_macro_utils Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_macros_compile_fail_tests Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_math Split Ray into Ray2d and Ray3d and simplify plane construction (#10856) 2023-12-06 14:09:04 +00:00
bevy_mikktspace Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_pbr Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_ptr Enable clippy::undocumented_unsafe_blocks warning across the workspace (#10646) 2023-11-21 02:06:24 +00:00
bevy_reflect Fix debug printing for dynamic types (#10740) 2023-12-12 19:44:43 +00:00
bevy_reflect_compile_fail_tests Fix nested generics in Reflect derive (#10791) 2023-11-29 01:46:09 +00:00
bevy_render Explain how RegularPolygon mesh is generated (#10927) 2023-12-12 21:40:33 +00:00
bevy_scene Mention DynamicSceneBuilder in doc comment (#10780) 2023-11-28 23:45:00 +00:00
bevy_sprite Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_tasks Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_text Rename TextAlignment to JustifyText. (#10854) 2023-12-05 03:00:41 +00:00
bevy_time Wait until FixedUpdate can see events before dropping them (#10077) 2023-11-26 23:04:41 +00:00
bevy_transform Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_ui Rename WorldQueryData & WorldQueryFilter to QueryData & QueryFilter (#10779) 2023-12-12 19:45:50 +00:00
bevy_utils Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_window Rename Input to ButtonInput (#10859) 2023-12-06 20:32:34 +00:00
bevy_winit Refactor function update_accessibility_nodes (#10911) 2023-12-10 00:52:16 +00:00