From 1fe559730ce05184c926160f044ad53c77b28c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Sun, 29 Jun 2025 19:12:33 +0200 Subject: [PATCH] bevy_ecs: remove use of needless_return (#19859) # Objective - bevy_ecs has a expected lint that is both needed and unneeded ## Solution - Change the logic so that it's always not needed ## Testing `cargo clippy -p bevy_ecs --no-default-features --no-deps -- -D warnings` --- crates/bevy_ecs/src/storage/resource.rs | 39 ++++++++++--------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/crates/bevy_ecs/src/storage/resource.rs b/crates/bevy_ecs/src/storage/resource.rs index 29752ae2e5..1a90cc511c 100644 --- a/crates/bevy_ecs/src/storage/resource.rs +++ b/crates/bevy_ecs/src/storage/resource.rs @@ -64,32 +64,23 @@ impl ResourceData { /// If `SEND` is false, this will panic if called from a different thread than the one it was inserted from. #[inline] fn validate_access(&self) { - if SEND { - #[cfg_attr( - not(feature = "std"), - expect( - clippy::needless_return, - reason = "needless until no_std is addressed (see below)", - ) - )] - return; - } + if !SEND { + #[cfg(feature = "std")] + if self.origin_thread_id != Some(std::thread::current().id()) { + // Panic in tests, as testing for aborting is nearly impossible + panic!( + "Attempted to access or drop non-send resource {} from thread {:?} on a thread {:?}. This is not allowed. Aborting.", + self.type_name, + self.origin_thread_id, + std::thread::current().id() + ); + } - #[cfg(feature = "std")] - if self.origin_thread_id != Some(std::thread::current().id()) { - // Panic in tests, as testing for aborting is nearly impossible - panic!( - "Attempted to access or drop non-send resource {} from thread {:?} on a thread {:?}. This is not allowed. Aborting.", - self.type_name, - self.origin_thread_id, - std::thread::current().id() - ); + // TODO: Handle no_std non-send. + // Currently, no_std is single-threaded only, so this is safe to ignore. + // To support no_std multithreading, an alternative will be required. + // Remove the #[expect] attribute above when this is addressed. } - - // TODO: Handle no_std non-send. - // Currently, no_std is single-threaded only, so this is safe to ignore. - // To support no_std multithreading, an alternative will be required. - // Remove the #[expect] attribute above when this is addressed. } /// Returns true if the resource is populated.