From 05fcd0bd0695ffb2b92ab26df0c3c639075495fe Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Thu, 5 Dec 2024 15:55:12 +0100 Subject: [PATCH] fix clippy needless lifetimes (#769) + ignore them for bevy where we often want explicitness --- crates/rapier_testbed2d-f64/Cargo.toml | 3 +++ crates/rapier_testbed2d/Cargo.toml | 3 +++ crates/rapier_testbed3d-f64/Cargo.toml | 3 +++ crates/rapier_testbed3d/Cargo.toml | 3 +++ examples2d/trimesh2.rs | 2 +- src/data/arena.rs | 14 +++++++------- src/data/graph.rs | 10 +++++----- .../contact_constraint/two_body_constraint.rs | 2 +- src/dynamics/solver/interaction_groups.rs | 2 +- .../joint_constraint/any_joint_constraint.rs | 2 +- src/pipeline/physics_hooks.rs | 2 +- src/pipeline/query_pipeline/generators.rs | 6 +++--- src/pipeline/query_pipeline/mod.rs | 8 ++++---- src_testbed/testbed.rs | 4 ++-- 14 files changed, 38 insertions(+), 26 deletions(-) diff --git a/crates/rapier_testbed2d-f64/Cargo.toml b/crates/rapier_testbed2d-f64/Cargo.toml index fab895872..16b65b714 100644 --- a/crates/rapier_testbed2d-f64/Cargo.toml +++ b/crates/rapier_testbed2d-f64/Cargo.toml @@ -41,6 +41,9 @@ unstable-puffin-pr-235 = [] [package.metadata.docs.rs] features = ["parallel", "profiling"] +[lints.clippy] +needless_lifetimes = "allow" + [dependencies] nalgebra = { version = "0.33", features = ["rand", "glam027"] } rand = "0.8" diff --git a/crates/rapier_testbed2d/Cargo.toml b/crates/rapier_testbed2d/Cargo.toml index b95966f3d..f16d5554c 100644 --- a/crates/rapier_testbed2d/Cargo.toml +++ b/crates/rapier_testbed2d/Cargo.toml @@ -41,6 +41,9 @@ unstable-puffin-pr-235 = [] [package.metadata.docs.rs] features = ["parallel", "other-backends", "profiling"] +[lints.clippy] +needless_lifetimes = "allow" + [dependencies] nalgebra = { version = "0.33", features = ["rand", "glam027"] } rand = "0.8" diff --git a/crates/rapier_testbed3d-f64/Cargo.toml b/crates/rapier_testbed3d-f64/Cargo.toml index 97d1a5420..f023d8628 100644 --- a/crates/rapier_testbed3d-f64/Cargo.toml +++ b/crates/rapier_testbed3d-f64/Cargo.toml @@ -43,6 +43,9 @@ unstable-puffin-pr-235 = [] [package.metadata.docs.rs] features = ["parallel", "profiling"] +[lints.clippy] +needless_lifetimes = "allow" + [dependencies] nalgebra = { version = "0.33", features = ["rand", "glam027"] } rand = "0.8" diff --git a/crates/rapier_testbed3d/Cargo.toml b/crates/rapier_testbed3d/Cargo.toml index 2b536abd1..916bdd57a 100644 --- a/crates/rapier_testbed3d/Cargo.toml +++ b/crates/rapier_testbed3d/Cargo.toml @@ -41,6 +41,9 @@ unstable-puffin-pr-235 = [] [package.metadata.docs.rs] features = ["parallel", "other-backends", "profiling"] +[lints.clippy] +needless_lifetimes = "allow" + [dependencies] nalgebra = { version = "0.33", features = ["rand", "glam027"] } rand = "0.8" diff --git a/examples2d/trimesh2.rs b/examples2d/trimesh2.rs index a295db552..a57c0fe08 100644 --- a/examples2d/trimesh2.rs +++ b/examples2d/trimesh2.rs @@ -143,7 +143,7 @@ pub struct PathConvIter<'a> { deferred: Option, } -impl<'l> Iterator for PathConvIter<'l> { +impl Iterator for PathConvIter<'_> { type Item = PathEvent; fn next(&mut self) -> Option { if self.deferred.is_some() { diff --git a/src/data/arena.rs b/src/data/arena.rs index 57653da9b..a7869a627 100644 --- a/src/data/arena.rs +++ b/src/data/arena.rs @@ -965,7 +965,7 @@ impl<'a, T> Iterator for Iter<'a, T> { } } -impl<'a, T> DoubleEndedIterator for Iter<'a, T> { +impl DoubleEndedIterator for Iter<'_, T> { fn next_back(&mut self) -> Option { loop { match self.inner.next_back() { @@ -993,13 +993,13 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } } -impl<'a, T> ExactSizeIterator for Iter<'a, T> { +impl ExactSizeIterator for Iter<'_, T> { fn len(&self) -> usize { self.len } } -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} impl<'a, T> IntoIterator for &'a mut Arena { type Item = (Index, &'a mut T); @@ -1069,7 +1069,7 @@ impl<'a, T> Iterator for IterMut<'a, T> { } } -impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { +impl DoubleEndedIterator for IterMut<'_, T> { fn next_back(&mut self) -> Option { loop { match self.inner.next_back() { @@ -1097,13 +1097,13 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> { } } -impl<'a, T> ExactSizeIterator for IterMut<'a, T> { +impl ExactSizeIterator for IterMut<'_, T> { fn len(&self) -> usize { self.len } } -impl<'a, T> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} /// An iterator that removes elements from the arena. /// @@ -1135,7 +1135,7 @@ pub struct Drain<'a, T: 'a> { inner: iter::Enumerate>>, } -impl<'a, T> Iterator for Drain<'a, T> { +impl Iterator for Drain<'_, T> { type Item = (Index, T); fn next(&mut self) -> Option { diff --git a/src/data/graph.rs b/src/data/graph.rs index 8f38dae00..4620b8850 100644 --- a/src/data/graph.rs +++ b/src/data/graph.rs @@ -531,7 +531,7 @@ fn edges_walker_mut( EdgesWalkerMut { edges, next, dir } } -impl<'a, E> EdgesWalkerMut<'a, E> { +impl EdgesWalkerMut<'_, E> { fn next_edge(&mut self) -> Option<&mut Edge> { self.next().map(|t| t.1) } @@ -630,7 +630,7 @@ impl<'a, E> Iterator for Edges<'a, E> { // x // } -impl<'a, E> Clone for Edges<'a, E> { +impl Clone for Edges<'_, E> { fn clone(&self) -> Self { Edges { skip_start: self.skip_start, @@ -699,15 +699,15 @@ impl<'a, E: 'a> EdgeReference<'a, E> { } } -impl<'a, E> Clone for EdgeReference<'a, E> { +impl Clone for EdgeReference<'_, E> { fn clone(&self) -> Self { *self } } -impl<'a, E> Copy for EdgeReference<'a, E> {} +impl Copy for EdgeReference<'_, E> {} -impl<'a, E> PartialEq for EdgeReference<'a, E> +impl PartialEq for EdgeReference<'_, E> where E: PartialEq, { diff --git a/src/dynamics/solver/contact_constraint/two_body_constraint.rs b/src/dynamics/solver/contact_constraint/two_body_constraint.rs index d2a2c4940..9adcd5453 100644 --- a/src/dynamics/solver/contact_constraint/two_body_constraint.rs +++ b/src/dynamics/solver/contact_constraint/two_body_constraint.rs @@ -11,7 +11,7 @@ use na::{DVector, Matrix2}; use super::{TwoBodyConstraintElement, TwoBodyConstraintNormalPart}; -impl<'a> AnyConstraintMut<'a, ContactConstraintTypes> { +impl AnyConstraintMut<'_, ContactConstraintTypes> { pub fn remove_bias(&mut self) { match self { Self::OneBody(c) => c.remove_cfm_and_bias_from_rhs(), diff --git a/src/dynamics/solver/interaction_groups.rs b/src/dynamics/solver/interaction_groups.rs index 13d66550d..521b7a204 100644 --- a/src/dynamics/solver/interaction_groups.rs +++ b/src/dynamics/solver/interaction_groups.rs @@ -18,7 +18,7 @@ pub(crate) trait PairInteraction { use crate::dynamics::RigidBodyType; #[cfg(feature = "parallel")] -impl<'a> PairInteraction for &'a mut ContactManifold { +impl PairInteraction for &mut ContactManifold { fn body_pair(&self) -> (Option, Option) { (self.data.rigid_body1, self.data.rigid_body2) } diff --git a/src/dynamics/solver/joint_constraint/any_joint_constraint.rs b/src/dynamics/solver/joint_constraint/any_joint_constraint.rs index 8cbd438be..c93abc7c4 100644 --- a/src/dynamics/solver/joint_constraint/any_joint_constraint.rs +++ b/src/dynamics/solver/joint_constraint/any_joint_constraint.rs @@ -27,7 +27,7 @@ use crate::dynamics::solver::joint_constraint::joint_constraint_builder::{ pub struct JointConstraintTypes; -impl<'a> AnyConstraintMut<'a, JointConstraintTypes> { +impl AnyConstraintMut<'_, JointConstraintTypes> { pub fn remove_bias(&mut self) { match self { Self::OneBody(c) => c.remove_bias_from_rhs(), diff --git a/src/pipeline/physics_hooks.rs b/src/pipeline/physics_hooks.rs index 8df11cba1..10d96cd24 100644 --- a/src/pipeline/physics_hooks.rs +++ b/src/pipeline/physics_hooks.rs @@ -45,7 +45,7 @@ pub struct ContactModificationContext<'a> { pub user_data: &'a mut u32, } -impl<'a> ContactModificationContext<'a> { +impl ContactModificationContext<'_> { /// Helper function to update `self` to emulate a oneway-platform. /// /// The "oneway" behavior will only allow contacts between two colliders diff --git a/src/pipeline/query_pipeline/generators.rs b/src/pipeline/query_pipeline/generators.rs index 5e5146b87..4a08bbf52 100644 --- a/src/pipeline/query_pipeline/generators.rs +++ b/src/pipeline/query_pipeline/generators.rs @@ -30,7 +30,7 @@ pub struct SweptAabbWithPredictedPosition<'a> { /// You probably want to set it to [`IntegrationParameters::dt`]. pub dt: Real, } -impl<'a> QbvhDataGenerator for SweptAabbWithPredictedPosition<'a> { +impl QbvhDataGenerator for SweptAabbWithPredictedPosition<'_> { fn size_hint(&self) -> usize { self.colliders.len() } @@ -68,7 +68,7 @@ pub struct SweptAabbWithNextPosition<'a> { pub colliders: &'a ColliderSet, } -impl<'a> QbvhDataGenerator for SweptAabbWithNextPosition<'a> { +impl QbvhDataGenerator for SweptAabbWithNextPosition<'_> { fn size_hint(&self) -> usize { self.colliders.len() } @@ -96,7 +96,7 @@ pub struct CurrentAabb<'a> { pub colliders: &'a ColliderSet, } -impl<'a> QbvhDataGenerator for CurrentAabb<'a> { +impl QbvhDataGenerator for CurrentAabb<'_> { fn size_hint(&self) -> usize { self.colliders.len() } diff --git a/src/pipeline/query_pipeline/mod.rs b/src/pipeline/query_pipeline/mod.rs index 6d41f4f31..06a5e2fe1 100644 --- a/src/pipeline/query_pipeline/mod.rs +++ b/src/pipeline/query_pipeline/mod.rs @@ -119,7 +119,7 @@ pub struct QueryFilter<'a> { pub predicate: Option<&'a dyn Fn(ColliderHandle, &Collider) -> bool>, } -impl<'a> QueryFilter<'a> { +impl QueryFilter<'_> { /// Applies the filters described by `self` to a collider to determine if it has to be /// included in a scene query (`true`) or not (`false`). #[inline] @@ -136,7 +136,7 @@ impl<'a> QueryFilter<'a> { } } -impl<'a> From for QueryFilter<'a> { +impl From for QueryFilter<'_> { fn from(flags: QueryFilterFlags) -> Self { Self { flags, @@ -145,7 +145,7 @@ impl<'a> From for QueryFilter<'a> { } } -impl<'a> From for QueryFilter<'a> { +impl From for QueryFilter<'_> { fn from(groups: InteractionGroups) -> Self { Self { groups: Some(groups), @@ -229,7 +229,7 @@ impl<'a> QueryFilter<'a> { } } -impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> { +impl TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'_> { type PartShape = dyn Shape; type PartNormalConstraints = dyn NormalConstraints; type PartId = ColliderHandle; diff --git a/src_testbed/testbed.rs b/src_testbed/testbed.rs index fa7f731d4..9f1bf202d 100644 --- a/src_testbed/testbed.rs +++ b/src_testbed/testbed.rs @@ -469,7 +469,7 @@ impl TestbedApp { } } -impl<'a, 'b, 'c, 'd, 'e, 'f> TestbedGraphics<'a, 'b, 'c, 'd, 'e, 'f> { +impl TestbedGraphics<'_, '_, '_, '_, '_, '_> { pub fn set_body_color(&mut self, body: RigidBodyHandle, color: [f32; 3]) { self.graphics.set_body_color(self.materials, body, color); } @@ -526,7 +526,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> TestbedGraphics<'a, 'b, 'c, 'd, 'e, 'f> { } } -impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> { +impl Testbed<'_, '_, '_, '_, '_, '_> { pub fn set_number_of_steps_per_frame(&mut self, nsteps: usize) { self.state.nsteps = nsteps }