Uh oh!
There was an error while loading. Please reload this page.
rustc_metadata: Deduplicate code between encode_info_for_item, encode_info_for_foreign_item, encode_info_for_trait_item, and encode_info_for_impl_item - #78081
Conversation
rust-highfive
commented
Oct 18, 2020
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (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. |
petrochenkov
commented
Oct 18, 2020
@pitaj |
bors
commented
Oct 21, 2020
☔ The latest upstream changes (presumably #78077) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels: |
I'm going to reassign this to r? @oli-obk who requested this change in #77375 (comment). |
pitaj
commented
Oct 24, 2020
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
oli-obk
commented
Oct 25, 2020
Yea, these boolean flags do not make the code less fragile. I think we should still do this PR, but just remove all the boolean flags and keep the individual logic to each call site. We can also create multiple functions if we want to share more, but I think starting out with just the minimal implementation that deduplicates the code that is actually shared is the best way forward. Once that is a real improvement over the status quo, we can look at the call sites to see whether creating more functions for a subset of the call sites is helpful |
I've removed the boolean flags. Turns out they have 8 lines fully in common. I've seen some other opportunities for dedupe.
|
oli-obk
commented
Oct 25, 2020
We already have a conditional function like this: grouping generics, predicates and outlives bounds together does make sense. We could call it |
Remove `encode_explicit_predicates` and `encode_inferred_outlives`, they were only used in `encode_bounds` after this change
pitaj
commented
Oct 25, 2020
I added
I seems to me that logic already exists in the rust/compiler/rustc_metadata/src/rmeta/encoder.rs Lines 1378 to 1384 in 430feb2 rust/compiler/rustc_metadata/src/rmeta/encoder.rs Lines 1732 to 1735 in 430feb2 rust/compiler/rustc_typeck/src/variance/mod.rs Lines 48 to 55 in 430feb2 rust/compiler/rustc_typeck/src/variance/mod.rs Lines 69 to 73 in 430feb2 I'm not sure how possible it is to reuse this logic in encoder, but that would be pretty nice. |
oli-obk
commented
Oct 26, 2020
Ok, I see. Those kind of checks are okay. The case of |
crlf0710
commented
Nov 20, 2020
@pitaj Ping from triage! What's the current status of this? |
pitaj
commented
Nov 20, 2020
Thanks for checking in. I haven't forgotten about this, just been focused on other things. |
triage: I'm closing this PR as inactive @pitaj - if this PR is still in progress, please feel free to reopen |
For #77393
r? @petrochenkov
Todo: