-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
delegation: fix cycles during delayed lowering #154368
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
Open
aerooneqq
wants to merge
8
commits into
rust-lang:main
Choose a base branch
from
aerooneqq:delegation-force-lowering-later
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3416702
Invoke hir_crate_items before force_delayed_lowering, don't force low…
aerooneqq b87ae9e
Add FIXME for bad error message
aerooneqq 6eb9261
Review: inline delayed_owners_kinds
aerooneqq 4b0f1ec
Review: &self -> self
aerooneqq 4354e2e
Review: Option<Ident> -> Ident
aerooneqq fefa3f6
Rename kind -> owner
aerooneqq 9136618
Add one more test
aerooneqq f22063b
Try to fix perf
aerooneqq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rustbot ready
This should fix incremental compilation issues, however it may bring other perf regressions as now we call it every time we want to get
Ident. Let's try run perf, If it will be OK then we can leave this thus adjusting all logic connected to getting identifier.Honestly speaking I am not sure that this is a correct way of solving cycle problems during delegation function resolution, after some experiments with inherent impls I found several other scenarios where cycles are possible, for example one is connected to const evaluation which eventually comes to
lints_that_dont_need_to_runwhich creates query cycle.Maybe we need infrastructural solution, for example fill synthetic owners for delegations before delayed lowering, then execute delayed lowering in a special query system mode, in this mode we will use synthetic owners in all queries connected to delegations, and after this mode we will replace them with lowered delegations and invalidate all queries that used synthetic delegations. But I still need to experiment more with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me why delegation needs a special "unprocessed HIR ID" at all. Can't you use type-dependent name resolution like the other things that can't be resolved without typeck info?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If by
type-dependent name resolutionyou mean resolution throughrustc_hir_typeck::method::probe::ProbeContextthats what I am trying to do now, the problem is that we need this resolution in order to generate HIR of delegation, so we invoke it during delayed AST -> HIR lowering, however,ProbeContextcan eventually invoke queries that can walk for example all items and access their HIR, but as we are doing it while lowering delegation, its HIR is not ready, so this creates cycle.Most of information about delegation can be retrieved without lowered delegation HIR, in this example we know delegation identifier without its HIR version, so now we stored it in
MaybeOwner::Delayedvariant and it can be accessed without forcing delegation's AST -> HIR lowering.