From d9265db3447dfe8b74b40de297a3ad7d696f4ece Mon Sep 17 00:00:00 2001 From: JoJoJet <21144246+JoJoJet@users.noreply.github.com> Date: Fri, 13 Jan 2023 22:35:43 +0000 Subject: [PATCH] Implement `ReadOnlySystemParam` for `Extract<>` (#7182) # Objective - `Extract` does not implement `ReadOnlySystemParam` even though it should. - Noticed by @hymm on discord: https://discord.com/channels/691052431525675048/749335865876021248/1063535818267963543 ## Solution Implement the trait. --- crates/bevy_render/src/extract_param.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/extract_param.rs b/crates/bevy_render/src/extract_param.rs index 4038a71aa6..584a82303f 100644 --- a/crates/bevy_render/src/extract_param.rs +++ b/crates/bevy_render/src/extract_param.rs @@ -52,8 +52,10 @@ pub struct ExtractState { main_world_state: as SystemParam>::State, } -// SAFETY: only accesses MainWorld resource with read only system params using Res, -// which is initialized in init() +// SAFETY: The only `World` access (`Res`) is read-only. +unsafe impl

ReadOnlySystemParam for Extract<'_, '_, P> where P: ReadOnlySystemParam {} + +// SAFETY: The only `World` access is properly registered by `Res::init_state`. unsafe impl

SystemParam for Extract<'_, '_, P> where P: ReadOnlySystemParam,