-
-
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
Fix *most* clippy lints #15906
Fix *most* clippy lints #15906
Conversation
@@ -587,7 +587,7 @@ impl AssetSources { | |||
AssetSourceId::Name(name) => self | |||
.sources | |||
.get(&name) | |||
.ok_or_else(|| MissingAssetSourceError(AssetSourceId::Name(name))), | |||
.ok_or(MissingAssetSourceError(AssetSourceId::Name(name))), |
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.
What's the problem with the original code? Now this value is constructed every time instead of only when needed.
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.
It's not actually constructed: since it's just wrapping in enum variants/newtype structs, it's basically as simple as a copy anyway, and adding an extra level of function indirection just makes it harder to optimize.
The clippy lint specifically looks for "trivial" constructions like this, since the amount of text makes it seem like a lot of work is being done, when it's actually not.
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.
What a useful lint :)
Objective
Another clippy-lint fix: the goal is so that
ci lints
actually displays the problems that a contributor caused, and not a bunch of existing stuff in the repo. (when run on nightly)Solution
This fixes all but the
clippy::needless_lifetimes
lint, which will result in substantially more fixes and be in other PR(s). I also explicitly allownon_local_definitions
since it is not working correctly, but will be fixed.A few things were manually fixed: for example, some places had an explicitly defined
div_ceil
function that was used, which is no longer needed since this function is stable on unsigned integers. Also, empty lines in doc comments were handled individually.Testing
I ran
cargo clippy --workspace --all-targets --all-features --fix --allow-staged
with theclippy::needless_lifetimes
lint marked asallow
inCargo.toml
to avoid fixing that too. It now passes with all but the listed lint.