Delegation: eliminate usage of AST from generics creation#154142
Open
aerooneqq wants to merge 1 commit intorust-lang:mainfrom
Open
Delegation: eliminate usage of AST from generics creation#154142aerooneqq wants to merge 1 commit intorust-lang:mainfrom
aerooneqq wants to merge 1 commit intorust-lang:mainfrom
Conversation
Collaborator
|
HIR ty lowering was modified cc @fmease |
| pub enum InferDelegation<'hir> { | ||
| DefId(DefId), | ||
| Sig(DefId, InferDelegationSig<'hir>), | ||
| } |
Contributor
There was a problem hiding this comment.
Need comments explaining what the variants mean / when they are used.
| /// through `tcx`. Next, at some point of generics processing we need to lower those | ||
| /// generics to HIR, for this purpose we use `into_hir_generics` that lowers AST generics | ||
| /// and replaces Ast variant with Hir. Such approach is useful as we can call this method | ||
| /// Used for storing either ty generics or their lowered HIR version. Firstly we obtain |
Contributor
There was a problem hiding this comment.
Suggested change
| /// Used for storing either ty generics or their lowered HIR version. Firstly we obtain | |
| /// Used for storing either ty generics or their uplifted HIR version. First we obtain |
(In other places too.)
- Getting from lower level IR to higher level IR is uplifting.
- https://www.merriam-webster.com/grammar/first-or-firstly
| } | ||
| } else { | ||
| DelegationGenerics::Default(parent_generics_factory(self, false)) | ||
| let skip_self = !generate_self as usize; |
Contributor
There was a problem hiding this comment.
Suggested change
| let skip_self = !generate_self as usize; | |
| let skip_self = usize::from(!generate_self); |
| generics | ||
| fn generic_params(&mut self, id: DefId) -> Option<impl Iterator<Item = ty::GenericParamDef>> { | ||
| let params = &self.tcx.generics_of(id).own_params; | ||
| (!params.is_empty()).then(|| params.iter().cloned()) |
Contributor
There was a problem hiding this comment.
Why do you need to clone and collect the parameters?
You could probably keep the &'tcx [GenericParam] or its sub-slices directly.
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.
This PR eliminates all interaction with AST during creation of generics, then it supports proper const param types propagation. Fixes #153433. Fixes #153499. Part of #118212.
r? @petrochenkov