From 4b703c76b67b260735997fc20ba3c2174071d3a7 Mon Sep 17 00:00:00 2001 From: "Ame :]" <104745335+ameknite@users.noreply.github.com> Date: Thu, 5 Oct 2023 00:41:09 -0500 Subject: [PATCH] Fix some warnings shown in nightly (#10012) # Objective Fix warnings: - #[warn(clippy::needless_pass_by_ref_mut)] - #[warn(elided_lifetimes_in_associated_constant)] ## Solution - Remove mut - add &'static ## Errors ```rust warning: this argument is a mutable reference, but not used mutably --> crates/bevy_hierarchy/src/child_builder.rs:672:31 | 672 | fn assert_children(world: &mut World, parent: Entity, children: Option<&[Entity]>) { | ^^^^^^^^^^ help: consider changing to: `&World` | = note: this is cfg-gated and may require further changes = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_ref_mut = note: `#[warn(clippy::needless_pass_by_ref_mut)]` on by default ``` ```rust warning: `&` without an explicit lifetime name cannot be used here --> examples/shader/post_processing.rs:120:21 | 120 | pub const NAME: &str = "post_process"; | ^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #115010 = note: `#[warn(elided_lifetimes_in_associated_constant)]` on by default help: use the `'static` lifetime | 120 | pub const NAME: &'static str = "post_process"; | +++++++ ``` --- crates/bevy_hierarchy/src/child_builder.rs | 4 ++-- examples/shader/post_processing.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bevy_hierarchy/src/child_builder.rs b/crates/bevy_hierarchy/src/child_builder.rs index 06a522a228b59..8e316aa5b34dc 100644 --- a/crates/bevy_hierarchy/src/child_builder.rs +++ b/crates/bevy_hierarchy/src/child_builder.rs @@ -664,12 +664,12 @@ mod tests { }; /// Assert the (non)existence and state of the child's [`Parent`] component. - fn assert_parent(world: &mut World, child: Entity, parent: Option) { + fn assert_parent(world: &World, child: Entity, parent: Option) { assert_eq!(world.get::(child).map(|p| p.get()), parent); } /// Assert the (non)existence and state of the parent's [`Children`] component. - fn assert_children(world: &mut World, parent: Entity, children: Option<&[Entity]>) { + fn assert_children(world: &World, parent: Entity, children: Option<&[Entity]>) { assert_eq!(world.get::(parent).map(|c| &**c), children); } diff --git a/examples/shader/post_processing.rs b/examples/shader/post_processing.rs index fd6dfc3422173..d789eaa48b023 100644 --- a/examples/shader/post_processing.rs +++ b/examples/shader/post_processing.rs @@ -117,7 +117,7 @@ impl Plugin for PostProcessPlugin { #[derive(Default)] struct PostProcessNode; impl PostProcessNode { - pub const NAME: &str = "post_process"; + pub const NAME: &'static str = "post_process"; } // The ViewNode trait is required by the ViewNodeRunner