delegation: refactor AST -> HIR lowering#158434
Draft
aerooneqq wants to merge 8 commits into
Draft
Conversation
Contributor
Author
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
☔ The latest upstream changes (presumably #158455) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a lot of new features were added to delegation the code became a bit worse, as resolution and lowering logic is mixed in
delegation.rs. In this file the output of resolution step of delegation is transferred as function params (in some functions up to 7 or 8 params), which is not good looking for me.As I mentioned in the previous paragraph delegation AST -> HIR lowering can be split into two phases:
This PR explicitly splits those two phases: as a first step we collect all needed information into
DelegationResolutionstruct and then use it during AST -> HIR lowering. Thedelegation.rsfile is moved intodelegationfolder and renamed tomod.rs, the final file structure is as follows:mod.rs- contains lowering logic for everything but generics,generics.rs- contains logic for resolution and uplifting of generic params, placed in a separate file as it is a significant and independent part of lowering,attributes.rs- contains relatively small piece of logic which connects to attributes inheritance,resolution.rs- contains logic for resolution of everything but generics.As resolution of delegation and generics logically does not depend on
LoweringContext, as from its nameLoweringContextcontains many additional information which is used for lowering, I've createdLoweringContextForResolutiontrait which abstracts operations which are used during delegation resolution.Benefits of this PR:
uplift_delegation_genericswhich was creating generic params for delegation made the code more understandable.Part of #118212.
r? @petrochenkov