-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Clippy fixes #3718
Clippy fixes #3718
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were several places where an fn
was made const, that can't be actually called in a const context as the Type they are implemented for can only be constructed at runtime.
Please revert those functions or try to get a const-constructor.
Also please when change as many Files/Places as here, make 1. Commit for every clippy Lint. this makes it much easier to review each individual Lint.
@MinerSebas |
A Adding |
Some of this work was duplicated in #2934. I think I prefer the clarity and freshness of this PR, if we're picking one to merge. |
Thanks @mockersf (Merci François !) I'll apply the suggestions of @MinerSebas and remove the extra @alice-i-cecile I added more clippy fixes like Should I add to the CI config or the |
@@ -570,6 +570,7 @@ impl World { | |||
|
|||
/// Returns an iterator of entities that had components of type `T` removed | |||
/// since the last call to [`World::clear_trackers`]. | |||
// TODO: return `std::iter::Copied` instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should return a std::iter::Copied
here but I don't know if it would be a breaking change or not
@@ -579,6 +580,7 @@ impl World { | |||
|
|||
/// Returns an iterator of entities that had components with the given `component_id` removed | |||
/// since the last call to [`World::clear_trackers`]. | |||
// TODO: return `std::iter::Copied` instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should return a std::iter::Copied
here but I don't know if it would be a breaking change or not
Yeah, if we're going to fix pedantic / nursery lints we should toggle them on in CI so they stay fixed. |
To be transparent, this is exactly why I think most of those lints should not be fixed. Adding more things to check will slow down development. Some add enough values to be worth it, but that's not the case of most of the pedantic lints. Also, the pedantic lints are often quite... pedantic and a matter of taste. Some of them are fine, I disagree with a few, and some should be done only sometimes - doing them by a lint remove sense from the code. |
@mockersf I agree, many pedantic lints are not worth it. |
@ManevilleF do you want to rebase this? If so we can merge it in ASAP after rebasing; otherwise I think we should just close it out to reduce merge conflicts. |
As discussed I will close this and open it again from the @mockersf @cart I think the current list of warnings is a good start:
Do you have more warnings you wish to add or some to remove? |
List of lints, for easy reference. |
Personal opinions:
|
# Objective Follow up to my previous MR #3718 to add new clippy warnings to bevy: - [x] [~~option_if_let_else~~](https://rust-lang.github.io/rust-clippy/master/#option_if_let_else) (reverted) - [x] [redundant_else](https://rust-lang.github.io/rust-clippy/master/#redundant_else) - [x] [match_same_arms](https://rust-lang.github.io/rust-clippy/master/#match_same_arms) - [x] [semicolon_if_nothing_returned](https://rust-lang.github.io/rust-clippy/master/#semicolon_if_nothing_returned) - [x] [explicit_iter_loop](https://rust-lang.github.io/rust-clippy/master/#explicit_iter_loop) - [x] [map_flatten](https://rust-lang.github.io/rust-clippy/master/#map_flatten) There is one commit per clippy warning, and the matching flags are added to the CI execution. To test the CI execution you may run `cargo run -p ci -- clippy` at the root. I choose the add the flags in the `ci` tool crate to avoid having them in every `lib.rs` but I guess it could become an issue with suprise warnings coming up after a commit/push Co-authored-by: Carter Anderson <mcanders1@gmail.com>
# Objective Follow up to my previous MR bevyengine#3718 to add new clippy warnings to bevy: - [x] [~~option_if_let_else~~](https://rust-lang.github.io/rust-clippy/master/#option_if_let_else) (reverted) - [x] [redundant_else](https://rust-lang.github.io/rust-clippy/master/#redundant_else) - [x] [match_same_arms](https://rust-lang.github.io/rust-clippy/master/#match_same_arms) - [x] [semicolon_if_nothing_returned](https://rust-lang.github.io/rust-clippy/master/#semicolon_if_nothing_returned) - [x] [explicit_iter_loop](https://rust-lang.github.io/rust-clippy/master/#explicit_iter_loop) - [x] [map_flatten](https://rust-lang.github.io/rust-clippy/master/#map_flatten) There is one commit per clippy warning, and the matching flags are added to the CI execution. To test the CI execution you may run `cargo run -p ci -- clippy` at the root. I choose the add the flags in the `ci` tool crate to avoid having them in every `lib.rs` but I guess it could become an issue with suprise warnings coming up after a commit/push Co-authored-by: Carter Anderson <mcanders1@gmail.com>
# Objective Follow up to my previous MR bevyengine#3718 to add new clippy warnings to bevy: - [x] [~~option_if_let_else~~](https://rust-lang.github.io/rust-clippy/master/#option_if_let_else) (reverted) - [x] [redundant_else](https://rust-lang.github.io/rust-clippy/master/#redundant_else) - [x] [match_same_arms](https://rust-lang.github.io/rust-clippy/master/#match_same_arms) - [x] [semicolon_if_nothing_returned](https://rust-lang.github.io/rust-clippy/master/#semicolon_if_nothing_returned) - [x] [explicit_iter_loop](https://rust-lang.github.io/rust-clippy/master/#explicit_iter_loop) - [x] [map_flatten](https://rust-lang.github.io/rust-clippy/master/#map_flatten) There is one commit per clippy warning, and the matching flags are added to the CI execution. To test the CI execution you may run `cargo run -p ci -- clippy` at the root. I choose the add the flags in the `ci` tool crate to avoid having them in every `lib.rs` but I guess it could become an issue with suprise warnings coming up after a commit/push Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Objective
Fixes some
nursery
andpedantic
clippy warnings likeclippy::missing_const_fn
clippy::option_if_let_else
clippy::use_self
clippy::redundant_else
clippy::match_same_arms
clippy::semicolon_if_returned
clippy::explicit_iter_loop
clippy::cloned_instead_of_copied
clippy::map_flatten
Solution
I applied many small changes accross all crates.