From d5b963462dfe3bc0825ac8691ad8316bb006a230 Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Fri, 29 Nov 2024 01:02:44 +0200 Subject: [PATCH 1/2] Fix new Rust 1.83.0 lints (#569) # Objective Rust 1.83.0 was just released, and CI is complaining because of new lints, mainly for ellided lifetimes. ## Solution Fix lints! --- src/collision/collider/backend.rs | 1 - src/collision/collider/world_query.rs | 2 +- src/collision/narrow_phase.rs | 2 +- src/debug_render/gizmos.rs | 2 +- .../rigid_body/mass_properties/world_query.rs | 6 +++--- src/dynamics/rigid_body/world_query.rs | 4 ++-- src/spatial_query/pipeline.rs | 12 ++++++------ src/spatial_query/system_param.rs | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/collision/collider/backend.rs b/src/collision/collider/backend.rs index 37d23d55..99877ca1 100644 --- a/src/collision/collider/backend.rs +++ b/src/collision/collider/backend.rs @@ -57,7 +57,6 @@ use mass_properties::OnChangeColliderMassProperties; /// it should now work with the rest of the engine just like normal [`Collider`]s! /// /// **Note**: [Spatial queries](spatial_query) are not supported for custom colliders yet. - pub struct ColliderBackendPlugin { schedule: Interned, _phantom: PhantomData, diff --git a/src/collision/collider/world_query.rs b/src/collision/collider/world_query.rs index 0d0b3989..19501578 100644 --- a/src/collision/collider/world_query.rs +++ b/src/collision/collider/world_query.rs @@ -25,7 +25,7 @@ pub struct ColliderQuery { pub shape: &'static C, } -impl<'w, C: AnyCollider> ColliderQueryItem<'w, C> { +impl ColliderQueryItem<'_, C> { /// Returns the current position of the body. This is a sum of the [`Position`] and /// [`AccumulatedTranslation`] components. pub fn current_position(&self) -> Vector { diff --git a/src/collision/narrow_phase.rs b/src/collision/narrow_phase.rs index 1d7ebe0f..ca510031 100644 --- a/src/collision/narrow_phase.rs +++ b/src/collision/narrow_phase.rs @@ -385,7 +385,7 @@ pub struct NarrowPhase<'w, 's, C: AnyCollider> { contact_tolerance: Local<'s, Scalar>, } -impl<'w, 's, C: AnyCollider> NarrowPhase<'w, 's, C> { +impl NarrowPhase<'_, '_, C> { /// Updates the narrow phase by computing [`Contacts`] based on [`BroadCollisionPairs`] /// and adding them to [`Collisions`]. fn update(&mut self, broad_collision_pairs: &[(Entity, Entity)], delta_secs: Scalar) { diff --git a/src/debug_render/gizmos.rs b/src/debug_render/gizmos.rs index 65dc2dc6..427b25d4 100644 --- a/src/debug_render/gizmos.rs +++ b/src/debug_render/gizmos.rs @@ -85,7 +85,7 @@ pub trait PhysicsGizmoExt { ); } -impl<'w, 's> PhysicsGizmoExt for Gizmos<'w, 's, PhysicsGizmos> { +impl PhysicsGizmoExt for Gizmos<'_, '_, PhysicsGizmos> { /// Draws a line from `a` to `b`. fn draw_line(&mut self, a: Vector, b: Vector, color: Color) { #[cfg(feature = "2d")] diff --git a/src/dynamics/rigid_body/mass_properties/world_query.rs b/src/dynamics/rigid_body/mass_properties/world_query.rs index 4379234a..83e69a74 100644 --- a/src/dynamics/rigid_body/mass_properties/world_query.rs +++ b/src/dynamics/rigid_body/mass_properties/world_query.rs @@ -17,7 +17,7 @@ pub struct MassPropertiesQuery { pub center_of_mass: &'static mut CenterOfMass, } -impl<'w> MassPropertiesQueryItem<'w> { +impl MassPropertiesQueryItem<'_> { /// Computes the angular inertia shifted by the given offset, taking into account mass. #[cfg(feature = "2d")] #[inline] @@ -49,7 +49,7 @@ impl<'w> MassPropertiesQueryItem<'w> { } } -impl<'w> AddAssign for MassPropertiesQueryItem<'w> { +impl AddAssign for MassPropertiesQueryItem<'_> { fn add_assign(&mut self, rhs: ColliderMassProperties) { let mass1 = self.mass.value(); let mass2 = rhs.mass; @@ -75,7 +75,7 @@ impl<'w> AddAssign for MassPropertiesQueryItem<'w> { } } -impl<'w> SubAssign for MassPropertiesQueryItem<'w> { +impl SubAssign for MassPropertiesQueryItem<'_> { fn sub_assign(&mut self, rhs: ColliderMassProperties) { if self.mass.inverse() + rhs.mass.recip_or_zero() <= 0.0 { return; diff --git a/src/dynamics/rigid_body/world_query.rs b/src/dynamics/rigid_body/world_query.rs index 97af3625..c1cb6f71 100644 --- a/src/dynamics/rigid_body/world_query.rs +++ b/src/dynamics/rigid_body/world_query.rs @@ -34,7 +34,7 @@ pub struct RigidBodyQuery { pub is_sensor: Has, } -impl<'w> RigidBodyQueryItem<'w> { +impl RigidBodyQueryItem<'_> { /// Computes the velocity at the given `point` relative to the center of the body. pub fn velocity_at_point(&self, point: Vector) -> Vector { #[cfg(feature = "2d")] @@ -114,7 +114,7 @@ impl<'w> RigidBodyQueryItem<'w> { } } -impl<'w> RigidBodyQueryReadOnlyItem<'w> { +impl RigidBodyQueryReadOnlyItem<'_> { /// Computes the velocity at the given `point` relative to the center of mass. pub fn velocity_at_point(&self, point: Vector) -> Vector { #[cfg(feature = "2d")] diff --git a/src/spatial_query/pipeline.rs b/src/spatial_query/pipeline.rs index 9055e850..28f0e45e 100644 --- a/src/spatial_query/pipeline.rs +++ b/src/spatial_query/pipeline.rs @@ -52,7 +52,7 @@ impl SpatialQueryPipeline { pub(crate) fn as_composite_shape<'a>( &'a self, query_filter: &'a SpatialQueryFilter, - ) -> QueryPipelineAsCompositeShape { + ) -> QueryPipelineAsCompositeShape<'a> { QueryPipelineAsCompositeShape { pipeline: self, colliders: &self.colliders, @@ -60,11 +60,11 @@ impl SpatialQueryPipeline { } } - pub(crate) fn as_composite_shape_with_predicate<'a>( + pub(crate) fn as_composite_shape_with_predicate<'a: 'b, 'b>( &'a self, query_filter: &'a SpatialQueryFilter, predicate: &'a dyn Fn(Entity) -> bool, - ) -> QueryPipelineAsCompositeShapeWithPredicate { + ) -> QueryPipelineAsCompositeShapeWithPredicate<'a, 'b> { QueryPipelineAsCompositeShapeWithPredicate { pipeline: self, colliders: &self.colliders, @@ -124,7 +124,7 @@ impl SpatialQueryPipeline { &'a HashMap, Collider, CollisionLayers)>, ); - impl<'a> parry::partitioning::QbvhDataGenerator for DataGenerator<'a> { + impl parry::partitioning::QbvhDataGenerator for DataGenerator<'_> { fn size_hint(&self) -> usize { self.0.len() } @@ -812,7 +812,7 @@ pub(crate) struct QueryPipelineAsCompositeShape<'a> { query_filter: &'a SpatialQueryFilter, } -impl<'a> TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'a> { +impl TypedSimdCompositeShape for QueryPipelineAsCompositeShape<'_> { type PartShape = dyn Shape; type PartNormalConstraints = dyn NormalConstraints; type PartId = u32; @@ -858,7 +858,7 @@ pub(crate) struct QueryPipelineAsCompositeShapeWithPredicate<'a, 'b> { predicate: &'b dyn Fn(Entity) -> bool, } -impl<'a, 'b> TypedSimdCompositeShape for QueryPipelineAsCompositeShapeWithPredicate<'a, 'b> { +impl TypedSimdCompositeShape for QueryPipelineAsCompositeShapeWithPredicate<'_, '_> { type PartShape = dyn Shape; type PartNormalConstraints = dyn NormalConstraints; type PartId = u32; diff --git a/src/spatial_query/system_param.rs b/src/spatial_query/system_param.rs index 46635eec..30ec0b1a 100644 --- a/src/spatial_query/system_param.rs +++ b/src/spatial_query/system_param.rs @@ -77,7 +77,7 @@ pub struct SpatialQuery<'w, 's> { pub query_pipeline: ResMut<'w, SpatialQueryPipeline>, } -impl<'w, 's> SpatialQuery<'w, 's> { +impl SpatialQuery<'_, '_> { /// Updates the colliders in the pipeline. This is done automatically once per physics frame in /// [`PhysicsStepSet::SpatialQuery`], but if you modify colliders or their positions before that, you can /// call this to make sure the data is up to date when performing spatial queries using [`SpatialQuery`]. From 52cbcecce0fd05a65005ab6935ebeb231373c2c6 Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Sat, 30 Nov 2024 22:35:30 +0200 Subject: [PATCH 2/2] Migrate from Bevy 0.15 RC to full 0.15 (#570) # Objective The full 0.15 release has a few breaking changes from the release candidate. ## Solution Fix them! Also changed `bevy_mod_debugdump` to use the main branch instead of the 0.15 PR's branch, since it has now been updated. --- crates/avian2d/Cargo.toml | 10 +++++----- .../avian2d/examples/dynamic_character_2d/plugin.rs | 4 ++-- .../examples/kinematic_character_2d/plugin.rs | 4 ++-- crates/avian3d/Cargo.toml | 13 +++++++------ .../avian3d/examples/dynamic_character_3d/plugin.rs | 6 +++--- .../examples/kinematic_character_3d/plugin.rs | 6 +++--- crates/benches_common_2d/Cargo.toml | 2 +- crates/benches_common_3d/Cargo.toml | 2 +- crates/examples_common_2d/Cargo.toml | 3 ++- crates/examples_common_3d/Cargo.toml | 4 +++- 10 files changed, 29 insertions(+), 25 deletions(-) diff --git a/crates/avian2d/Cargo.toml b/crates/avian2d/Cargo.toml index 296fc999..f20d3629 100644 --- a/crates/avian2d/Cargo.toml +++ b/crates/avian2d/Cargo.toml @@ -59,14 +59,14 @@ bench = false [dependencies] avian_derive = { path = "../avian_derive", version = "0.1" } -bevy = { version = "0.15.0-rc", default-features = false } -bevy_math = { version = "0.15.0-rc" } +bevy = { version = "0.15", default-features = false } +bevy_math = { version = "0.15" } libm = { version = "0.2", optional = true } parry2d = { version = "0.17", optional = true } parry2d-f64 = { version = "0.17", optional = true } nalgebra = { version = "0.33", features = ["convert-glam029"], optional = true } serde = { version = "1", features = ["derive"], optional = true } -derive_more = "0.99" +derive_more = "1" indexmap = "2.0.0" fxhash = "0.2.1" itertools = "0.13" @@ -75,12 +75,12 @@ bitflags = "2.5.0" [dev-dependencies] examples_common_2d = { path = "../examples_common_2d" } benches_common_2d = { path = "../benches_common_2d" } -bevy_math = { version = "0.15.0-rc", features = ["approx"] } +bevy_math = { version = "0.15", features = ["approx"] } glam = { version = "0.29", features = ["bytemuck"] } approx = "0.5" bytemuck = "1.19" criterion = { version = "0.5", features = ["html_reports"] } -bevy_mod_debugdump = { git = "https://github.com/andriyDev/bevy_mod_debugdump", branch = "bevy-0.15" } +bevy_mod_debugdump = { git = "https://github.com/jakobhellermann/bevy_mod_debugdump" } [[example]] name = "dynamic_character_2d" diff --git a/crates/avian2d/examples/dynamic_character_2d/plugin.rs b/crates/avian2d/examples/dynamic_character_2d/plugin.rs index f6b907c6..b904e1e8 100644 --- a/crates/avian2d/examples/dynamic_character_2d/plugin.rs +++ b/crates/avian2d/examples/dynamic_character_2d/plugin.rs @@ -150,11 +150,11 @@ fn gamepad_input( gamepads: Query<&Gamepad>, ) { for gamepad in gamepads.iter() { - if let Some(x) = gamepad.analog.get(GamepadAxis::LeftStickX) { + if let Some(x) = gamepad.get(GamepadAxis::LeftStickX) { movement_event_writer.send(MovementAction::Move(x as Scalar)); } - if gamepad.digital.just_pressed(GamepadButton::South) { + if gamepad.just_pressed(GamepadButton::South) { movement_event_writer.send(MovementAction::Jump); } } diff --git a/crates/avian2d/examples/kinematic_character_2d/plugin.rs b/crates/avian2d/examples/kinematic_character_2d/plugin.rs index 9ea9e60c..9888f20f 100644 --- a/crates/avian2d/examples/kinematic_character_2d/plugin.rs +++ b/crates/avian2d/examples/kinematic_character_2d/plugin.rs @@ -164,11 +164,11 @@ fn gamepad_input( gamepads: Query<&Gamepad>, ) { for gamepad in gamepads.iter() { - if let Some(x) = gamepad.analog.get(GamepadAxis::LeftStickX) { + if let Some(x) = gamepad.get(GamepadAxis::LeftStickX) { movement_event_writer.send(MovementAction::Move(x as Scalar)); } - if gamepad.digital.just_pressed(GamepadButton::South) { + if gamepad.just_pressed(GamepadButton::South) { movement_event_writer.send(MovementAction::Jump); } } diff --git a/crates/avian3d/Cargo.toml b/crates/avian3d/Cargo.toml index f799d027..106608ec 100644 --- a/crates/avian3d/Cargo.toml +++ b/crates/avian3d/Cargo.toml @@ -61,29 +61,30 @@ bench = false [dependencies] avian_derive = { path = "../avian_derive", version = "0.1" } -bevy = { version = "0.15.0-rc", default-features = false } -bevy_math = { version = "0.15.0-rc" } +bevy = { version = "0.15", default-features = false } +bevy_math = { version = "0.15" } libm = { version = "0.2", optional = true } parry3d = { version = "0.17", optional = true } parry3d-f64 = { version = "0.17", optional = true } nalgebra = { version = "0.33", features = ["convert-glam029"], optional = true } serde = { version = "1", features = ["derive"], optional = true } -derive_more = "0.99" +derive_more = "1" indexmap = "2.0.0" fxhash = "0.2.1" itertools = "0.13" bitflags = "2.5.0" [dev-dependencies] -bevy = { version = "0.15.0-rc", default-features = false, features = [ +bevy = { version = "0.15", default-features = false, features = [ "bevy_gltf", + "animation", ] } examples_common_3d = { path = "../examples_common_3d" } benches_common_3d = { path = "../benches_common_3d" } -bevy_math = { version = "0.15.0-rc", features = ["approx"] } +bevy_math = { version = "0.15", features = ["approx"] } approx = "0.5" criterion = { version = "0.5", features = ["html_reports"] } -bevy_mod_debugdump = { git = "https://github.com/andriyDev/bevy_mod_debugdump", branch = "bevy-0.15" } +bevy_mod_debugdump = { git = "https://github.com/jakobhellermann/bevy_mod_debugdump" } [[example]] name = "dynamic_character_3d" diff --git a/crates/avian3d/examples/dynamic_character_3d/plugin.rs b/crates/avian3d/examples/dynamic_character_3d/plugin.rs index 5f1a7720..207c3184 100644 --- a/crates/avian3d/examples/dynamic_character_3d/plugin.rs +++ b/crates/avian3d/examples/dynamic_character_3d/plugin.rs @@ -159,15 +159,15 @@ fn gamepad_input( ) { for gamepad in gamepads.iter() { if let (Some(x), Some(y)) = ( - gamepad.analog.get(GamepadAxis::LeftStickX), - gamepad.analog.get(GamepadAxis::LeftStickY), + gamepad.get(GamepadAxis::LeftStickX), + gamepad.get(GamepadAxis::LeftStickY), ) { movement_event_writer.send(MovementAction::Move( Vector2::new(x as Scalar, y as Scalar).clamp_length_max(1.0), )); } - if gamepad.digital.just_pressed(GamepadButton::South) { + if gamepad.just_pressed(GamepadButton::South) { movement_event_writer.send(MovementAction::Jump); } } diff --git a/crates/avian3d/examples/kinematic_character_3d/plugin.rs b/crates/avian3d/examples/kinematic_character_3d/plugin.rs index 5782da64..f542b48d 100644 --- a/crates/avian3d/examples/kinematic_character_3d/plugin.rs +++ b/crates/avian3d/examples/kinematic_character_3d/plugin.rs @@ -174,15 +174,15 @@ fn gamepad_input( ) { for gamepad in gamepads.iter() { if let (Some(x), Some(y)) = ( - gamepad.analog.get(GamepadAxis::LeftStickX), - gamepad.analog.get(GamepadAxis::LeftStickY), + gamepad.get(GamepadAxis::LeftStickX), + gamepad.get(GamepadAxis::LeftStickY), ) { movement_event_writer.send(MovementAction::Move( Vector2::new(x as Scalar, y as Scalar).clamp_length_max(1.0), )); } - if gamepad.digital.just_pressed(GamepadButton::South) { + if gamepad.just_pressed(GamepadButton::South) { movement_event_writer.send(MovementAction::Jump); } } diff --git a/crates/benches_common_2d/Cargo.toml b/crates/benches_common_2d/Cargo.toml index ee6ce01c..0bbe1cc1 100644 --- a/crates/benches_common_2d/Cargo.toml +++ b/crates/benches_common_2d/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -bevy = { version = "0.15.0-rc", default-features = false } +bevy = { version = "0.15", default-features = false } avian2d = { path = "../avian2d", default-features = false } criterion = "0.5" diff --git a/crates/benches_common_3d/Cargo.toml b/crates/benches_common_3d/Cargo.toml index 2c36246b..de0c47ac 100644 --- a/crates/benches_common_3d/Cargo.toml +++ b/crates/benches_common_3d/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -bevy = { version = "0.15.0-rc", default-features = false } +bevy = { version = "0.15", default-features = false } avian3d = { path = "../avian3d", default-features = false } criterion = "0.5" diff --git a/crates/examples_common_2d/Cargo.toml b/crates/examples_common_2d/Cargo.toml index 4e1ff5af..88ea0a4b 100644 --- a/crates/examples_common_2d/Cargo.toml +++ b/crates/examples_common_2d/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" use-debug-plugin = [] [dependencies] -bevy = { version = "0.15.0-rc", default-features = false, features = [ +bevy = { version = "0.15", default-features = false, features = [ "bevy_core_pipeline", "bevy_state", "bevy_text", @@ -22,6 +22,7 @@ bevy = { version = "0.15.0-rc", default-features = false, features = [ "ktx2", "zstd", "bevy_winit", + "bevy_window", "x11", # github actions runners don't have libxkbcommon installed, so can't use wayland ] } avian2d = { path = "../avian2d", default-features = false } diff --git a/crates/examples_common_3d/Cargo.toml b/crates/examples_common_3d/Cargo.toml index ca10080d..72cadbb5 100644 --- a/crates/examples_common_3d/Cargo.toml +++ b/crates/examples_common_3d/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" use-debug-plugin = [] [dependencies] -bevy = { version = "0.15.0-rc", default-features = false, features = [ +bevy = { version = "0.15", default-features = false, features = [ "bevy_core_pipeline", "bevy_state", "bevy_text", @@ -18,12 +18,14 @@ bevy = { version = "0.15.0-rc", default-features = false, features = [ "bevy_pbr", "bevy_gizmos", "bevy_gltf", + "animation", "default_font", "tonemapping_luts", "ktx2", "png", "zstd", "bevy_winit", + "bevy_window", "x11", # github actions runners don't have libxkbcommon installed, so can't use wayland ] } avian3d = { path = "../avian3d", default-features = false }