From c87eeed6d8763863feaf152a86e9adb1dd9d9e40 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 22:21:18 +1100 Subject: [PATCH 1/8] Address lints in `bevy_platform_support` (#18477) # Objective @mockersf noticed there were some failing lints in `bevy_platform_support`. ## Solution Addressed the lints! ## Testing - CI --- .../bevy_platform_support/src/sync/barrier.rs | 6 +-- .../src/sync/lazy_lock.rs | 6 +-- .../bevy_platform_support/src/sync/mutex.rs | 8 +-- crates/bevy_platform_support/src/sync/once.rs | 7 +-- .../bevy_platform_support/src/sync/poison.rs | 6 +-- .../bevy_platform_support/src/sync/rwlock.rs | 8 +-- .../src/time/fallback.rs | 49 ++++++++++--------- 7 files changed, 46 insertions(+), 44 deletions(-) diff --git a/crates/bevy_platform_support/src/sync/barrier.rs b/crates/bevy_platform_support/src/sync/barrier.rs index 6c179d81d6..2968a78b01 100644 --- a/crates/bevy_platform_support/src/sync/barrier.rs +++ b/crates/bevy_platform_support/src/sync/barrier.rs @@ -1,12 +1,12 @@ //! Provides `Barrier` and `BarrierWaitResult` -pub use barrier::{Barrier, BarrierWaitResult}; +pub use implementation::{Barrier, BarrierWaitResult}; #[cfg(feature = "std")] -use std::sync as barrier; +use std::sync as implementation; #[cfg(not(feature = "std"))] -mod barrier { +mod implementation { use core::fmt; /// Fallback implementation of `Barrier` from the standard library. diff --git a/crates/bevy_platform_support/src/sync/lazy_lock.rs b/crates/bevy_platform_support/src/sync/lazy_lock.rs index 8a13c1bef2..c756daeb94 100644 --- a/crates/bevy_platform_support/src/sync/lazy_lock.rs +++ b/crates/bevy_platform_support/src/sync/lazy_lock.rs @@ -1,11 +1,11 @@ //! Provides `LazyLock` -pub use lazy_lock::LazyLock; +pub use implementation::LazyLock; #[cfg(feature = "std")] -use std::sync as lazy_lock; +use std::sync as implementation; #[cfg(not(feature = "std"))] -mod lazy_lock { +mod implementation { pub use spin::Lazy as LazyLock; } diff --git a/crates/bevy_platform_support/src/sync/mutex.rs b/crates/bevy_platform_support/src/sync/mutex.rs index a059d670e9..7ff363f574 100644 --- a/crates/bevy_platform_support/src/sync/mutex.rs +++ b/crates/bevy_platform_support/src/sync/mutex.rs @@ -1,12 +1,12 @@ //! Provides `Mutex` and `MutexGuard` -pub use mutex::{Mutex, MutexGuard}; +pub use implementation::{Mutex, MutexGuard}; #[cfg(feature = "std")] -use std::sync as mutex; +use std::sync as implementation; #[cfg(not(feature = "std"))] -mod mutex { +mod implementation { use crate::sync::{LockResult, TryLockError, TryLockResult}; use core::fmt; @@ -81,7 +81,7 @@ mod mutex { } } - impl Default for Mutex { + impl Default for Mutex { fn default() -> Mutex { Mutex::new(Default::default()) } diff --git a/crates/bevy_platform_support/src/sync/once.rs b/crates/bevy_platform_support/src/sync/once.rs index 2ae733f387..f4ac34b905 100644 --- a/crates/bevy_platform_support/src/sync/once.rs +++ b/crates/bevy_platform_support/src/sync/once.rs @@ -1,12 +1,12 @@ //! Provides `Once`, `OnceState`, `OnceLock` -pub use once::{Once, OnceLock, OnceState}; +pub use implementation::{Once, OnceLock, OnceState}; #[cfg(feature = "std")] -use std::sync as once; +use std::sync as implementation; #[cfg(not(feature = "std"))] -mod once { +mod implementation { use core::{ fmt, panic::{RefUnwindSafe, UnwindSafe}, @@ -145,6 +145,7 @@ mod once { /// Creates a new `Once` value. /// /// See the standard library for further details. + #[expect(clippy::new_without_default, reason = "matching std::sync::Once")] pub const fn new() -> Self { Self { inner: OnceLock::new(), diff --git a/crates/bevy_platform_support/src/sync/poison.rs b/crates/bevy_platform_support/src/sync/poison.rs index 0aa8e168c2..79eafc4250 100644 --- a/crates/bevy_platform_support/src/sync/poison.rs +++ b/crates/bevy_platform_support/src/sync/poison.rs @@ -1,12 +1,12 @@ //! Provides `LockResult`, `PoisonError`, `TryLockError`, `TryLockResult` -pub use poison::{LockResult, PoisonError, TryLockError, TryLockResult}; +pub use implementation::{LockResult, PoisonError, TryLockError, TryLockResult}; #[cfg(feature = "std")] -use std::sync as poison; +use std::sync as implementation; #[cfg(not(feature = "std"))] -mod poison { +mod implementation { use core::{error::Error, fmt}; /// Fallback implementation of `PoisonError` from the standard library. diff --git a/crates/bevy_platform_support/src/sync/rwlock.rs b/crates/bevy_platform_support/src/sync/rwlock.rs index 627da73f32..f1f529baaf 100644 --- a/crates/bevy_platform_support/src/sync/rwlock.rs +++ b/crates/bevy_platform_support/src/sync/rwlock.rs @@ -1,12 +1,12 @@ -//! TODO: Implement `RwLock`, `RwLockReadGuard`, `RwLockWriteGuard` +//! Provides `RwLock`, `RwLockReadGuard`, `RwLockWriteGuard` -pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +pub use implementation::{RwLock, RwLockReadGuard, RwLockWriteGuard}; #[cfg(feature = "std")] -use std::sync as rwlock; +use std::sync as implementation; #[cfg(not(feature = "std"))] -mod rwlock { +mod implementation { use crate::sync::{LockResult, TryLockError, TryLockResult}; use core::fmt; diff --git a/crates/bevy_platform_support/src/time/fallback.rs b/crates/bevy_platform_support/src/time/fallback.rs index a0a9354902..344fe74baf 100644 --- a/crates/bevy_platform_support/src/time/fallback.rs +++ b/crates/bevy_platform_support/src/time/fallback.rs @@ -36,7 +36,7 @@ impl Instant { let getter = ELAPSED_GETTER.load(Ordering::Acquire); // SAFETY: Function pointer is always valid - let getter = unsafe { core::mem::transmute::<_, fn() -> Duration>(getter) }; + let getter = unsafe { core::mem::transmute::<*mut (), fn() -> Duration>(getter) }; Self((getter)()) } @@ -149,28 +149,29 @@ impl fmt::Debug for Instant { } fn unset_getter() -> Duration { - let _nanos: u64; - - #[cfg(target_arch = "x86")] - unsafe { - _nanos = core::arch::x86::_rdtsc(); + cfg_if::cfg_if! { + if #[cfg(target_arch = "x86")] { + // SAFETY: standard technique for getting a nanosecond counter on x86 + let nanos = unsafe { + core::arch::x86::_rdtsc() + }; + Duration::from_nanos(nanos) + } else if #[cfg(target_arch = "x86_64")] { + // SAFETY: standard technique for getting a nanosecond counter on x86_64 + let nanos = unsafe { + core::arch::x86_64::_rdtsc() + }; + Duration::from_nanos(nanos) + } else if #[cfg(target_arch = "aarch64")] { + // SAFETY: standard technique for getting a nanosecond counter of aarch64 + let nanos = unsafe { + let mut ticks: u64; + core::arch::asm!("mrs {}, cntvct_el0", out(reg) ticks); + ticks + }; + Duration::from_nanos(nanos) + } else { + panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`") + } } - - #[cfg(target_arch = "x86_64")] - unsafe { - _nanos = core::arch::x86_64::_rdtsc(); - } - - #[cfg(target_arch = "aarch64")] - unsafe { - let mut ticks: u64; - core::arch::asm!("mrs {}, cntvct_el0", out(reg) ticks); - _nanos = ticks; - } - - #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] - panic!("An elapsed time getter has not been provided to `Instant`. Please use `Instant::set_elapsed(...)` before calling `Instant::now()`"); - - #[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))] - return Duration::from_nanos(_nanos); } From 4127ac1662b248b4af561d7f0083e4a7f1a5ee64 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 22:26:36 +1100 Subject: [PATCH 2/8] Properly gate functionality on `http` in `bevy_remote` (#18478) # Objective Noticed that `bevy_remote` fails to compile without default features. ## Solution Adjusted offending method to avoid reliance on `http` module when it is disabled. ## Testing - CI - `cargo clippy -p bevy_remote --no-default-features` --- crates/bevy_remote/src/builtin_methods.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index 60c96dcb8a..1638c4a47f 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -19,19 +19,18 @@ use bevy_reflect::{ serde::{ReflectSerializer, TypedReflectDeserializer}, GetPath, PartialReflect, TypeRegistration, TypeRegistry, }; -use bevy_utils::default; use serde::{de::DeserializeSeed as _, Deserialize, Serialize}; use serde_json::{Map, Value}; use crate::{ error_codes, - schemas::{ - json_schema::JsonSchemaBevyType, - open_rpc::{OpenRpcDocument, ServerObject}, - }, + schemas::{json_schema::JsonSchemaBevyType, open_rpc::OpenRpcDocument}, BrpError, BrpResult, }; +#[cfg(feature = "http")] +use {crate::schemas::open_rpc::ServerObject, bevy_utils::default}; + /// The method path for a `bevy/get` request. pub const BRP_GET_METHOD: &str = "bevy/get"; @@ -821,6 +820,8 @@ pub fn process_remote_list_methods_request( world: &mut World, ) -> BrpResult { let remote_methods = world.resource::(); + + #[cfg(feature = "http")] let servers = match ( world.get_resource::(), world.get_resource::(), @@ -837,6 +838,10 @@ pub fn process_remote_list_methods_request( }]), _ => None, }; + + #[cfg(not(feature = "http"))] + let servers = None; + let doc = OpenRpcDocument { info: Default::default(), methods: remote_methods.into(), From 72b4ed05c74bd04db266791c5b3e442de89377c3 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 22:44:49 +1100 Subject: [PATCH 3/8] Address `clippy::let_and_return` in `bevy_utils` (#18480) # Objective `clippy::let_and_return` fails on Windows. ## Solution Fixed it! ## Testing - CI --- crates/bevy_utils/src/parallel_queue.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bevy_utils/src/parallel_queue.rs b/crates/bevy_utils/src/parallel_queue.rs index f9c4c66ca0..861d17bcf2 100644 --- a/crates/bevy_utils/src/parallel_queue.rs +++ b/crates/bevy_utils/src/parallel_queue.rs @@ -29,8 +29,7 @@ impl Parallel { /// If there is no thread-local value, it will be initialized to its default. pub fn scope(&self, f: impl FnOnce(&mut T) -> R) -> R { let mut cell = self.locals.get_or_default().borrow_mut(); - let ret = f(cell.deref_mut()); - ret + f(cell.deref_mut()) } /// Mutably borrows the thread-local value. From 2eb836abaf3a20489af58a126127233bda444d06 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 22:48:40 +1100 Subject: [PATCH 4/8] Fix `clippy::let_and_return` in `bevy_ecs` (#18481) # Objective - `clippy::let_and_return` fails in `bevy_ecs` ## Solution - Fixed it! ## Testing - CI --- crates/bevy_ecs/src/archetype.rs | 5 ++--- crates/bevy_ecs/src/bundle.rs | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/bevy_ecs/src/archetype.rs b/crates/bevy_ecs/src/archetype.rs index e6ae5e4ae3..f55acf6d35 100644 --- a/crates/bevy_ecs/src/archetype.rs +++ b/crates/bevy_ecs/src/archetype.rs @@ -942,7 +942,7 @@ impl Archetypes { let archetypes = &mut self.archetypes; let archetype_component_count = &mut self.archetype_component_count; let component_index = &mut self.by_component; - let archetype_id = *self + *self .by_components .entry(archetype_identity) .or_insert_with_key(move |identity| { @@ -975,8 +975,7 @@ impl Archetypes { .zip(sparse_set_archetype_components), )); id - }); - archetype_id + }) } /// Returns the number of components that are stored in archetypes. diff --git a/crates/bevy_ecs/src/bundle.rs b/crates/bevy_ecs/src/bundle.rs index 5946819032..d87ef517f1 100644 --- a/crates/bevy_ecs/src/bundle.rs +++ b/crates/bevy_ecs/src/bundle.rs @@ -1585,7 +1585,7 @@ impl Bundles { storages: &mut Storages, ) -> BundleId { let bundle_infos = &mut self.bundle_infos; - let id = *self.bundle_ids.entry(TypeId::of::()).or_insert_with(|| { + *self.bundle_ids.entry(TypeId::of::()).or_insert_with(|| { let mut component_ids= Vec::new(); T::component_ids(components, &mut |id| component_ids.push(id)); let id = BundleId(bundle_infos.len()); @@ -1597,8 +1597,7 @@ impl Bundles { unsafe { BundleInfo::new(core::any::type_name::(), storages, components, component_ids, id) }; bundle_infos.push(bundle_info); id - }); - id + }) } /// Registers a new [`BundleInfo`], which contains both explicit and required components for a statically known type. From e3968e2963ed27f54737a4720642d360e513e7a4 Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 23:22:20 +1100 Subject: [PATCH 5/8] Properly gate imports in `bevy_scene` (#18482) # Objective - Some imports are only used with certain features. ## Solution - Gate them! ## Testing - CI --- crates/bevy_scene/src/dynamic_scene.rs | 13 ++++++++----- crates/bevy_scene/src/lib.rs | 5 +++-- crates/bevy_scene/src/scene_loader.rs | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/crates/bevy_scene/src/dynamic_scene.rs b/crates/bevy_scene/src/dynamic_scene.rs index 19d5045fab..02f621ad14 100644 --- a/crates/bevy_scene/src/dynamic_scene.rs +++ b/crates/bevy_scene/src/dynamic_scene.rs @@ -1,4 +1,4 @@ -use crate::{ron, DynamicSceneBuilder, Scene, SceneSpawnError}; +use crate::{DynamicSceneBuilder, Scene, SceneSpawnError}; use bevy_asset::Asset; use bevy_ecs::reflect::{ReflectMapEntities, ReflectResource}; use bevy_ecs::{ @@ -6,15 +6,18 @@ use bevy_ecs::{ reflect::{AppTypeRegistry, ReflectComponent}, world::World, }; -use bevy_reflect::{PartialReflect, TypePath, TypeRegistry}; +use bevy_reflect::{PartialReflect, TypePath}; use crate::reflect_utils::clone_reflect_value; -#[cfg(feature = "serialize")] -use crate::serde::SceneSerializer; use bevy_ecs::component::ComponentCloneBehavior; use bevy_ecs::relationship::RelationshipHookMode; + #[cfg(feature = "serialize")] -use serde::Serialize; +use { + crate::{ron, serde::SceneSerializer}, + bevy_reflect::TypeRegistry, + serde::Serialize, +}; /// A collection of serializable resources and dynamic entities. /// diff --git a/crates/bevy_scene/src/lib.rs b/crates/bevy_scene/src/lib.rs index 7a9526c0f4..a507a58aaf 100644 --- a/crates/bevy_scene/src/lib.rs +++ b/crates/bevy_scene/src/lib.rs @@ -27,7 +27,6 @@ pub mod serde; /// Rusty Object Notation, a crate used to serialize and deserialize bevy scenes. pub use bevy_asset::ron; -use bevy_ecs::schedule::IntoScheduleConfigs; pub use components::*; pub use dynamic_scene::*; pub use dynamic_scene_builder::*; @@ -48,7 +47,9 @@ pub mod prelude { } use bevy_app::prelude::*; -use bevy_asset::AssetApp; + +#[cfg(feature = "serialize")] +use {bevy_asset::AssetApp, bevy_ecs::schedule::IntoScheduleConfigs}; /// Plugin that provides scene functionality to an [`App`]. #[derive(Default)] diff --git a/crates/bevy_scene/src/scene_loader.rs b/crates/bevy_scene/src/scene_loader.rs index 481b7ebc04..d74dff84f5 100644 --- a/crates/bevy_scene/src/scene_loader.rs +++ b/crates/bevy_scene/src/scene_loader.rs @@ -1,21 +1,27 @@ -#[cfg(feature = "serialize")] -use crate::serde::SceneDeserializer; -use crate::{ron, DynamicScene}; -use bevy_asset::{io::Reader, AssetLoader, LoadContext}; +use crate::ron; use bevy_ecs::{ reflect::AppTypeRegistry, world::{FromWorld, World}, }; use bevy_reflect::TypeRegistryArc; -#[cfg(feature = "serialize")] -use serde::de::DeserializeSeed; use thiserror::Error; +#[cfg(feature = "serialize")] +use { + crate::{serde::SceneDeserializer, DynamicScene}, + bevy_asset::{io::Reader, AssetLoader, LoadContext}, + serde::de::DeserializeSeed, +}; + /// Asset loader for a Bevy dynamic scene (`.scn` / `.scn.ron`). /// /// The loader handles assets serialized with [`DynamicScene::serialize`]. #[derive(Debug)] pub struct SceneLoader { + #[cfg_attr( + not(feature = "serialize"), + expect(dead_code, reason = "only used with `serialize` feature") + )] type_registry: TypeRegistryArc, } From a8568f753519a62b7f1a59ac7b9dd6fbc70938da Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 23:27:14 +1100 Subject: [PATCH 6/8] Ensure `dds` enables `bevy_core_pipeline/dds` in `bevy_anti_aliasing` (#18484) # Objective - Compile failure with `bevy_anti_aliasing` due to `dds` feature not enabling `bevy_core_pipeline/dds`, causing a public API desync. ## Solution - Ensured feature is enabled ## Testing - CI --- crates/bevy_anti_aliasing/Cargo.toml | 2 +- crates/bevy_image/src/image.rs | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/bevy_anti_aliasing/Cargo.toml b/crates/bevy_anti_aliasing/Cargo.toml index 0f164ae725..821d01b3a5 100644 --- a/crates/bevy_anti_aliasing/Cargo.toml +++ b/crates/bevy_anti_aliasing/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["bevy"] trace = [] webgl = [] webgpu = [] -dds = ["bevy_render/dds", "bevy_image/dds"] +dds = ["bevy_render/dds", "bevy_image/dds", "bevy_core_pipeline/dds"] smaa_luts = ["bevy_render/ktx2", "bevy_image/ktx2", "bevy_image/zstd"] [dependencies] diff --git a/crates/bevy_image/src/image.rs b/crates/bevy_image/src/image.rs index da2609028f..9d1c9b166a 100644 --- a/crates/bevy_image/src/image.rs +++ b/crates/bevy_image/src/image.rs @@ -931,13 +931,9 @@ impl Image { #[cfg(all(debug_assertions, feature = "dds"))] name: String, buffer: &[u8], image_type: ImageType, - #[expect( - clippy::allow_attributes, - reason = "`unused_variables` may not always lint" - )] - #[allow( - unused_variables, - reason = "`supported_compressed_formats` is needed where the image format is `Basis`, `Dds`, or `Ktx2`; if these are disabled, then `supported_compressed_formats` is unused." + #[cfg_attr( + not(any(feature = "basis-universal", feature = "dds", feature = "ktx2")), + expect(unused_variables, reason = "only used with certain features") )] supported_compressed_formats: CompressedImageFormats, is_srgb: bool, From 5ba86654a05fb1c59b22ac34bc3fdde474367e2f Mon Sep 17 00:00:00 2001 From: Zachary Harrold Date: Sat, 22 Mar 2025 23:37:42 +1100 Subject: [PATCH 7/8] Remove `bevy_input_focus` from `bevy_a11y` (#18483) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective - Compiling `bevy_a11y` without default features fails because you need to select a floating point backed. But you actually don't need it, this requirement is from an unused linkage to `bevy_input_focus` ## Solution - Remove link ## Testing - CI --------- Co-authored-by: François Mockers --- crates/bevy_a11y/Cargo.toml | 20 ++------------------ crates/bevy_internal/Cargo.toml | 1 - 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/crates/bevy_a11y/Cargo.toml b/crates/bevy_a11y/Cargo.toml index 3a6ece0652..9a7c4125a2 100644 --- a/crates/bevy_a11y/Cargo.toml +++ b/crates/bevy_a11y/Cargo.toml @@ -18,28 +18,17 @@ bevy_reflect = [ "dep:bevy_reflect", "bevy_app/bevy_reflect", "bevy_ecs/bevy_reflect", - "bevy_input_focus/bevy_reflect", ] ## Adds serialization support through `serde`. -serialize = [ - "dep:serde", - "bevy_ecs/serialize", - "bevy_input_focus/serialize", - "accesskit/serde", -] +serialize = ["dep:serde", "bevy_ecs/serialize", "accesskit/serde"] # Platform Compatibility ## Allows access to the `std` crate. Enabling this feature will prevent compilation ## on `no_std` targets, but provides access to certain additional features on ## supported platforms. -std = [ - "bevy_app/std", - "bevy_ecs/std", - "bevy_reflect/std", - "bevy_input_focus/std", -] +std = ["bevy_app/std", "bevy_ecs/std", "bevy_reflect/std"] ## `critical-section` provides the building blocks for synchronization primitives ## on all platforms, including `no_std`. @@ -47,19 +36,14 @@ critical-section = [ "bevy_app/critical-section", "bevy_ecs/critical-section", "bevy_reflect?/critical-section", - "bevy_input_focus/critical-section", ] -## Uses the `libm` maths library instead of the one provided in `std` and `core`. -libm = ["bevy_input_focus/libm"] - [dependencies] # bevy bevy_app = { path = "../bevy_app", version = "0.16.0-dev", default-features = false } bevy_derive = { path = "../bevy_derive", version = "0.16.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev", default-features = false } bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", default-features = false, optional = true } -bevy_input_focus = { path = "../bevy_input_focus", version = "0.16.0-dev", default-features = false } # other accesskit = { version = "0.17", default-features = false } diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index c4afedcf3f..8a466df199 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -329,7 +329,6 @@ critical-section = [ # Uses the `libm` maths library instead of the one provided in `std` and `core`. libm = [ - "bevy_a11y?/libm", "bevy_color?/libm", "bevy_input/libm", "bevy_input_focus?/libm", From d02a206940453cb96a4424baab93c0f13fef8b48 Mon Sep 17 00:00:00 2001 From: Viktor Gustavsson Date: Sat, 22 Mar 2025 14:27:37 +0100 Subject: [PATCH 8/8] Fix `clippy::unnecessary-literal-unwrap` in `bevy_time` (#18485) # Objective - Compiling `bevy_time` without the `std`-feature results in a `clippy::unnecessary-literal-unwrap`. ## Solution - Fix lint error ## Testing - CI --- --- crates/bevy_time/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index db39a41929..d2648e6fd8 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -160,12 +160,13 @@ pub fn time_system( None => None, }; - #[cfg(not(feature = "std"))] - let sent_time = None; - match update_strategy.as_ref() { TimeUpdateStrategy::Automatic => { + #[cfg(feature = "std")] real_time.update_with_instant(sent_time.unwrap_or_else(Instant::now)); + + #[cfg(not(feature = "std"))] + real_time.update_with_instant(Instant::now()); } TimeUpdateStrategy::ManualInstant(instant) => real_time.update_with_instant(*instant), TimeUpdateStrategy::ManualDuration(duration) => real_time.update_with_duration(*duration),