From dbd856de71a3a00bfd30bd3113147819b97688a6 Mon Sep 17 00:00:00 2001 From: SarthakSingh31 Date: Tue, 17 May 2022 04:38:03 +0000 Subject: [PATCH] Nightly clippy fixes (#3491) Fixes the following nightly clippy lints: - ~~[map_flatten](https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten)~~ (Fixed on main) - ~~[needless_borrow](https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow)~~ (Fixed on main) - [return_self_not_must_use](https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use) (Added in 1.59.0) - ~~[unnecessary_lazy_evaluations](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations)~~ (Fixed on main) - [extra_unused_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes) outside of macros - [let_unit_value](https://rust-lang.github.io/rust-clippy/master/index.html#let_unit_value) --- crates/bevy_ecs/src/query/fetch.rs | 2 +- crates/bevy_ecs/src/system/system_param.rs | 8 ++++---- crates/bevy_ecs/src/world/world_cell.rs | 2 +- crates/bevy_reflect/src/array.rs | 2 +- crates/bevy_render/src/view/visibility/render_layers.rs | 2 ++ crates/bevy_transform/src/components/global_transform.rs | 3 +++ crates/bevy_transform/src/components/transform.rs | 3 +++ 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 5a89bc5280f63..502d00f0f2eaf 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -840,7 +840,7 @@ impl<'w, T: Component> WorldQueryGats<'w> for &mut T { type _State = WriteState; } -impl<'w, 's, T: Component> Fetch<'w> for WriteFetch<'w, T> { +impl<'w, T: Component> Fetch<'w> for WriteFetch<'w, T> { type Item = Mut<'w, T>; type State = WriteState; diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index b56a2e3461d70..8b9cf8349d727 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -510,11 +510,11 @@ unsafe impl ReadOnlySystemParamFetch for WorldState {} #[doc(hidden)] pub struct WorldState; -impl<'w, 's> SystemParam for &'w World { +impl<'w> SystemParam for &'w World { type Fetch = WorldState; } -unsafe impl<'w, 's> SystemParamState for WorldState { +unsafe impl SystemParamState for WorldState { fn init(_world: &mut World, system_meta: &mut SystemMeta) -> Self { let mut access = Access::default(); access.read_all(); @@ -1365,7 +1365,7 @@ impl<'w, 's, P: SystemParam> StaticSystemParam<'w, 's, P> { pub struct StaticSystemParamState(S, PhantomData P>); // Safe: This doesn't add any more reads, and the delegated fetch confirms it -unsafe impl<'w, 's, S: ReadOnlySystemParamFetch, P> ReadOnlySystemParamFetch +unsafe impl ReadOnlySystemParamFetch for StaticSystemParamState { } @@ -1394,7 +1394,7 @@ where } } -unsafe impl<'w, 's, S: SystemParamState, P: SystemParam + 'static> SystemParamState +unsafe impl SystemParamState for StaticSystemParamState { fn init(world: &mut World, system_meta: &mut SystemMeta) -> Self { diff --git a/crates/bevy_ecs/src/world/world_cell.rs b/crates/bevy_ecs/src/world/world_cell.rs index d8256df7d215d..5a1fff6cdf9a2 100644 --- a/crates/bevy_ecs/src/world/world_cell.rs +++ b/crates/bevy_ecs/src/world/world_cell.rs @@ -74,7 +74,7 @@ impl<'w> Drop for WorldCell<'w> { fn drop(&mut self) { let mut access = self.access.borrow_mut(); // give world ArchetypeComponentAccess back to reuse allocations - let _ = std::mem::swap(&mut self.world.archetype_component_access, &mut *access); + std::mem::swap(&mut self.world.archetype_component_access, &mut *access); } } diff --git a/crates/bevy_reflect/src/array.rs b/crates/bevy_reflect/src/array.rs index b4b3e29851ad7..0bbcf271272af 100644 --- a/crates/bevy_reflect/src/array.rs +++ b/crates/bevy_reflect/src/array.rs @@ -210,7 +210,7 @@ impl<'a> Iterator for ArrayIter<'a> { impl<'a> ExactSizeIterator for ArrayIter<'a> {} -impl<'a> serde::Serialize for dyn Array { +impl serde::Serialize for dyn Array { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, diff --git a/crates/bevy_render/src/view/visibility/render_layers.rs b/crates/bevy_render/src/view/visibility/render_layers.rs index c1ac9646a0620..677c0877777ba 100644 --- a/crates/bevy_render/src/view/visibility/render_layers.rs +++ b/crates/bevy_render/src/view/visibility/render_layers.rs @@ -76,6 +76,7 @@ impl RenderLayers { /// /// # Panics /// Panics when called with a layer greater than `TOTAL_LAYERS - 1`. + #[must_use] pub const fn with(mut self, layer: Layer) -> Self { assert!((layer as usize) < Self::TOTAL_LAYERS); self.0 |= 1 << layer; @@ -86,6 +87,7 @@ impl RenderLayers { /// /// # Panics /// Panics when called with a layer greater than `TOTAL_LAYERS - 1`. + #[must_use] pub const fn without(mut self, layer: Layer) -> Self { assert!((layer as usize) < Self::TOTAL_LAYERS); self.0 &= !(1 << layer); diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index 6bddfead5ad74..be1d75cfcb46b 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -102,6 +102,7 @@ impl GlobalTransform { #[doc(hidden)] #[inline] + #[must_use] pub const fn with_translation(mut self, translation: Vec3) -> Self { self.translation = translation; self @@ -109,6 +110,7 @@ impl GlobalTransform { #[doc(hidden)] #[inline] + #[must_use] pub const fn with_rotation(mut self, rotation: Quat) -> Self { self.rotation = rotation; self @@ -116,6 +118,7 @@ impl GlobalTransform { #[doc(hidden)] #[inline] + #[must_use] pub const fn with_scale(mut self, scale: Vec3) -> Self { self.scale = scale; self diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index c822336d36c8b..bbca98e76961d 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -112,6 +112,7 @@ impl Transform { /// Returns this [`Transform`] with a new translation. #[inline] + #[must_use] pub const fn with_translation(mut self, translation: Vec3) -> Self { self.translation = translation; self @@ -119,6 +120,7 @@ impl Transform { /// Returns this [`Transform`] with a new rotation. #[inline] + #[must_use] pub const fn with_rotation(mut self, rotation: Quat) -> Self { self.rotation = rotation; self @@ -126,6 +128,7 @@ impl Transform { /// Returns this [`Transform`] with a new scale. #[inline] + #[must_use] pub const fn with_scale(mut self, scale: Vec3) -> Self { self.scale = scale; self