bevy/crates
Jakob Hellermann d38a8dfdd7 add more SAFETY comments and lint for missing ones in bevy_ecs (#4835)
# Objective

`SAFETY` comments are meant to be placed before `unsafe` blocks and should contain the reasoning of why in this case the usage of unsafe is okay. This is useful when reading the code because it makes it clear which assumptions are required for safety, and makes it easier to spot possible unsoundness holes. It also forces the code writer to think of something to write and maybe look at the safety contracts of any called unsafe methods again to double-check their correct usage.

There's a clippy lint called `undocumented_unsafe_blocks` which warns when using a block without such a comment. 

## Solution

- since clippy expects `SAFETY` instead of `SAFE`, rename those
- add `SAFETY` comments in more places
- for the last remaining 3 places, add an `#[allow()]` and `// TODO` since I wasn't comfortable enough with the code to justify their safety
- add ` #![warn(clippy::undocumented_unsafe_blocks)]` to `bevy_ecs`


### Note for reviewers

The first commit only renames `SAFETY` to `SAFE` so it doesn't need a thorough review.
cb042a416e..55cef2d6fa is the diff for all other changes.

### Safety comments where I'm not too familiar with the code

774012ece5/crates/bevy_ecs/src/entity/mod.rs (L540-L546)

774012ece5/crates/bevy_ecs/src/world/entity_ref.rs (L249-L252)

### Locations left undocumented with a `TODO` comment

5dde944a30/crates/bevy_ecs/src/schedule/executor_parallel.rs (L196-L199)

5dde944a30/crates/bevy_ecs/src/world/entity_ref.rs (L287-L289)

5dde944a30/crates/bevy_ecs/src/world/entity_ref.rs (L413-L415)

Co-authored-by: Jakob Hellermann <hellermann@sipgate.de>
2022-07-04 14:44:24 +00:00
..
bevy_animation Add helper methods for rotating Transforms (#5151) 2022-07-01 03:58:54 +00:00
bevy_app Remove the dependency cycles (#5171) 2022-07-04 13:04:18 +00:00
bevy_asset Derive default for enums where possible (#5158) 2022-07-01 03:42:15 +00:00
bevy_audio Remove the dependency cycles (#5171) 2022-07-04 13:04:18 +00:00
bevy_core Add global init and get accessors for all newtyped TaskPools (#2250) 2022-06-09 02:43:24 +00:00
bevy_core_pipeline Add reflection for resources (#5175) 2022-07-04 13:04:20 +00:00
bevy_derive android - fix issues other than the rendering (#5130) 2022-06-30 19:42:45 +00:00
bevy_diagnostic Cleanups in diagnostics (#3871) 2022-06-20 17:02:25 +00:00
bevy_dylib Bump Bevy to 0.8.0-dev (#4505) 2022-04-17 23:04:52 +00:00
bevy_dynamic_plugin Bump Bevy to 0.8.0-dev (#4505) 2022-04-17 23:04:52 +00:00
bevy_ecs add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_ecs_compile_fail_tests Fix rust 1.62 changes (#5154) 2022-06-30 19:24:28 +00:00
bevy_encase_derive Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_gilrs Update gilrs to v0.9 (#4848) 2022-05-30 17:26:23 +00:00
bevy_gltf fix new clippy lints (#5160) 2022-07-01 13:41:23 +00:00
bevy_hierarchy add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_input Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_internal enable optional dependencies to stay optional (#5023) 2022-06-20 10:32:43 +00:00
bevy_log Remove the dependency cycles (#5171) 2022-07-04 13:04:18 +00:00
bevy_macro_utils bevy_reflect_derive: Tidying up the code (#4712) 2022-05-12 19:43:23 +00:00
bevy_math Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_mikktspace Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_pbr Add reflection for resources (#5175) 2022-07-04 13:04:20 +00:00
bevy_ptr add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_reflect bevy_reflect: remove glam from a test which is active without the glam feature (#5195) 2022-07-04 14:17:46 +00:00
bevy_render Add reflection for resources (#5175) 2022-07-04 13:04:20 +00:00
bevy_scene Fix ron deprecation (#5021) 2022-06-15 19:18:53 +00:00
bevy_sprite Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_tasks Miri can set thread names now (#5108) 2022-06-26 21:28:00 +00:00
bevy_text Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_time add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_transform Updated glam to 0.21. (#5142) 2022-07-03 19:55:33 +00:00
bevy_ui add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_utils add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_window add more SAFETY comments and lint for missing ones in bevy_ecs (#4835) 2022-07-04 14:44:24 +00:00
bevy_winit Add option to center a window (#4999) 2022-07-04 13:04:14 +00:00