-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
collapse nested if blocks #9613
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Personally I prefer to not blanket do this via the guidance of some external tool. The structure of |
Personally i don't think collapsing the statements makes them less readable, though it's debatable whether it makes them more readable in all cases. It does remove a level of indentation. Also, if another i definitely think collapsing the "if { else {...}}" blocks into "if else {...}" blocks improves readability. there's a couple of examples of that. there are some ugly ones in there too, for example if unit.target.is_cdylib()
&& !self.compilation.cdylibs.iter().any(|uo| uo.unit == *unit) {
...
} but i don't think this is any less readable than the original- if unit.target.is_cdylib() {
if !self.compilation.cdylibs.iter().any(|uo| uo.unit == *unit) {
...
} It might be worth naming some of this checks to document what it is they're actually testing. as in, // as a free function, or a struct method...
fn check_that_thing(cdylibs: ...) -> bool {
...
}
if unit.target.is_cdylib() && check_that_thing(self.compilation.cdylibs) {
...
} |
c403d1d
to
c5da878
Compare
I'm going to go ahead and merge this, but I want to point out that there is a comment here specifically saying we would prefer to not have PRs fixing clippy lints. They tend to be subjective, or have false positives, or break things. In this case, I don't think this is a significant improvement, but a small reduction in nesting I think is fine. @bors r+ |
📌 Commit c5da878 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 9 commits in cc17afbb0067b1f57d8882640f63b2168d5b7624..b51439fd8b505d4800a257acfecf3c69f81e35cf 2021-08-02 20:28:08 +0000 to 2021-08-09 18:40:05 +0000 - Deduplicate entries in cargo --list (rust-lang/cargo#9773) - Include aliases with other commands (rust-lang/cargo#9764) - Add a profile option to select the codegen backend (rust-lang/cargo#9118) - remove useless conversions (rust-lang/cargo#9617) - collapse nested if blocks (rust-lang/cargo#9613) - Refactor fake_file() away from cargo_command tests (rust-lang/cargo#9767) - Update cargo-platform to 0.1.2 (rust-lang/cargo#9762) - Bump to the latest jobserver dependency (rust-lang/cargo#9760) - Fix semver check for rust 1.54.0 (rust-lang/cargo#9763)
Update cargo 9 commits in cc17afbb0067b1f57d8882640f63b2168d5b7624..b51439fd8b505d4800a257acfecf3c69f81e35cf 2021-08-02 20:28:08 +0000 to 2021-08-09 18:40:05 +0000 - Deduplicate entries in cargo --list (rust-lang/cargo#9773) - Include aliases with other commands (rust-lang/cargo#9764) - Add a profile option to select the codegen backend (rust-lang/cargo#9118) - remove useless conversions (rust-lang/cargo#9617) - collapse nested if blocks (rust-lang/cargo#9613) - Refactor fake_file() away from cargo_command tests (rust-lang/cargo#9767) - Update cargo-platform to 0.1.2 (rust-lang/cargo#9762) - Bump to the latest jobserver dependency (rust-lang/cargo#9760) - Fix semver check for rust 1.54.0 (rust-lang/cargo#9763)
Update cargo 9 commits in cc17afbb0067b1f57d8882640f63b2168d5b7624..b51439fd8b505d4800a257acfecf3c69f81e35cf 2021-08-02 20:28:08 +0000 to 2021-08-09 18:40:05 +0000 - Deduplicate entries in cargo --list (rust-lang/cargo#9773) - Include aliases with other commands (rust-lang/cargo#9764) - Add a profile option to select the codegen backend (rust-lang/cargo#9118) - remove useless conversions (rust-lang/cargo#9617) - collapse nested if blocks (rust-lang/cargo#9613) - Refactor fake_file() away from cargo_command tests (rust-lang/cargo#9767) - Update cargo-platform to 0.1.2 (rust-lang/cargo#9762) - Bump to the latest jobserver dependency (rust-lang/cargo#9760) - Fix semver check for rust 1.54.0 (rust-lang/cargo#9763)
No description provided.