Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler using clone on a double-reference #252

Closed
bgourlie opened this issue Aug 20, 2020 · 3 comments
Closed

Scheduler using clone on a double-reference #252

bgourlie opened this issue Aug 20, 2020 · 3 comments
Labels
C-Code-Quality A section of code that is hard to understand or change

Comments

@bgourlie
Copy link
Contributor

Clippy flagged this error:

error: using `clone` on a double-reference; this will copy the reference instead of cloning the inner type
  --> crates\bevy_render\src\render_graph\schedule.rs:78:53
   |
78 |         node_borrows.sort_by_key(|(_node, indices)| indices.clone());
   |                                                     ^^^^^^^^^^^^^^^
   |
   = note: `#[deny(clippy::clone_double_ref)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_double_ref
help: try dereferencing it
   |
78 |         node_borrows.sort_by_key(|(_node, indices)| &(*indices).clone());
   |                                                     ^^^^^^^^^^^^^^^^^^^
help: or try being explicit if you are sure, that you want to clone a reference
   |
78 |         node_borrows.sort_by_key(|(_node, indices)| <&render_graph::schedule::NodeIndices>::clone(indices));
   |                          

Seems like a pretty trivial fix once we clarify the intention of the clone.

@bgourlie bgourlie mentioned this issue Aug 20, 2020
@GabCampbell GabCampbell added the C-Code-Quality A section of code that is hard to understand or change label Aug 20, 2020
@GabCampbell
Copy link
Contributor

Thanks for the issues you're raising, code quality should always remain a top priority!

@multun
Copy link
Contributor

multun commented Aug 20, 2020

I believe this is intended, trying to clone the referenced value doesn't compile at all

@cart
Copy link
Member

cart commented Aug 20, 2020

Closed via #206 (although i honestly prefer the old version, clippy is weird sometimes 😄 )

@cart cart closed this as completed Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Code-Quality A section of code that is hard to understand or change
Projects
None yet
Development

No branches or pull requests

4 participants