-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
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
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. |
@pitaj |
☔ 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). |
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author |
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.
|
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
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. |
Ok, I see. Those kind of checks are okay. The case of |
@pitaj Ping from triage! What's the current status of this? |
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: