Skip to content

Commit

Permalink
Fix some warnings shown in nightly (#10012)
Browse files Browse the repository at this point in the history
# 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 <rust-lang/rust#115010>
    = note: `#[warn(elided_lifetimes_in_associated_constant)]` on by default
help: use the `'static` lifetime
    |
120 |     pub const NAME: &'static str = "post_process";
    |                      +++++++


```
  • Loading branch information
ameknite authored Oct 5, 2023
1 parent 86f7ef1 commit 7541bf8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_hierarchy/src/child_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Entity>) {
fn assert_parent(world: &World, child: Entity, parent: Option<Entity>) {
assert_eq!(world.get::<Parent>(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::<Children>(parent).map(|c| &**c), children);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/shader/post_processing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7541bf8

Please sign in to comment.