From 63f35cc190c7de199231b73203d5ab0555d4796f Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 7 Aug 2025 14:41:38 -0700 Subject: [PATCH 1/2] Fix elided lifetime lint --- crates/bevy_animation/src/animation_curves.rs | 10 ++++----- crates/bevy_animation/src/lib.rs | 4 ++-- crates/bevy_asset/src/loader.rs | 2 +- crates/bevy_asset/src/path.rs | 2 +- crates/bevy_asset/src/saver.rs | 2 +- crates/bevy_asset/src/server/mod.rs | 2 +- crates/bevy_asset/src/transformer.rs | 4 ++-- crates/bevy_ecs/src/change_detection.rs | 2 +- crates/bevy_ecs/src/entity/clone_entities.rs | 4 ++-- crates/bevy_ecs/src/entity/mod.rs | 2 +- crates/bevy_ecs/src/observer/mod.rs | 2 +- crates/bevy_ecs/src/observer/system_param.rs | 2 +- .../src/relationship/related_methods.rs | 2 +- crates/bevy_ecs/src/system/commands/mod.rs | 18 +++++++-------- crates/bevy_ecs/src/system/system_param.rs | 2 +- crates/bevy_ecs/src/world/deferred_world.rs | 10 ++++----- crates/bevy_ecs/src/world/mod.rs | 22 +++++++++---------- crates/bevy_gizmos/src/gizmos.rs | 2 +- crates/bevy_pbr/src/cluster.rs | 6 ++--- crates/bevy_pbr/src/material_bind_groups.rs | 6 ++--- crates/bevy_pbr/src/render/mesh.rs | 6 ++--- crates/bevy_pbr/src/render/mesh_bindings.rs | 13 ++++++----- crates/bevy_reflect/derive/src/derive_data.rs | 12 +++++----- .../bevy_reflect/derive/src/enum_utility.rs | 8 +++---- crates/bevy_reflect/src/array.rs | 10 ++++----- crates/bevy_reflect/src/enums/dynamic_enum.rs | 6 ++--- crates/bevy_reflect/src/enums/enum_trait.rs | 2 +- crates/bevy_reflect/src/func/args/from_arg.rs | 8 +++++++ .../bevy_reflect/src/func/dynamic_function.rs | 4 ++-- crates/bevy_reflect/src/func/info.rs | 2 +- crates/bevy_reflect/src/impls/alloc/borrow.rs | 10 ++++----- .../src/impls/alloc/collections/btree/map.rs | 4 ++-- crates/bevy_reflect/src/impls/core/panic.rs | 4 ++-- .../bevy_reflect/src/impls/core/primitives.rs | 10 ++++----- crates/bevy_reflect/src/impls/core/sync.rs | 4 ++-- crates/bevy_reflect/src/impls/macros/list.rs | 6 ++--- crates/bevy_reflect/src/impls/macros/map.rs | 4 ++-- crates/bevy_reflect/src/impls/macros/set.rs | 4 ++-- crates/bevy_reflect/src/impls/smallvec.rs | 6 ++--- crates/bevy_reflect/src/impls/std/path.rs | 8 +++---- crates/bevy_reflect/src/list.rs | 10 ++++----- crates/bevy_reflect/src/map.rs | 4 ++-- crates/bevy_reflect/src/path/error.rs | 2 +- crates/bevy_reflect/src/path/mod.rs | 2 +- crates/bevy_reflect/src/reflect.rs | 4 ++-- crates/bevy_reflect/src/set.rs | 4 ++-- crates/bevy_reflect/src/struct_trait.rs | 8 +++---- crates/bevy_reflect/src/tuple.rs | 14 ++++++------ crates/bevy_reflect/src/tuple_struct.rs | 8 +++---- crates/bevy_reflect/src/type_info.rs | 4 ++-- crates/bevy_reflect/src/type_info_stack.rs | 2 +- crates/bevy_reflect/src/utility.rs | 8 +++---- .../src/batching/gpu_preprocessing.rs | 2 +- .../src/batching/no_gpu_preprocessing.rs | 2 +- crates/bevy_render/src/mesh/allocator.rs | 6 ++--- .../render_resource/batched_uniform_buffer.rs | 2 +- .../src/render_resource/bind_group.rs | 2 +- .../bevy_render/src/render_resource/buffer.rs | 2 +- .../src/render_resource/buffer_vec.rs | 6 ++--- .../src/render_resource/gpu_array_buffer.rs | 2 +- .../src/render_resource/storage_buffer.rs | 4 ++-- .../src/render_resource/uniform_buffer.rs | 4 ++-- .../bevy_render/src/renderer/render_device.rs | 2 +- .../src/texture/texture_attachment.rs | 8 +++---- crates/bevy_render/src/view/mod.rs | 10 ++++----- crates/bevy_shader/src/shader_cache.rs | 2 +- crates/bevy_text/src/text_access.rs | 22 ++++++++++++------- crates/bevy_utils/src/debug_info.rs | 2 +- crates/bevy_window/src/raw_handle.rs | 4 ++-- examples/animation/animated_ui.rs | 2 +- examples/ecs/dynamic.rs | 2 +- 71 files changed, 205 insertions(+), 188 deletions(-) diff --git a/crates/bevy_animation/src/animation_curves.rs b/crates/bevy_animation/src/animation_curves.rs index 782daf0f552bc..0e1d5866df41b 100644 --- a/crates/bevy_animation/src/animation_curves.rs +++ b/crates/bevy_animation/src/animation_curves.rs @@ -199,7 +199,7 @@ pub trait AnimatableProperty: Send + Sync + 'static { /// The [`EvaluatorId`] used to look up the [`AnimationCurveEvaluator`] for this [`AnimatableProperty`]. /// For a given animated property, this ID should always be the same to allow things like animation blending to occur. - fn evaluator_id(&self) -> EvaluatorId; + fn evaluator_id(&self) -> EvaluatorId<'_>; } /// A [`Component`] field that can be animated, defined by a function that reads the component and returns @@ -236,7 +236,7 @@ where Ok((self.func)(c.into_inner())) } - fn evaluator_id(&self) -> EvaluatorId { + fn evaluator_id(&self) -> EvaluatorId<'_> { EvaluatorId::ComponentField(&self.evaluator_id) } } @@ -357,7 +357,7 @@ where self.curve.domain() } - fn evaluator_id(&self) -> EvaluatorId { + fn evaluator_id(&self) -> EvaluatorId<'_> { self.property.evaluator_id() } @@ -476,7 +476,7 @@ where self.0.domain() } - fn evaluator_id(&self) -> EvaluatorId { + fn evaluator_id(&self) -> EvaluatorId<'_> { EvaluatorId::Type(TypeId::of::()) } @@ -768,7 +768,7 @@ pub trait AnimationCurve: Debug + Send + Sync + 'static { /// /// This must match the type returned by [`Self::create_evaluator`]. It must /// be a single type that doesn't depend on the type of the curve. - fn evaluator_id(&self) -> EvaluatorId; + fn evaluator_id(&self) -> EvaluatorId<'_>; /// Returns a newly-instantiated [`AnimationCurveEvaluator`] for use with /// this curve. diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 67e5cde0466a9..6896a4d25b3bb 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -772,7 +772,7 @@ struct CurrentEvaluators { } impl CurrentEvaluators { - pub(crate) fn keys(&self) -> impl Iterator { + pub(crate) fn keys(&self) -> impl Iterator> { self.component_properties .keys() .map(EvaluatorId::ComponentField) @@ -1462,7 +1462,7 @@ impl<'a> TriggeredEvents<'a> { self.lower.is_empty() && self.upper.is_empty() } - fn iter(&self) -> TriggeredEventsIter { + fn iter(&self) -> TriggeredEventsIter<'_> { match self.direction { TriggeredEventsDir::Forward => TriggeredEventsIter::Forward(self.lower.iter()), TriggeredEventsDir::Reverse => TriggeredEventsIter::Reverse(self.lower.iter().rev()), diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 24405f0657d5e..8065d32b53bc5 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -371,7 +371,7 @@ impl<'a> LoadContext<'a> { /// load_context.add_loaded_labeled_asset(label, loaded_asset); /// } /// ``` - pub fn begin_labeled_asset(&self) -> LoadContext { + pub fn begin_labeled_asset(&self) -> LoadContext<'_> { LoadContext::new( self.asset_server, self.asset_path.clone(), diff --git a/crates/bevy_asset/src/path.rs b/crates/bevy_asset/src/path.rs index ed189a683b35d..d4e8b9a0370af 100644 --- a/crates/bevy_asset/src/path.rs +++ b/crates/bevy_asset/src/path.rs @@ -246,7 +246,7 @@ impl<'a> AssetPath<'a> { /// Gets the "asset source", if one was defined. If none was defined, the default source /// will be used. #[inline] - pub fn source(&self) -> &AssetSourceId { + pub fn source(&self) -> &AssetSourceId<'_> { &self.source } diff --git a/crates/bevy_asset/src/saver.rs b/crates/bevy_asset/src/saver.rs index c8b96012eea72..0f3e3987f264a 100644 --- a/crates/bevy_asset/src/saver.rs +++ b/crates/bevy_asset/src/saver.rs @@ -114,7 +114,7 @@ impl<'a, A: Asset> SavedAsset<'a, A> { } /// Returns the labeled asset, if it exists and matches this type. - pub fn get_labeled(&self, label: &Q) -> Option> + pub fn get_labeled(&self, label: &Q) -> Option> where CowArc<'static, str>: Borrow, Q: ?Sized + Hash + Eq, diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index 69dc8428da87d..102f985fe1213 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -1272,7 +1272,7 @@ impl AssetServer { } /// Returns the path for the given `id`, if it has one. - pub fn get_path(&self, id: impl Into) -> Option { + pub fn get_path(&self, id: impl Into) -> Option> { let infos = self.data.infos.read(); let info = infos.get(id.into())?; Some(info.path.as_ref()?.clone()) diff --git a/crates/bevy_asset/src/transformer.rs b/crates/bevy_asset/src/transformer.rs index 802e3aeaa7eff..f80f44511ab4c 100644 --- a/crates/bevy_asset/src/transformer.rs +++ b/crates/bevy_asset/src/transformer.rs @@ -87,7 +87,7 @@ impl TransformedAsset { &mut self.value } /// Returns the labeled asset, if it exists and matches this type. - pub fn get_labeled(&mut self, label: &Q) -> Option> + pub fn get_labeled(&mut self, label: &Q) -> Option> where CowArc<'static, str>: Borrow, Q: ?Sized + Hash + Eq, @@ -187,7 +187,7 @@ impl<'a, A: Asset> TransformedSubAsset<'a, A> { self.value } /// Returns the labeled asset, if it exists and matches this type. - pub fn get_labeled(&mut self, label: &Q) -> Option> + pub fn get_labeled(&mut self, label: &Q) -> Option> where CowArc<'static, str>: Borrow, Q: ?Sized + Hash + Eq, diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index 1ba4f23db2721..af42d9c44176d 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -1051,7 +1051,7 @@ impl<'w> MutUntyped<'w> { /// Returns a [`MutUntyped`] with a smaller lifetime. /// This is useful if you have `&mut MutUntyped`, but you need a `MutUntyped`. #[inline] - pub fn reborrow(&mut self) -> MutUntyped { + pub fn reborrow(&mut self) -> MutUntyped<'_> { MutUntyped { value: self.value.reborrow(), ticks: TicksMut { diff --git a/crates/bevy_ecs/src/entity/clone_entities.rs b/crates/bevy_ecs/src/entity/clone_entities.rs index 2ba536a114b21..b2e78d79c1084 100644 --- a/crates/bevy_ecs/src/entity/clone_entities.rs +++ b/crates/bevy_ecs/src/entity/clone_entities.rs @@ -445,7 +445,7 @@ impl EntityCloner { /// explicitly denied, for example by using the [`deny`](EntityClonerBuilder::deny) method. /// /// Required components are not considered by denied components and must be explicitly denied as well if desired. - pub fn build_opt_out(world: &mut World) -> EntityClonerBuilder { + pub fn build_opt_out(world: &mut World) -> EntityClonerBuilder<'_, OptOut> { EntityClonerBuilder { world, filter: Default::default(), @@ -461,7 +461,7 @@ impl EntityCloner { /// Components allowed to be cloned through this builder would also allow their required components, /// which will be cloned from the source entity only if the target entity does not contain them already. /// To skip adding required components see [`without_required_components`](EntityClonerBuilder::without_required_components). - pub fn build_opt_in(world: &mut World) -> EntityClonerBuilder { + pub fn build_opt_in(world: &mut World) -> EntityClonerBuilder<'_, OptIn> { EntityClonerBuilder { world, filter: Default::default(), diff --git a/crates/bevy_ecs/src/entity/mod.rs b/crates/bevy_ecs/src/entity/mod.rs index 64a8c8952e0df..07404459c6c36 100644 --- a/crates/bevy_ecs/src/entity/mod.rs +++ b/crates/bevy_ecs/src/entity/mod.rs @@ -774,7 +774,7 @@ impl Entities { clippy::unnecessary_fallible_conversions, reason = "`IdCursor::try_from` may fail on 32-bit platforms." )] - pub fn reserve_entities(&self, count: u32) -> ReserveEntitiesIterator { + pub fn reserve_entities(&self, count: u32) -> ReserveEntitiesIterator<'_> { // Use one atomic subtract to grab a range of new IDs. The range might be // entirely nonnegative, meaning all IDs come from the freelist, or entirely // negative, meaning they are all new IDs to allocate, or a mix of both. diff --git a/crates/bevy_ecs/src/observer/mod.rs b/crates/bevy_ecs/src/observer/mod.rs index dd43cb090d181..18a7e4ba27367 100644 --- a/crates/bevy_ecs/src/observer/mod.rs +++ b/crates/bevy_ecs/src/observer/mod.rs @@ -182,7 +182,7 @@ impl World { pub fn add_observer( &mut self, system: impl IntoObserverSystem, - ) -> EntityWorldMut { + ) -> EntityWorldMut<'_> { self.spawn(Observer::new(system)) } diff --git a/crates/bevy_ecs/src/observer/system_param.rs b/crates/bevy_ecs/src/observer/system_param.rs index 6e165ccd6df67..6637a0ce2472c 100644 --- a/crates/bevy_ecs/src/observer/system_param.rs +++ b/crates/bevy_ecs/src/observer/system_param.rs @@ -64,7 +64,7 @@ impl<'w, E, B: Bundle> On<'w, E, B> { } /// Returns a pointer to the triggered event. - pub fn event_ptr(&self) -> Ptr { + pub fn event_ptr(&self) -> Ptr<'_> { Ptr::from(&self.event) } diff --git a/crates/bevy_ecs/src/relationship/related_methods.rs b/crates/bevy_ecs/src/relationship/related_methods.rs index 22b5ea128187b..dbbe015f6b7f5 100644 --- a/crates/bevy_ecs/src/relationship/related_methods.rs +++ b/crates/bevy_ecs/src/relationship/related_methods.rs @@ -642,7 +642,7 @@ impl<'w, R: Relationship> RelatedSpawnerCommands<'w, R> { } /// Returns the underlying [`Commands`]. - pub fn commands(&mut self) -> Commands { + pub fn commands(&mut self) -> Commands<'_, '_> { self.commands.reborrow() } diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index c2df1823f70ea..3f3e75c37f700 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -313,7 +313,7 @@ impl<'w, 's> Commands<'w, 's> { /// - [`spawn_batch`](Self::spawn_batch) to spawn many entities /// with the same combination of components. #[track_caller] - pub fn spawn_empty(&mut self) -> EntityCommands { + pub fn spawn_empty(&mut self) -> EntityCommands<'_> { let entity = self.entities.reserve_entity(); let mut entity_commands = EntityCommands { entity, @@ -375,7 +375,7 @@ impl<'w, 's> Commands<'w, 's> { /// - [`spawn_batch`](Self::spawn_batch) to spawn many entities /// with the same combination of components. #[track_caller] - pub fn spawn(&mut self, bundle: T) -> EntityCommands { + pub fn spawn(&mut self, bundle: T) -> EntityCommands<'_> { let entity = self.entities.reserve_entity(); let mut entity_commands = EntityCommands { entity, @@ -436,7 +436,7 @@ impl<'w, 's> Commands<'w, 's> { /// - [`get_entity`](Self::get_entity) for the fallible version. #[inline] #[track_caller] - pub fn entity(&mut self, entity: Entity) -> EntityCommands { + pub fn entity(&mut self, entity: Entity) -> EntityCommands<'_> { EntityCommands { entity, commands: self.reborrow(), @@ -487,7 +487,7 @@ impl<'w, 's> Commands<'w, 's> { pub fn get_entity( &mut self, entity: Entity, - ) -> Result { + ) -> Result, EntityDoesNotExistError> { if self.entities.contains(entity) { Ok(EntityCommands { entity, @@ -1120,7 +1120,7 @@ impl<'w, 's> Commands<'w, 's> { pub fn add_observer( &mut self, observer: impl IntoObserverSystem, - ) -> EntityCommands { + ) -> EntityCommands<'_> { self.spawn(Observer::new(observer)) } @@ -1269,7 +1269,7 @@ impl<'a> EntityCommands<'a> { /// Returns an [`EntityCommands`] with a smaller lifetime. /// /// This is useful if you have `&mut EntityCommands` but you need `EntityCommands`. - pub fn reborrow(&mut self) -> EntityCommands { + pub fn reborrow(&mut self) -> EntityCommands<'_> { EntityCommands { entity: self.entity, commands: self.commands.reborrow(), @@ -1319,7 +1319,7 @@ impl<'a> EntityCommands<'a> { /// /// # bevy_ecs::system::assert_is_system(level_up_system); /// ``` - pub fn entry(&mut self) -> EntityEntryCommands { + pub fn entry(&mut self) -> EntityEntryCommands<'_, T> { EntityEntryCommands { entity_commands: self.reborrow(), marker: PhantomData, @@ -1982,7 +1982,7 @@ impl<'a> EntityCommands<'a> { } /// Returns the underlying [`Commands`]. - pub fn commands(&mut self) -> Commands { + pub fn commands(&mut self) -> Commands<'_, '_> { self.commands.reborrow() } @@ -2381,7 +2381,7 @@ impl<'a, T: Component> EntityEntryCommands<'a, T> { /// } /// # bevy_ecs::system::assert_is_system(level_up_system); /// ``` - pub fn entity(&mut self) -> EntityCommands { + pub fn entity(&mut self) -> EntityCommands<'_> { self.entity_commands.reborrow() } } diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index dcf5f4f3327fe..d9adab6fe34b7 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -1270,7 +1270,7 @@ impl<'a, T: SystemBuffer> DerefMut for Deferred<'a, T> { impl Deferred<'_, T> { /// Returns a [`Deferred`] with a smaller lifetime. /// This is useful if you have `&mut Deferred` but need `Deferred`. - pub fn reborrow(&mut self) -> Deferred { + pub fn reborrow(&mut self) -> Deferred<'_, T> { Deferred(self.0) } } diff --git a/crates/bevy_ecs/src/world/deferred_world.rs b/crates/bevy_ecs/src/world/deferred_world.rs index 3b146d2c0589c..92d2e98e5da69 100644 --- a/crates/bevy_ecs/src/world/deferred_world.rs +++ b/crates/bevy_ecs/src/world/deferred_world.rs @@ -62,13 +62,13 @@ impl<'w> From<&'w mut World> for DeferredWorld<'w> { impl<'w> DeferredWorld<'w> { /// Reborrow self as a new instance of [`DeferredWorld`] #[inline] - pub fn reborrow(&mut self) -> DeferredWorld { + pub fn reborrow(&mut self) -> DeferredWorld<'_> { DeferredWorld { world: self.world } } /// Creates a [`Commands`] instance that pushes to the world's command queue #[inline] - pub fn commands(&mut self) -> Commands { + pub fn commands(&mut self) -> Commands<'_, '_> { // SAFETY: &mut self ensure that there are no outstanding accesses to the queue let command_queue = unsafe { self.world.get_raw_command_queue() }; // SAFETY: command_queue is stored on world and always valid while the world exists @@ -81,7 +81,7 @@ impl<'w> DeferredWorld<'w> { pub fn get_mut>( &mut self, entity: Entity, - ) -> Option> { + ) -> Option> { self.get_entity_mut(entity).ok()?.into_mut() } @@ -418,7 +418,7 @@ impl<'w> DeferredWorld<'w> { /// # assert_eq!(_world.get::(e1).unwrap().0, eid); /// # assert_eq!(_world.get::(e2).unwrap().0, eid); /// ``` - pub fn entities_and_commands(&mut self) -> (EntityFetcher, Commands) { + pub fn entities_and_commands(&mut self) -> (EntityFetcher<'_>, Commands<'_, '_>) { let cell = self.as_unsafe_world_cell(); // SAFETY: `&mut self` gives mutable access to the entire world, and prevents simultaneous access. let fetcher = unsafe { EntityFetcher::new(cell) }; @@ -887,7 +887,7 @@ impl<'w> DeferredWorld<'w> { /// # Safety /// - must only be used to make non-structural ECS changes #[inline] - pub(crate) fn as_unsafe_world_cell(&mut self) -> UnsafeWorldCell { + pub(crate) fn as_unsafe_world_cell(&mut self) -> UnsafeWorldCell<'_> { self.world } } diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index d251206c37720..9e36484cc5141 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -232,14 +232,14 @@ impl World { /// **NOTE:** [`ComponentsQueuedRegistrator`] is easily misused. /// See its docs for important notes on when and how it should be used. #[inline] - pub fn components_queue(&self) -> ComponentsQueuedRegistrator { + pub fn components_queue(&self) -> ComponentsQueuedRegistrator<'_> { // SAFETY: These are from the same world. unsafe { ComponentsQueuedRegistrator::new(&self.components, &self.component_ids) } } /// Prepares a [`ComponentsRegistrator`] for the world. #[inline] - pub fn components_registrator(&mut self) -> ComponentsRegistrator { + pub fn components_registrator(&mut self) -> ComponentsRegistrator<'_> { // SAFETY: These are from the same world. unsafe { ComponentsRegistrator::new(&mut self.components, &mut self.component_ids) } } @@ -271,7 +271,7 @@ impl World { /// Creates a new [`Commands`] instance that writes to the world's command queue /// Use [`World::flush`] to apply all queued commands #[inline] - pub fn commands(&mut self) -> Commands { + pub fn commands(&mut self) -> Commands<'_, '_> { // SAFETY: command_queue is stored on world and always valid while the world exists unsafe { Commands::new_raw_from_entities(self.command_queue.clone(), &self.entities) } } @@ -1047,7 +1047,7 @@ impl World { /// # assert_eq!(world.get::(e1).unwrap().0, eid); /// # assert_eq!(world.get::(e2).unwrap().0, eid); /// ``` - pub fn entities_and_commands(&mut self) -> (EntityFetcher, Commands) { + pub fn entities_and_commands(&mut self) -> (EntityFetcher<'_>, Commands<'_, '_>) { let cell = self.as_unsafe_world_cell(); // SAFETY: `&mut self` gives mutable access to the entire world, and prevents simultaneous access. let fetcher = unsafe { EntityFetcher::new(cell) }; @@ -1087,7 +1087,7 @@ impl World { /// assert_eq!(position.x, 0.0); /// ``` #[track_caller] - pub fn spawn_empty(&mut self) -> EntityWorldMut { + pub fn spawn_empty(&mut self) -> EntityWorldMut<'_> { self.flush(); let entity = self.entities.alloc(); // SAFETY: entity was just allocated @@ -1155,7 +1155,7 @@ impl World { /// assert_eq!(position.x, 2.0); /// ``` #[track_caller] - pub fn spawn(&mut self, bundle: B) -> EntityWorldMut { + pub fn spawn(&mut self, bundle: B) -> EntityWorldMut<'_> { self.spawn_with_caller(bundle, MaybeLocation::caller()) } @@ -1163,7 +1163,7 @@ impl World { &mut self, bundle: B, caller: MaybeLocation, - ) -> EntityWorldMut { + ) -> EntityWorldMut<'_> { self.flush(); let change_tick = self.change_tick(); let entity = self.entities.alloc(); @@ -1192,7 +1192,7 @@ impl World { &mut self, entity: Entity, caller: MaybeLocation, - ) -> EntityWorldMut { + ) -> EntityWorldMut<'_> { let archetype = self.archetypes.empty_mut(); // PERF: consider avoiding allocating entities in the empty archetype unless needed let table_row = self.storages.tables[archetype.table_id()].allocate(entity); @@ -1279,7 +1279,7 @@ impl World { pub fn get_mut>( &mut self, entity: Entity, - ) -> Option> { + ) -> Option> { self.get_entity_mut(entity).ok()?.into_mut() } @@ -1980,7 +1980,7 @@ impl World { /// use [`get_resource_or_insert_with`](World::get_resource_or_insert_with). #[inline] #[track_caller] - pub fn resource_ref(&self) -> Ref { + pub fn resource_ref(&self) -> Ref<'_, R> { match self.get_resource_ref() { Some(x) => x, None => panic!( @@ -2028,7 +2028,7 @@ impl World { /// Gets a reference including change detection to the resource of the given type if it exists. #[inline] - pub fn get_resource_ref(&self) -> Option> { + pub fn get_resource_ref(&self) -> Option> { // SAFETY: // - `as_unsafe_world_cell_readonly` gives permission to access everything immutably // - `&self` ensures nothing in world is borrowed mutably diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index 0299b4700a3a1..d13fe8240be78 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -355,7 +355,7 @@ where } /// Read-only view into the buffers data. - pub fn buffer(&self) -> GizmoBufferView { + pub fn buffer(&self) -> GizmoBufferView<'_> { let GizmoBuffer { list_positions, list_colors, diff --git a/crates/bevy_pbr/src/cluster.rs b/crates/bevy_pbr/src/cluster.rs index f3d242a512fcc..bc473a509f666 100644 --- a/crates/bevy_pbr/src/cluster.rs +++ b/crates/bevy_pbr/src/cluster.rs @@ -216,7 +216,7 @@ impl GpuClusterableObjects { } } - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { match self { GpuClusterableObjects::Uniform(buffer) => buffer.binding(), GpuClusterableObjects::Storage(buffer) => buffer.binding(), @@ -456,7 +456,7 @@ impl ViewClusterBindings { } } - pub fn clusterable_object_index_lists_binding(&self) -> Option { + pub fn clusterable_object_index_lists_binding(&self) -> Option> { match &self.buffers { ViewClusterBuffers::Uniform { clusterable_object_index_lists, @@ -469,7 +469,7 @@ impl ViewClusterBindings { } } - pub fn offsets_and_counts_binding(&self) -> Option { + pub fn offsets_and_counts_binding(&self) -> Option> { match &self.buffers { ViewClusterBuffers::Uniform { cluster_offsets_and_counts, diff --git a/crates/bevy_pbr/src/material_bind_groups.rs b/crates/bevy_pbr/src/material_bind_groups.rs index c984cfb85db7d..0851760bbfd03 100644 --- a/crates/bevy_pbr/src/material_bind_groups.rs +++ b/crates/bevy_pbr/src/material_bind_groups.rs @@ -478,7 +478,7 @@ impl MaterialBindGroupAllocator { } /// Returns the slab with the given index, if one exists. - pub fn get(&self, group: MaterialBindGroupIndex) -> Option { + pub fn get(&self, group: MaterialBindGroupIndex) -> Option> { match *self { MaterialBindGroupAllocator::Bindless(ref bindless_allocator) => bindless_allocator .get(group) @@ -673,7 +673,7 @@ impl MaterialBindlessIndexTable { } /// Returns the [`BindGroupEntry`] for the index table itself. - fn bind_group_entry(&self) -> BindGroupEntry { + fn bind_group_entry(&self) -> BindGroupEntry<'_> { BindGroupEntry { binding: *self.binding_number, resource: self @@ -1837,7 +1837,7 @@ impl MaterialBindGroupNonBindlessAllocator { } /// Returns a wrapper around the bind group with the given index. - fn get(&self, group: MaterialBindGroupIndex) -> Option { + fn get(&self, group: MaterialBindGroupIndex) -> Option> { self.bind_groups[group.0 as usize] .as_ref() .map(|bind_group| match bind_group { diff --git a/crates/bevy_pbr/src/render/mesh.rs b/crates/bevy_pbr/src/render/mesh.rs index 9795d442ddd99..580dbc2d99a3c 100644 --- a/crates/bevy_pbr/src/render/mesh.rs +++ b/crates/bevy_pbr/src/render/mesh.rs @@ -903,7 +903,7 @@ impl RenderMeshInstances { /// Constructs [`RenderMeshQueueData`] for the given entity, if it has a /// mesh attached. - pub fn render_mesh_queue_data(&self, entity: MainEntity) -> Option { + pub fn render_mesh_queue_data(&self, entity: MainEntity) -> Option> { match *self { RenderMeshInstances::CpuBuilding(ref instances) => { instances.render_mesh_queue_data(entity) @@ -934,7 +934,7 @@ impl RenderMeshInstancesCpu { .map(|render_mesh_instance| render_mesh_instance.mesh_asset_id) } - fn render_mesh_queue_data(&self, entity: MainEntity) -> Option { + fn render_mesh_queue_data(&self, entity: MainEntity) -> Option> { self.get(&entity) .map(|render_mesh_instance| RenderMeshQueueData { shared: &render_mesh_instance.shared, @@ -958,7 +958,7 @@ impl RenderMeshInstancesGpu { .map(|render_mesh_instance| render_mesh_instance.mesh_asset_id) } - fn render_mesh_queue_data(&self, entity: MainEntity) -> Option { + fn render_mesh_queue_data(&self, entity: MainEntity) -> Option> { self.get(&entity) .map(|render_mesh_instance| RenderMeshQueueData { shared: &render_mesh_instance.shared, diff --git a/crates/bevy_pbr/src/render/mesh_bindings.rs b/crates/bevy_pbr/src/render/mesh_bindings.rs index 51b28389dcd0c..b8f095af72a86 100644 --- a/crates/bevy_pbr/src/render/mesh_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_bindings.rs @@ -91,7 +91,7 @@ mod entry { renderer::RenderDevice, }; - fn entry(binding: u32, size: Option, buffer: &Buffer) -> BindGroupEntry { + fn entry(binding: u32, size: Option, buffer: &Buffer) -> BindGroupEntry<'_> { BindGroupEntry { binding, resource: BindingResource::Buffer(BufferBinding { @@ -116,22 +116,25 @@ mod entry { }; entry(binding, size, buffer) } - pub(super) fn weights(binding: u32, buffer: &Buffer) -> BindGroupEntry { + pub(super) fn weights(binding: u32, buffer: &Buffer) -> BindGroupEntry<'_> { entry(binding, Some(MORPH_BUFFER_SIZE as u64), buffer) } - pub(super) fn targets(binding: u32, texture: &TextureView) -> BindGroupEntry { + pub(super) fn targets(binding: u32, texture: &TextureView) -> BindGroupEntry<'_> { BindGroupEntry { binding, resource: BindingResource::TextureView(texture), } } - pub(super) fn lightmaps_texture_view(binding: u32, texture: &TextureView) -> BindGroupEntry { + pub(super) fn lightmaps_texture_view( + binding: u32, + texture: &TextureView, + ) -> BindGroupEntry<'_> { BindGroupEntry { binding, resource: BindingResource::TextureView(texture), } } - pub(super) fn lightmaps_sampler(binding: u32, sampler: &Sampler) -> BindGroupEntry { + pub(super) fn lightmaps_sampler(binding: u32, sampler: &Sampler) -> BindGroupEntry<'_> { BindGroupEntry { binding, resource: BindingResource::Sampler(sampler), diff --git a/crates/bevy_reflect/derive/src/derive_data.rs b/crates/bevy_reflect/derive/src/derive_data.rs index 9e3e169bc21f6..ce985d39bd2f3 100644 --- a/crates/bevy_reflect/derive/src/derive_data.rs +++ b/crates/bevy_reflect/derive/src/derive_data.rs @@ -332,7 +332,7 @@ impl<'a> ReflectDerive<'a> { } /// Get the remote type path, if any. - pub fn remote_ty(&self) -> Option { + pub fn remote_ty(&self) -> Option> { match self { Self::Struct(data) | Self::TupleStruct(data) | Self::UnitStruct(data) => { data.meta.remote_ty() @@ -343,7 +343,7 @@ impl<'a> ReflectDerive<'a> { } /// Get the [`ReflectMeta`] for this derived type. - pub fn meta(&self) -> &ReflectMeta { + pub fn meta(&self) -> &ReflectMeta<'_> { match self { Self::Struct(data) | Self::TupleStruct(data) | Self::UnitStruct(data) => data.meta(), Self::Enum(data) => data.meta(), @@ -351,7 +351,7 @@ impl<'a> ReflectDerive<'a> { } } - pub fn where_clause_options(&self) -> WhereClauseOptions { + pub fn where_clause_options(&self) -> WhereClauseOptions<'_, '_> { match self { Self::Struct(data) | Self::TupleStruct(data) | Self::UnitStruct(data) => { data.where_clause_options() @@ -462,7 +462,7 @@ impl<'a> ReflectMeta<'a> { } /// Get the remote type path, if any. - pub fn remote_ty(&self) -> Option { + pub fn remote_ty(&self) -> Option> { self.remote_ty } @@ -631,7 +631,7 @@ impl<'a> ReflectStruct<'a> { &self.fields } - pub fn where_clause_options(&self) -> WhereClauseOptions { + pub fn where_clause_options(&self) -> WhereClauseOptions<'_, '_> { WhereClauseOptions::new_with_types(self.meta(), self.active_types()) } @@ -851,7 +851,7 @@ impl<'a> ReflectEnum<'a> { self.variants.iter().flat_map(EnumVariant::active_fields) } - pub fn where_clause_options(&self) -> WhereClauseOptions { + pub fn where_clause_options(&self) -> WhereClauseOptions<'_, '_> { WhereClauseOptions::new_with_types(self.meta(), self.active_types()) } diff --git a/crates/bevy_reflect/derive/src/enum_utility.rs b/crates/bevy_reflect/derive/src/enum_utility.rs index c717b7723eb3d..2b32ce1e4d0f3 100644 --- a/crates/bevy_reflect/derive/src/enum_utility.rs +++ b/crates/bevy_reflect/derive/src/enum_utility.rs @@ -37,7 +37,7 @@ pub(crate) struct VariantField<'a, 'b> { /// Trait used to control how enum variants are built. pub(crate) trait VariantBuilder: Sized { /// Returns the enum data. - fn reflect_enum(&self) -> &ReflectEnum; + fn reflect_enum(&self) -> &ReflectEnum<'_>; /// Returns a token stream that accesses a field of a variant as an `Option`. /// @@ -212,7 +212,7 @@ impl<'a> FromReflectVariantBuilder<'a> { } impl<'a> VariantBuilder for FromReflectVariantBuilder<'a> { - fn reflect_enum(&self) -> &ReflectEnum { + fn reflect_enum(&self) -> &ReflectEnum<'_> { self.reflect_enum } @@ -244,7 +244,7 @@ impl<'a> TryApplyVariantBuilder<'a> { } impl<'a> VariantBuilder for TryApplyVariantBuilder<'a> { - fn reflect_enum(&self) -> &ReflectEnum { + fn reflect_enum(&self) -> &ReflectEnum<'_> { self.reflect_enum } @@ -300,7 +300,7 @@ impl<'a> ReflectCloneVariantBuilder<'a> { } impl<'a> VariantBuilder for ReflectCloneVariantBuilder<'a> { - fn reflect_enum(&self) -> &ReflectEnum { + fn reflect_enum(&self) -> &ReflectEnum<'_> { self.reflect_enum } diff --git a/crates/bevy_reflect/src/array.rs b/crates/bevy_reflect/src/array.rs index df9580b8201e9..55412a1e79fba 100644 --- a/crates/bevy_reflect/src/array.rs +++ b/crates/bevy_reflect/src/array.rs @@ -63,7 +63,7 @@ pub trait Array: PartialReflect { } /// Returns an iterator over the array. - fn iter(&self) -> ArrayIter; + fn iter(&self) -> ArrayIter<'_>; /// Drain the elements of this array to get a vector of owned values. fn drain(self: Box) -> Vec>; @@ -242,12 +242,12 @@ impl PartialReflect for DynamicArray { } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Array(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Array(self) } @@ -294,7 +294,7 @@ impl Array for DynamicArray { } #[inline] - fn iter(&self) -> ArrayIter { + fn iter(&self) -> ArrayIter<'_> { ArrayIter::new(self) } @@ -351,7 +351,7 @@ pub struct ArrayIter<'a> { impl ArrayIter<'_> { /// Creates a new [`ArrayIter`]. #[inline] - pub const fn new(array: &dyn Array) -> ArrayIter { + pub const fn new(array: &dyn Array) -> ArrayIter<'_> { ArrayIter { array, index: 0 } } } diff --git a/crates/bevy_reflect/src/enums/dynamic_enum.rs b/crates/bevy_reflect/src/enums/dynamic_enum.rs index 214d54c5e302d..8f218a5f04bbc 100644 --- a/crates/bevy_reflect/src/enums/dynamic_enum.rs +++ b/crates/bevy_reflect/src/enums/dynamic_enum.rs @@ -255,7 +255,7 @@ impl Enum for DynamicEnum { } } - fn iter_fields(&self) -> VariantFieldIter { + fn iter_fields(&self) -> VariantFieldIter<'_> { VariantFieldIter::new(self) } @@ -372,12 +372,12 @@ impl PartialReflect for DynamicEnum { } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Enum(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Enum(self) } diff --git a/crates/bevy_reflect/src/enums/enum_trait.rs b/crates/bevy_reflect/src/enums/enum_trait.rs index 32e4b9612402f..a24fe65f6d97f 100644 --- a/crates/bevy_reflect/src/enums/enum_trait.rs +++ b/crates/bevy_reflect/src/enums/enum_trait.rs @@ -115,7 +115,7 @@ pub trait Enum: PartialReflect { /// For non-[`VariantType::Struct`] variants, this should return `None`. fn name_at(&self, index: usize) -> Option<&str>; /// Returns an iterator over the values of the current variant's fields. - fn iter_fields(&self) -> VariantFieldIter; + fn iter_fields(&self) -> VariantFieldIter<'_>; /// Returns the number of fields in the current variant. fn field_len(&self) -> usize; /// The name of the current variant. diff --git a/crates/bevy_reflect/src/func/args/from_arg.rs b/crates/bevy_reflect/src/func/args/from_arg.rs index c49d065169902..2ad1ae6353fee 100644 --- a/crates/bevy_reflect/src/func/args/from_arg.rs +++ b/crates/bevy_reflect/src/func/args/from_arg.rs @@ -1,3 +1,7 @@ +#![expect( + mismatched_lifetime_syntaxes, + reason = "I can't figure out how to fix this." +)] use crate::func::args::{Arg, ArgError}; use crate::{Reflect, TypePath}; @@ -77,6 +81,10 @@ macro_rules! impl_from_arg { )? { type This<'from_arg> = $ty; + #[expect( + mismatched_lifetime_syntaxes, + reason = "I can't figure out how to fix this." + )] fn from_arg(arg: $crate::func::args::Arg) -> Result, $crate::func::args::ArgError> { diff --git a/crates/bevy_reflect/src/func/dynamic_function.rs b/crates/bevy_reflect/src/func/dynamic_function.rs index ab1d70e4ed47a..d9f881af33626 100644 --- a/crates/bevy_reflect/src/func/dynamic_function.rs +++ b/crates/bevy_reflect/src/func/dynamic_function.rs @@ -409,11 +409,11 @@ impl PartialReflect for DynamicFunction<'static> { ReflectKind::Function } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Function(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Function(self) } diff --git a/crates/bevy_reflect/src/func/info.rs b/crates/bevy_reflect/src/func/info.rs index 2f5f82fbf5499..f3675ca185f7a 100644 --- a/crates/bevy_reflect/src/func/info.rs +++ b/crates/bevy_reflect/src/func/info.rs @@ -177,7 +177,7 @@ impl FunctionInfo { /// let pretty = info.pretty_printer(); /// assert_eq!(format!("{:?}", pretty), "(_: i32, _: i32) -> i32"); /// ``` - pub fn pretty_printer(&self) -> PrettyPrintFunctionInfo { + pub fn pretty_printer(&self) -> PrettyPrintFunctionInfo<'_> { PrettyPrintFunctionInfo::new(self) } diff --git a/crates/bevy_reflect/src/impls/alloc/borrow.rs b/crates/bevy_reflect/src/impls/alloc/borrow.rs index 9021343c67b75..8326ff9728922 100644 --- a/crates/bevy_reflect/src/impls/alloc/borrow.rs +++ b/crates/bevy_reflect/src/impls/alloc/borrow.rs @@ -55,11 +55,11 @@ impl PartialReflect for Cow<'static, str> { ReflectKind::Opaque } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Opaque(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Opaque(self) } @@ -180,7 +180,7 @@ impl List self.as_ref().len() } - fn iter(&self) -> ListIter { + fn iter(&self) -> ListIter<'_> { ListIter::new(self) } @@ -228,11 +228,11 @@ impl Parti ReflectKind::List } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::List(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::List(self) } diff --git a/crates/bevy_reflect/src/impls/alloc/collections/btree/map.rs b/crates/bevy_reflect/src/impls/alloc/collections/btree/map.rs index d5559a2985abd..ffa6ee34225a3 100644 --- a/crates/bevy_reflect/src/impls/alloc/collections/btree/map.rs +++ b/crates/bevy_reflect/src/impls/alloc/collections/btree/map.rs @@ -128,11 +128,11 @@ where ReflectKind::Map } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Map(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Map(self) } diff --git a/crates/bevy_reflect/src/impls/core/panic.rs b/crates/bevy_reflect/src/impls/core/panic.rs index 3d1cebe53e536..8bc583c64ba78 100644 --- a/crates/bevy_reflect/src/impls/core/panic.rs +++ b/crates/bevy_reflect/src/impls/core/panic.rs @@ -57,11 +57,11 @@ impl PartialReflect for &'static Location<'static> { ReflectKind::Opaque } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Opaque(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Opaque(self) } diff --git a/crates/bevy_reflect/src/impls/core/primitives.rs b/crates/bevy_reflect/src/impls/core/primitives.rs index 75825598233bc..8d53193ac6d03 100644 --- a/crates/bevy_reflect/src/impls/core/primitives.rs +++ b/crates/bevy_reflect/src/impls/core/primitives.rs @@ -191,11 +191,11 @@ impl PartialReflect for &'static str { Some(self) } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Opaque(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Opaque(self) } @@ -310,7 +310,7 @@ impl A } #[inline] - fn iter(&self) -> ArrayIter { + fn iter(&self) -> ArrayIter<'_> { ArrayIter::new(self) } @@ -360,12 +360,12 @@ impl P } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Array(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Array(self) } diff --git a/crates/bevy_reflect/src/impls/core/sync.rs b/crates/bevy_reflect/src/impls/core/sync.rs index 06b930e8a9b92..f48f5baa9d9d6 100644 --- a/crates/bevy_reflect/src/impls/core/sync.rs +++ b/crates/bevy_reflect/src/impls/core/sync.rs @@ -102,11 +102,11 @@ macro_rules! impl_reflect_for_atomic { ReflectKind::Opaque } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef <'_> { ReflectRef::Opaque(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut <'_> { ReflectMut::Opaque(self) } #[inline] diff --git a/crates/bevy_reflect/src/impls/macros/list.rs b/crates/bevy_reflect/src/impls/macros/list.rs index 81a27047cb687..16fd6661348e6 100644 --- a/crates/bevy_reflect/src/impls/macros/list.rs +++ b/crates/bevy_reflect/src/impls/macros/list.rs @@ -48,7 +48,7 @@ macro_rules! impl_reflect_for_veclike { } #[inline] - fn iter(&self) -> $crate::list::ListIter { + fn iter(&self) -> $crate::list::ListIter<'_> { $crate::list::ListIter::new(self) } @@ -98,11 +98,11 @@ macro_rules! impl_reflect_for_veclike { $crate::kind::ReflectKind::List } - fn reflect_ref(&self) -> $crate::kind::ReflectRef { + fn reflect_ref(&self) -> $crate::kind::ReflectRef<'_> { $crate::kind::ReflectRef::List(self) } - fn reflect_mut(&mut self) -> $crate::kind::ReflectMut { + fn reflect_mut(&mut self) -> $crate::kind::ReflectMut<'_> { $crate::kind::ReflectMut::List(self) } diff --git a/crates/bevy_reflect/src/impls/macros/map.rs b/crates/bevy_reflect/src/impls/macros/map.rs index e87bb314b5a18..5ac779f3a747d 100644 --- a/crates/bevy_reflect/src/impls/macros/map.rs +++ b/crates/bevy_reflect/src/impls/macros/map.rs @@ -131,11 +131,11 @@ macro_rules! impl_reflect_for_hashmap { $crate::kind::ReflectKind::Map } - fn reflect_ref(&self) -> $crate::kind::ReflectRef { + fn reflect_ref(&self) -> $crate::kind::ReflectRef<'_> { $crate::kind::ReflectRef::Map(self) } - fn reflect_mut(&mut self) -> $crate::kind::ReflectMut { + fn reflect_mut(&mut self) -> $crate::kind::ReflectMut<'_> { $crate::kind::ReflectMut::Map(self) } diff --git a/crates/bevy_reflect/src/impls/macros/set.rs b/crates/bevy_reflect/src/impls/macros/set.rs index 844b904cdec4c..69506a88e4549 100644 --- a/crates/bevy_reflect/src/impls/macros/set.rs +++ b/crates/bevy_reflect/src/impls/macros/set.rs @@ -114,11 +114,11 @@ macro_rules! impl_reflect_for_hashset { $crate::kind::ReflectKind::Set } - fn reflect_ref(&self) -> $crate::kind::ReflectRef { + fn reflect_ref(&self) -> $crate::kind::ReflectRef<'_> { $crate::kind::ReflectRef::Set(self) } - fn reflect_mut(&mut self) -> $crate::kind::ReflectMut { + fn reflect_mut(&mut self) -> $crate::kind::ReflectMut<'_> { $crate::kind::ReflectMut::Set(self) } diff --git a/crates/bevy_reflect/src/impls/smallvec.rs b/crates/bevy_reflect/src/impls/smallvec.rs index 86b7284381c39..21e5240683178 100644 --- a/crates/bevy_reflect/src/impls/smallvec.rs +++ b/crates/bevy_reflect/src/impls/smallvec.rs @@ -67,7 +67,7 @@ where >::len(self) } - fn iter(&self) -> ListIter { + fn iter(&self) -> ListIter<'_> { ListIter::new(self) } @@ -123,11 +123,11 @@ where ReflectKind::List } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::List(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::List(self) } diff --git a/crates/bevy_reflect/src/impls/std/path.rs b/crates/bevy_reflect/src/impls/std/path.rs index a669068ae3aa4..7444ef15c0bb4 100644 --- a/crates/bevy_reflect/src/impls/std/path.rs +++ b/crates/bevy_reflect/src/impls/std/path.rs @@ -63,11 +63,11 @@ impl PartialReflect for &'static Path { ReflectKind::Opaque } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef <'_> { ReflectRef::Opaque(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut <'_> { ReflectMut::Opaque(self) } @@ -194,11 +194,11 @@ impl PartialReflect for Cow<'static, Path> { ReflectKind::Opaque } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef <'_> { ReflectRef::Opaque(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut <'_> { ReflectMut::Opaque(self) } diff --git a/crates/bevy_reflect/src/list.rs b/crates/bevy_reflect/src/list.rs index 4ecdb632755d8..783eca12976d2 100644 --- a/crates/bevy_reflect/src/list.rs +++ b/crates/bevy_reflect/src/list.rs @@ -95,7 +95,7 @@ pub trait List: PartialReflect { } /// Returns an iterator over the list. - fn iter(&self) -> ListIter; + fn iter(&self) -> ListIter<'_>; /// Drain the elements of this list to get a vector of owned values. /// @@ -238,7 +238,7 @@ impl List for DynamicList { self.values.len() } - fn iter(&self) -> ListIter { + fn iter(&self) -> ListIter<'_> { ListIter::new(self) } @@ -294,12 +294,12 @@ impl PartialReflect for DynamicList { } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::List(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::List(self) } @@ -382,7 +382,7 @@ pub struct ListIter<'a> { impl ListIter<'_> { /// Creates a new [`ListIter`]. #[inline] - pub const fn new(list: &dyn List) -> ListIter { + pub const fn new(list: &dyn List) -> ListIter<'_> { ListIter { list, index: 0 } } } diff --git a/crates/bevy_reflect/src/map.rs b/crates/bevy_reflect/src/map.rs index e7178692023e2..c2264ecf2d3d0 100644 --- a/crates/bevy_reflect/src/map.rs +++ b/crates/bevy_reflect/src/map.rs @@ -375,11 +375,11 @@ impl PartialReflect for DynamicMap { ReflectKind::Map } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Map(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Map(self) } diff --git a/crates/bevy_reflect/src/path/error.rs b/crates/bevy_reflect/src/path/error.rs index 00188a4cc37b0..3287333b89f31 100644 --- a/crates/bevy_reflect/src/path/error.rs +++ b/crates/bevy_reflect/src/path/error.rs @@ -64,7 +64,7 @@ impl<'a> AccessError<'a> { } /// The returns the [`Access`] that this [`AccessError`] occurred in. - pub const fn access(&self) -> &Access { + pub const fn access(&self) -> &Access<'_> { &self.access } diff --git a/crates/bevy_reflect/src/path/mod.rs b/crates/bevy_reflect/src/path/mod.rs index f0434686eef4f..fad18746c27b5 100644 --- a/crates/bevy_reflect/src/path/mod.rs +++ b/crates/bevy_reflect/src/path/mod.rs @@ -414,7 +414,7 @@ impl ParsedPath { /// /// assert_eq!(parsed_path.element::(&foo).unwrap(), &123); /// ``` - pub fn parse(string: &str) -> PathResult { + pub fn parse(string: &str) -> PathResult<'_, Self> { let mut parts = Vec::new(); for (access, offset) in PathParser::new(string) { parts.push(OffsetAccess { diff --git a/crates/bevy_reflect/src/reflect.rs b/crates/bevy_reflect/src/reflect.rs index ffe9be54fef1f..1c86d8d4d2841 100644 --- a/crates/bevy_reflect/src/reflect.rs +++ b/crates/bevy_reflect/src/reflect.rs @@ -226,12 +226,12 @@ where /// Returns an immutable enumeration of "kinds" of type. /// /// See [`ReflectRef`]. - fn reflect_ref(&self) -> ReflectRef; + fn reflect_ref(&self) -> ReflectRef<'_>; /// Returns a mutable enumeration of "kinds" of type. /// /// See [`ReflectMut`]. - fn reflect_mut(&mut self) -> ReflectMut; + fn reflect_mut(&mut self) -> ReflectMut<'_>; /// Returns an owned enumeration of "kinds" of type. /// diff --git a/crates/bevy_reflect/src/set.rs b/crates/bevy_reflect/src/set.rs index e464ee4aab699..a49ee03cd86bb 100644 --- a/crates/bevy_reflect/src/set.rs +++ b/crates/bevy_reflect/src/set.rs @@ -301,11 +301,11 @@ impl PartialReflect for DynamicSet { ReflectKind::Set } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Set(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Set(self) } diff --git a/crates/bevy_reflect/src/struct_trait.rs b/crates/bevy_reflect/src/struct_trait.rs index e419947b3ab5a..46c7a546fab42 100644 --- a/crates/bevy_reflect/src/struct_trait.rs +++ b/crates/bevy_reflect/src/struct_trait.rs @@ -69,7 +69,7 @@ pub trait Struct: PartialReflect { fn field_len(&self) -> usize; /// Returns an iterator over the values of the reflectable fields for this struct. - fn iter_fields(&self) -> FieldIter; + fn iter_fields(&self) -> FieldIter<'_>; /// Creates a new [`DynamicStruct`] from this struct. fn to_dynamic_struct(&self) -> DynamicStruct { @@ -371,7 +371,7 @@ impl Struct for DynamicStruct { } #[inline] - fn iter_fields(&self) -> FieldIter { + fn iter_fields(&self) -> FieldIter<'_> { FieldIter { struct_val: self, index: 0, @@ -429,12 +429,12 @@ impl PartialReflect for DynamicStruct { } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Struct(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Struct(self) } diff --git a/crates/bevy_reflect/src/tuple.rs b/crates/bevy_reflect/src/tuple.rs index 97da69b5e2c73..fce437292bea9 100644 --- a/crates/bevy_reflect/src/tuple.rs +++ b/crates/bevy_reflect/src/tuple.rs @@ -50,7 +50,7 @@ pub trait Tuple: PartialReflect { fn field_len(&self) -> usize; /// Returns an iterator over the values of the tuple's fields. - fn iter_fields(&self) -> TupleFieldIter; + fn iter_fields(&self) -> TupleFieldIter<'_>; /// Drain the fields of this tuple to get a vector of owned values. fn drain(self: Box) -> Vec>; @@ -264,7 +264,7 @@ impl Tuple for DynamicTuple { } #[inline] - fn iter_fields(&self) -> TupleFieldIter { + fn iter_fields(&self) -> TupleFieldIter<'_> { TupleFieldIter { tuple: self, index: 0, @@ -318,12 +318,12 @@ impl PartialReflect for DynamicTuple { } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::Tuple(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::Tuple(self) } @@ -493,7 +493,7 @@ macro_rules! impl_reflect_tuple { } #[inline] - fn iter_fields(&self) -> TupleFieldIter { + fn iter_fields(&self) -> TupleFieldIter<'_> { TupleFieldIter { tuple: self, index: 0, @@ -542,11 +542,11 @@ macro_rules! impl_reflect_tuple { ReflectKind::Tuple } - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef <'_> { ReflectRef::Tuple(self) } - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut <'_> { ReflectMut::Tuple(self) } diff --git a/crates/bevy_reflect/src/tuple_struct.rs b/crates/bevy_reflect/src/tuple_struct.rs index cceab9904e91a..f2eb4ae3adef2 100644 --- a/crates/bevy_reflect/src/tuple_struct.rs +++ b/crates/bevy_reflect/src/tuple_struct.rs @@ -53,7 +53,7 @@ pub trait TupleStruct: PartialReflect { fn field_len(&self) -> usize; /// Returns an iterator over the values of the tuple struct's fields. - fn iter_fields(&self) -> TupleStructFieldIter; + fn iter_fields(&self) -> TupleStructFieldIter<'_>; /// Creates a new [`DynamicTupleStruct`] from this tuple struct. fn to_dynamic_tuple_struct(&self) -> DynamicTupleStruct { @@ -278,7 +278,7 @@ impl TupleStruct for DynamicTupleStruct { } #[inline] - fn iter_fields(&self) -> TupleStructFieldIter { + fn iter_fields(&self) -> TupleStructFieldIter<'_> { TupleStructFieldIter { tuple_struct: self, index: 0, @@ -337,12 +337,12 @@ impl PartialReflect for DynamicTupleStruct { } #[inline] - fn reflect_ref(&self) -> ReflectRef { + fn reflect_ref(&self) -> ReflectRef<'_> { ReflectRef::TupleStruct(self) } #[inline] - fn reflect_mut(&mut self) -> ReflectMut { + fn reflect_mut(&mut self) -> ReflectMut<'_> { ReflectMut::TupleStruct(self) } diff --git a/crates/bevy_reflect/src/type_info.rs b/crates/bevy_reflect/src/type_info.rs index 122ace029364d..cc70fb5eb67db 100644 --- a/crates/bevy_reflect/src/type_info.rs +++ b/crates/bevy_reflect/src/type_info.rs @@ -69,8 +69,8 @@ use thiserror::Error; /// # fn try_as_reflect(&self) -> Option<&dyn Reflect> { todo!() } /// # fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect> { todo!() } /// # fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError> { todo!() } -/// # fn reflect_ref(&self) -> ReflectRef { todo!() } -/// # fn reflect_mut(&mut self) -> ReflectMut { todo!() } +/// # fn reflect_ref(&self) -> ReflectRef <'_> { todo!() } +/// # fn reflect_mut(&mut self) -> ReflectMut <'_> { todo!() } /// # fn reflect_owned(self: Box) -> ReflectOwned { todo!() } /// # } /// # impl Reflect for MyStruct { diff --git a/crates/bevy_reflect/src/type_info_stack.rs b/crates/bevy_reflect/src/type_info_stack.rs index cdc19244de295..940bf4b6eafe7 100644 --- a/crates/bevy_reflect/src/type_info_stack.rs +++ b/crates/bevy_reflect/src/type_info_stack.rs @@ -30,7 +30,7 @@ impl TypeInfoStack { } /// Get an iterator over the stack in the order they were pushed. - pub fn iter(&self) -> Iter<&'static TypeInfo> { + pub fn iter(&self) -> Iter<'_, &'static TypeInfo> { self.stack.iter() } } diff --git a/crates/bevy_reflect/src/utility.rs b/crates/bevy_reflect/src/utility.rs index db8416bd6cbe1..1790f2545116b 100644 --- a/crates/bevy_reflect/src/utility.rs +++ b/crates/bevy_reflect/src/utility.rs @@ -86,8 +86,8 @@ mod sealed { /// # fn try_as_reflect(&self) -> Option<&dyn Reflect> { todo!() } /// # fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect> { todo!() } /// # fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError> { todo!() } -/// # fn reflect_ref(&self) -> ReflectRef { todo!() } -/// # fn reflect_mut(&mut self) -> ReflectMut { todo!() } +/// # fn reflect_ref(&self) -> ReflectRef <'_> { todo!() } +/// # fn reflect_mut(&mut self) -> ReflectMut <'_> { todo!() } /// # fn reflect_owned(self: Box) -> ReflectOwned { todo!() } /// # } /// # impl Reflect for Foo { @@ -173,8 +173,8 @@ impl Default for NonGenericTypeCell { /// # fn try_as_reflect(&self) -> Option<&dyn Reflect> { todo!() } /// # fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect> { todo!() } /// # fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError> { todo!() } -/// # fn reflect_ref(&self) -> ReflectRef { todo!() } -/// # fn reflect_mut(&mut self) -> ReflectMut { todo!() } +/// # fn reflect_ref(&self) -> ReflectRef <'_> { todo!() } +/// # fn reflect_mut(&mut self) -> ReflectMut <'_> { todo!() } /// # fn reflect_owned(self: Box) -> ReflectOwned { todo!() } /// # } /// # impl Reflect for Foo { diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index c8a0f1817e65c..35671a84e0ef9 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -1185,7 +1185,7 @@ where /// Returns the binding of the buffer that contains the per-instance data. /// /// This buffer needs to be filled in via a compute shader. - pub fn instance_data_binding(&self) -> Option { + pub fn instance_data_binding(&self) -> Option> { self.data_buffer .buffer() .map(|buffer| buffer.as_entire_binding()) diff --git a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs index 8bbbff8dd9e46..a6127255911bd 100644 --- a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs @@ -42,7 +42,7 @@ where /// /// If we're in the GPU instance buffer building mode, this buffer needs to /// be filled in via a compute shader. - pub fn instance_data_binding(&self) -> Option { + pub fn instance_data_binding(&self) -> Option> { self.binding() } } diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index bbdb543116b6e..3746acbbc4f3d 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -384,7 +384,7 @@ impl MeshAllocator { /// the mesh with the given ID. /// /// If the mesh wasn't allocated, returns None. - pub fn mesh_vertex_slice(&self, mesh_id: &AssetId) -> Option { + pub fn mesh_vertex_slice(&self, mesh_id: &AssetId) -> Option> { self.mesh_slice_in_slab(mesh_id, *self.mesh_id_to_vertex_slab.get(mesh_id)?) } @@ -392,7 +392,7 @@ impl MeshAllocator { /// the mesh with the given ID. /// /// If the mesh has no index data or wasn't allocated, returns None. - pub fn mesh_index_slice(&self, mesh_id: &AssetId) -> Option { + pub fn mesh_index_slice(&self, mesh_id: &AssetId) -> Option> { self.mesh_slice_in_slab(mesh_id, *self.mesh_id_to_index_slab.get(mesh_id)?) } @@ -415,7 +415,7 @@ impl MeshAllocator { &self, mesh_id: &AssetId, slab_id: SlabId, - ) -> Option { + ) -> Option> { match self.slabs.get(&slab_id)? { Slab::General(general_slab) => { let slab_allocation = general_slab.resident_allocations.get(mesh_id)?; diff --git a/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs b/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs index fecc90feac1a4..ad36839398715 100644 --- a/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs +++ b/crates/bevy_render/src/render_resource/batched_uniform_buffer.rs @@ -109,7 +109,7 @@ impl BatchedUniformBuffer { } #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { let mut binding = self.uniforms.binding(); if let Some(BindingResource::Buffer(binding)) = &mut binding { // MaxCapacityArray is runtime-sized so can't use T::min_size() diff --git a/crates/bevy_render/src/render_resource/bind_group.rs b/crates/bevy_render/src/render_resource/bind_group.rs index 1772c0082e8a4..3d808b31c4a3b 100644 --- a/crates/bevy_render/src/render_resource/bind_group.rs +++ b/crates/bevy_render/src/render_resource/bind_group.rs @@ -659,7 +659,7 @@ impl OwnedBindingResource { /// [`OwnedBindingResource::Data`], because [`OwnedData`] doesn't itself /// correspond to any binding and instead requires the /// `MaterialBindGroupAllocator` to pack it into a buffer. - pub fn get_binding(&self) -> BindingResource { + pub fn get_binding(&self) -> BindingResource<'_> { match self { OwnedBindingResource::Buffer(buffer) => buffer.as_entire_binding(), OwnedBindingResource::TextureView(_, view) => BindingResource::TextureView(view), diff --git a/crates/bevy_render/src/render_resource/buffer.rs b/crates/bevy_render/src/render_resource/buffer.rs index 811930da83667..22b8a933e0118 100644 --- a/crates/bevy_render/src/render_resource/buffer.rs +++ b/crates/bevy_render/src/render_resource/buffer.rs @@ -16,7 +16,7 @@ impl Buffer { self.id } - pub fn slice(&self, bounds: impl RangeBounds) -> BufferSlice { + pub fn slice(&self, bounds: impl RangeBounds) -> BufferSlice<'_> { // need to compute and store this manually because wgpu doesn't export offset and size on wgpu::BufferSlice let offset = match bounds.start_bound() { Bound::Included(&bound) => bound, diff --git a/crates/bevy_render/src/render_resource/buffer_vec.rs b/crates/bevy_render/src/render_resource/buffer_vec.rs index 1fdb26655dd45..e51f78cbc13e4 100644 --- a/crates/bevy_render/src/render_resource/buffer_vec.rs +++ b/crates/bevy_render/src/render_resource/buffer_vec.rs @@ -68,7 +68,7 @@ impl RawBufferVec { /// Returns the binding for the buffer if the data has been uploaded. #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer( self.buffer()?.as_entire_buffer_binding(), )) @@ -310,7 +310,7 @@ where /// Returns the binding for the buffer if the data has been uploaded. #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer( self.buffer()?.as_entire_buffer_binding(), )) @@ -498,7 +498,7 @@ where /// Returns the binding for the buffer if the data has been uploaded. #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer( self.buffer()?.as_entire_buffer_binding(), )) diff --git a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs index 0c5bf36bf6e35..2c81f56019d94 100644 --- a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs +++ b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs @@ -89,7 +89,7 @@ impl GpuArrayBuffer { } } - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { match self { GpuArrayBuffer::Uniform(buffer) => buffer.binding(), GpuArrayBuffer::Storage(buffer) => buffer.binding(), diff --git a/crates/bevy_render/src/render_resource/storage_buffer.rs b/crates/bevy_render/src/render_resource/storage_buffer.rs index b407e22d8f9e6..dd76f46a9c1c4 100644 --- a/crates/bevy_render/src/render_resource/storage_buffer.rs +++ b/crates/bevy_render/src/render_resource/storage_buffer.rs @@ -76,7 +76,7 @@ impl StorageBuffer { } #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer(BufferBinding { buffer: self.buffer()?, offset: 0, @@ -209,7 +209,7 @@ impl DynamicStorageBuffer { } #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer(BufferBinding { buffer: self.buffer()?, offset: 0, diff --git a/crates/bevy_render/src/render_resource/uniform_buffer.rs b/crates/bevy_render/src/render_resource/uniform_buffer.rs index b7d22972df469..03cfb8c644991 100644 --- a/crates/bevy_render/src/render_resource/uniform_buffer.rs +++ b/crates/bevy_render/src/render_resource/uniform_buffer.rs @@ -78,7 +78,7 @@ impl UniformBuffer { } #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer( self.buffer()?.as_entire_buffer_binding(), )) @@ -213,7 +213,7 @@ impl DynamicUniformBuffer { } #[inline] - pub fn binding(&self) -> Option { + pub fn binding(&self) -> Option> { Some(BindingResource::Buffer(BufferBinding { buffer: self.buffer()?, offset: 0, diff --git a/crates/bevy_render/src/renderer/render_device.rs b/crates/bevy_render/src/renderer/render_device.rs index 6785ad9c997c7..c965a9fb14424 100644 --- a/crates/bevy_render/src/renderer/render_device.rs +++ b/crates/bevy_render/src/renderer/render_device.rs @@ -139,7 +139,7 @@ impl RenderDevice { pub fn create_render_bundle_encoder( &self, desc: &wgpu::RenderBundleEncoderDescriptor, - ) -> wgpu::RenderBundleEncoder { + ) -> wgpu::RenderBundleEncoder<'_> { self.device.create_render_bundle_encoder(desc) } diff --git a/crates/bevy_render/src/texture/texture_attachment.rs b/crates/bevy_render/src/texture/texture_attachment.rs index 17ae6ea6c957f..cf0e057db0f21 100644 --- a/crates/bevy_render/src/texture/texture_attachment.rs +++ b/crates/bevy_render/src/texture/texture_attachment.rs @@ -34,7 +34,7 @@ impl ColorAttachment { /// `clear_color` if this is the first time calling this function, otherwise it will be loaded. /// /// The returned attachment will always have writing enabled (`store: StoreOp::Load`). - pub fn get_attachment(&self) -> RenderPassColorAttachment { + pub fn get_attachment(&self) -> RenderPassColorAttachment<'_> { if let Some(resolve_target) = self.resolve_target.as_ref() { let first_call = self.is_first_call.fetch_and(false, Ordering::SeqCst); @@ -59,7 +59,7 @@ impl ColorAttachment { /// a value of `clear_color` if this is the first time calling this function, otherwise it will be loaded. /// /// The returned attachment will always have writing enabled (`store: StoreOp::Load`). - pub fn get_unsampled_attachment(&self) -> RenderPassColorAttachment { + pub fn get_unsampled_attachment(&self) -> RenderPassColorAttachment<'_> { let first_call = self.is_first_call.fetch_and(false, Ordering::SeqCst); RenderPassColorAttachment { @@ -101,7 +101,7 @@ impl DepthAttachment { /// Get this texture view as an attachment. The attachment will be cleared with a value of /// `clear_value` if this is the first time calling this function with `store` == [`StoreOp::Store`], /// and a clear value was provided, otherwise it will be loaded. - pub fn get_attachment(&self, store: StoreOp) -> RenderPassDepthStencilAttachment { + pub fn get_attachment(&self, store: StoreOp) -> RenderPassDepthStencilAttachment<'_> { let first_call = self .is_first_call .fetch_and(store != StoreOp::Store, Ordering::SeqCst); @@ -143,7 +143,7 @@ impl OutputColorAttachment { /// Get this texture view as an attachment. The attachment will be cleared with a value of /// the provided `clear_color` if this is the first time calling this function, otherwise it /// will be loaded. - pub fn get_attachment(&self, clear_color: Option) -> RenderPassColorAttachment { + pub fn get_attachment(&self, clear_color: Option) -> RenderPassColorAttachment<'_> { let first_call = self.is_first_call.fetch_and(false, Ordering::SeqCst); RenderPassColorAttachment { diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index cb46c9215a085..2ffe9a24cbe3d 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -725,7 +725,7 @@ impl ViewTarget { pub const TEXTURE_FORMAT_HDR: TextureFormat = TextureFormat::Rgba16Float; /// Retrieve this target's main texture's color attachment. - pub fn get_color_attachment(&self) -> RenderPassColorAttachment { + pub fn get_color_attachment(&self) -> RenderPassColorAttachment<'_> { if self.main_texture.load(Ordering::SeqCst) == 0 { self.main_textures.a.get_attachment() } else { @@ -734,7 +734,7 @@ impl ViewTarget { } /// Retrieve this target's "unsampled" main texture's color attachment. - pub fn get_unsampled_color_attachment(&self) -> RenderPassColorAttachment { + pub fn get_unsampled_color_attachment(&self) -> RenderPassColorAttachment<'_> { if self.main_texture.load(Ordering::SeqCst) == 0 { self.main_textures.a.get_unsampled_attachment() } else { @@ -826,7 +826,7 @@ impl ViewTarget { pub fn out_texture_color_attachment( &self, clear_color: Option, - ) -> RenderPassColorAttachment { + ) -> RenderPassColorAttachment<'_> { self.out_texture.get_attachment(clear_color) } @@ -843,7 +843,7 @@ impl ViewTarget { /// [`ViewTarget`]'s main texture to the `destination` texture, so the caller /// _must_ ensure `source` is copied to `destination`, with or without modifications. /// Failing to do so will cause the current main texture information to be lost. - pub fn post_process_write(&self) -> PostProcessWrite { + pub fn post_process_write(&self) -> PostProcessWrite<'_> { let old_is_a_main_texture = self.main_texture.fetch_xor(1, Ordering::SeqCst); // if the old main texture is a, then the post processing must write from a to b if old_is_a_main_texture == 0 { @@ -880,7 +880,7 @@ impl ViewDepthTexture { } } - pub fn get_attachment(&self, store: StoreOp) -> RenderPassDepthStencilAttachment { + pub fn get_attachment(&self, store: StoreOp) -> RenderPassDepthStencilAttachment<'_> { self.attachment.get_attachment(store) } diff --git a/crates/bevy_shader/src/shader_cache.rs b/crates/bevy_shader/src/shader_cache.rs index 5974209cb522e..d9f402f4282e4 100644 --- a/crates/bevy_shader/src/shader_cache.rs +++ b/crates/bevy_shader/src/shader_cache.rs @@ -401,7 +401,7 @@ impl<'a> wesl::Resolver for ShaderResolver<'a> { fn resolve_source( &self, module_path: &wesl::syntax::ModulePath, - ) -> Result, wesl::ResolveError> { + ) -> Result, wesl::ResolveError> { let asset_id = self.asset_paths.get(module_path).ok_or_else(|| { wesl::ResolveError::ModuleNotFound(module_path.clone(), "Invalid asset id".to_string()) })?; diff --git a/crates/bevy_text/src/text_access.rs b/crates/bevy_text/src/text_access.rs index 7aafa28ef63e2..3c1e83c959e3a 100644 --- a/crates/bevy_text/src/text_access.rs +++ b/crates/bevy_text/src/text_access.rs @@ -74,7 +74,7 @@ pub struct TextReader<'w, 's, R: TextRoot> { impl<'w, 's, R: TextRoot> TextReader<'w, 's, R> { /// Returns an iterator over text spans in a text block, starting with the root entity. - pub fn iter(&mut self, root_entity: Entity) -> TextSpanIter { + pub fn iter(&mut self, root_entity: Entity) -> TextSpanIter<'_, R> { let stack = self.scratch.take(); TextSpanIter { @@ -254,7 +254,13 @@ impl<'w, 's, R: TextRoot> TextWriter<'w, 's, R> { &mut self, root_entity: Entity, index: usize, - ) -> Option<(Entity, usize, Mut, Mut, Mut)> { + ) -> Option<( + Entity, + usize, + Mut<'_, String>, + Mut<'_, TextFont>, + Mut<'_, TextColor>, + )> { // Root if index == 0 { let (text, font, color) = self.roots.get_mut(root_entity).ok()?; @@ -321,17 +327,17 @@ impl<'w, 's, R: TextRoot> TextWriter<'w, 's, R> { } /// Gets the text value of a text span within a text block at a specific index in the flattened span list. - pub fn get_text(&mut self, root_entity: Entity, index: usize) -> Option> { + pub fn get_text(&mut self, root_entity: Entity, index: usize) -> Option> { self.get(root_entity, index).map(|(_, _, text, ..)| text) } /// Gets the [`TextFont`] of a text span within a text block at a specific index in the flattened span list. - pub fn get_font(&mut self, root_entity: Entity, index: usize) -> Option> { + pub fn get_font(&mut self, root_entity: Entity, index: usize) -> Option> { self.get(root_entity, index).map(|(_, _, _, font, _)| font) } /// Gets the [`TextColor`] of a text span within a text block at a specific index in the flattened span list. - pub fn get_color(&mut self, root_entity: Entity, index: usize) -> Option> { + pub fn get_color(&mut self, root_entity: Entity, index: usize) -> Option> { self.get(root_entity, index) .map(|(_, _, _, _, color)| color) } @@ -339,21 +345,21 @@ impl<'w, 's, R: TextRoot> TextWriter<'w, 's, R> { /// Gets the text value of a text span within a text block at a specific index in the flattened span list. /// /// Panics if there is no span at the requested index. - pub fn text(&mut self, root_entity: Entity, index: usize) -> Mut { + pub fn text(&mut self, root_entity: Entity, index: usize) -> Mut<'_, String> { self.get_text(root_entity, index).unwrap() } /// Gets the [`TextFont`] of a text span within a text block at a specific index in the flattened span list. /// /// Panics if there is no span at the requested index. - pub fn font(&mut self, root_entity: Entity, index: usize) -> Mut { + pub fn font(&mut self, root_entity: Entity, index: usize) -> Mut<'_, TextFont> { self.get_font(root_entity, index).unwrap() } /// Gets the [`TextColor`] of a text span within a text block at a specific index in the flattened span list. /// /// Panics if there is no span at the requested index. - pub fn color(&mut self, root_entity: Entity, index: usize) -> Mut { + pub fn color(&mut self, root_entity: Entity, index: usize) -> Mut<'_, TextColor> { self.get_color(root_entity, index).unwrap() } diff --git a/crates/bevy_utils/src/debug_info.rs b/crates/bevy_utils/src/debug_info.rs index 71ce96ea0026e..afedfbe7984e8 100644 --- a/crates/bevy_utils/src/debug_info.rs +++ b/crates/bevy_utils/src/debug_info.rs @@ -82,7 +82,7 @@ impl DebugName { /// Get the [`ShortName`] corresponding to this debug name /// /// The value will be a static string if the `debug` feature is not enabled - pub fn shortname(&self) -> ShortName { + pub fn shortname(&self) -> ShortName<'_> { #[cfg(feature = "debug")] return ShortName(self.name.as_ref()); #[cfg(not(feature = "debug"))] diff --git a/crates/bevy_window/src/raw_handle.rs b/crates/bevy_window/src/raw_handle.rs index 0943315055fb6..635b06da7f309 100644 --- a/crates/bevy_window/src/raw_handle.rs +++ b/crates/bevy_window/src/raw_handle.rs @@ -138,7 +138,7 @@ unsafe impl Sync for RawHandleWrapper {} pub struct ThreadLockedRawWindowHandleWrapper(RawHandleWrapper); impl HasWindowHandle for ThreadLockedRawWindowHandleWrapper { - fn window_handle(&self) -> Result { + fn window_handle(&self) -> Result, HandleError> { // SAFETY: the caller has validated that this is a valid context to get [`RawHandleWrapper`] // as otherwise an instance of this type could not have been constructed // NOTE: we cannot simply impl HasRawWindowHandle for RawHandleWrapper, @@ -150,7 +150,7 @@ impl HasWindowHandle for ThreadLockedRawWindowHandleWrapper { } impl HasDisplayHandle for ThreadLockedRawWindowHandleWrapper { - fn display_handle(&self) -> Result { + fn display_handle(&self) -> Result, HandleError> { // SAFETY: the caller has validated that this is a valid context to get [`RawDisplayHandle`] // as otherwise an instance of this type could not have been constructed // NOTE: we cannot simply impl HasRawDisplayHandle for RawHandleWrapper, diff --git a/examples/animation/animated_ui.rs b/examples/animation/animated_ui.rs index 68b0eb7a8fc1f..b227fd37a40a9 100644 --- a/examples/animation/animated_ui.rs +++ b/examples/animation/animated_ui.rs @@ -171,7 +171,7 @@ struct TextColorProperty; impl AnimatableProperty for TextColorProperty { type Property = Srgba; - fn evaluator_id(&self) -> EvaluatorId { + fn evaluator_id(&self) -> EvaluatorId<'_> { EvaluatorId::Type(TypeId::of::()) } diff --git a/examples/ecs/dynamic.rs b/examples/ecs/dynamic.rs index bd993d44139ba..16459a3528ab6 100644 --- a/examples/ecs/dynamic.rs +++ b/examples/ecs/dynamic.rs @@ -197,7 +197,7 @@ fn main() { // Constructs `OwningPtr` for each item in `components` // By sharing the lifetime of `components` with the resulting ptrs we ensure we don't drop the data before use -fn to_owning_ptrs(components: &mut [Vec]) -> Vec> { +fn to_owning_ptrs(components: &mut [Vec]) -> Vec> { components .iter_mut() .map(|data| { From 44aefdb4da928e45805e3230152e2fdcf830673c Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Thu, 7 Aug 2025 18:31:30 -0400 Subject: [PATCH 2/2] Formatting Co-authored-by: Mike --- crates/bevy_reflect/src/type_info.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_reflect/src/type_info.rs b/crates/bevy_reflect/src/type_info.rs index cc70fb5eb67db..0a2db8d57a9ed 100644 --- a/crates/bevy_reflect/src/type_info.rs +++ b/crates/bevy_reflect/src/type_info.rs @@ -69,8 +69,8 @@ use thiserror::Error; /// # fn try_as_reflect(&self) -> Option<&dyn Reflect> { todo!() } /// # fn try_as_reflect_mut(&mut self) -> Option<&mut dyn Reflect> { todo!() } /// # fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError> { todo!() } -/// # fn reflect_ref(&self) -> ReflectRef <'_> { todo!() } -/// # fn reflect_mut(&mut self) -> ReflectMut <'_> { todo!() } +/// # fn reflect_ref(&self) -> ReflectRef<'_> { todo!() } +/// # fn reflect_mut(&mut self) -> ReflectMut<'_> { todo!() } /// # fn reflect_owned(self: Box) -> ReflectOwned { todo!() } /// # } /// # impl Reflect for MyStruct {