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

clippy::complexity fixes #105864

Merged
merged 1 commit into from
Dec 19, 2022
Merged

clippy::complexity fixes #105864

merged 1 commit into from
Dec 19, 2022

Conversation

matthiaskrgr
Copy link
Member

filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool

r? @compiler-errors

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 18, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 18, 2022

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Comment on lines -706 to 704
if field.is_none() {
// Transform repr(transparent) types without non-ZST field into ()
ty = tcx.mk_unit();
} else {
let ty0 = tcx.type_of(field.unwrap().did);
if let Some(field) = field {
let ty0 = tcx.type_of(field.did);
// Generalize any repr(transparent) user-defined type that is either a pointer
// or reference, and either references itself or any other type that contains or
// references itself, to avoid a reference cycle.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switch from if f.is_none() { otherbb } else { f.unwrap() } to if let Some(f) = f { f } else { otherbb } here

@@ -488,7 +488,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
// If this empty region is from a universe that can
// name the placeholder, then the placeholder is
// larger; otherwise, the only ancestor is `'static`.
if a_ui.can_name(placeholder.universe) { true } else { false }
return a_ui.can_name(placeholder.universe);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return a_ui.can_name(placeholder.universe);
a_ui.can_name(placeholder.universe)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally skipped the return, but I thought with the return it was more obvious that we get/return a bool here instead of just "computing something"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer keeping it I'm fine with that.

Comment on lines 102 to 103
return tcx.item_name(def_id).as_str() == "c_void"
&& (crate_name == sym::core || crate_name == sym::std || crate_name == sym::libc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return tcx.item_name(def_id).as_str() == "c_void"
&& (crate_name == sym::core || crate_name == sym::std || crate_name == sym::libc);
tcx.item_name(def_id).as_str() == "c_void"
&& (crate_name == sym::core || crate_name == sym::std || crate_name == sym::libc)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@Noratrieb
Copy link
Member

r? @Nilstrieb

Looks good, r=me after the two reviews

@rustbot rustbot assigned Noratrieb and unassigned compiler-errors Dec 18, 2022
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
@matthiaskrgr
Copy link
Member Author

@bors r=Nilstrieb

@bors
Copy link
Contributor

bors commented Dec 18, 2022

📌 Commit 1da4a49 has been approved by Nilstrieb

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 18, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 19, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#105682 (Use `expose_addr()` in `fmt::Pointer`)
 - rust-lang#105839 (Suggest a `T: Send` bound for `&mut T` upvars in `Send` generators)
 - rust-lang#105864 (clippy::complexity fixes)
 - rust-lang#105882 (Don't ICE in closure arg borrow suggestion)
 - rust-lang#105889 (Fix `uninlined_format_args` in libtest)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a9005b6 into rust-lang:master Dec 19, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants