-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Use queries for the HIR map #68944
Merged
Merged
Use queries for the HIR map #68944
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
cfa1d4e
Add HIR queries
Zoxc 21386e1
Collect the new maps
Zoxc 518c78f
Create Map after TyCtxt
Zoxc e1a9626
Update item functions
Zoxc d3c7394
Update `fn_decl_by_hir_id` and `fn_sig_by_hir_id`
Zoxc 0c68b7a
Update `body_owner` and `maybe_body_owned_by`
Zoxc 38e613c
Update `krate_attrs` and `get_module`
Zoxc b40e6ba
Update `visit_item_likes_in_module`
Zoxc d5827d8
Update `get_parent_node`
Zoxc 9c4308e
Update `find`
Zoxc 21942a5
Update `is_hir_id_module`
Zoxc 61527c8
Update `find_entry`
Zoxc 270ee7e
Remove comments
Zoxc 072449c
Update `trait_impls`
Zoxc d99b17f
Remove the `map` field from `Map`
Zoxc fa09db8
Remove `AllLocalTraitImpls`
Zoxc e9d166f
Clean up the collector
Zoxc b97d438
Remove `Hir` and `HirBody` dep nodes
Zoxc d73268b
Remove `input_task`
Zoxc 3538cb3
Only hash the Hir owner (including its bodies)
Zoxc 8b16b02
Index HIR after creating TyCtxt
Zoxc 0e316e2
Fix HIR map validation
Zoxc aea57ae
Don't hash HIR with bodies thrice
Zoxc 396aeb8
Optimize the HIR map
Zoxc 739a1ef
Create the `hir_to_node_id` map before `TyCtxt`
Zoxc c0b60c4
Replace `HirBody` with `hir_owner_items` in tests
Zoxc 274fb66
Replace `Hir` with `hir_owner` in tests
Zoxc 10b23e3
Format function_interfaces.rs
Zoxc 6258c01
Reintroduce workaround for #62649
Zoxc 7118f71
Update ich_nested_items.rs
Zoxc 8b8041e
Update tests
Zoxc 2af085d
Don't try to print missing HIR ids
Zoxc 31183c3
Add test for #69596
Zoxc 14fdd85
Add some comments to the new queries
Zoxc 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 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 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 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.
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.
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.
I see how this is still relevant for
DepKind::CrateMetadata
but I'm surprised that it's needed forDepKind::hir_owner
andDepKind::hir_owner_items
.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.
Given that
hir_owner
is just a rename ofHir
andhir_owner_items
is just a rename ofHirBody
, you can follow the explanation here to see how this has the same problem asHir
andHirBody
. AlsoHir(Something)
will be replaced byhir_owner_items(Something)
there, but that doesn't affect anything.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.
I had a chance to test this and I think the explanation in #62649 (comment) basically applies here:
Something::foo
is a valid query key forhir_owner
inrpass1
but inrpass2
it's not a valid key anymore.RecoverKey::recover()
returnsSome(_)
instead ofNone
. The algorithm thus goes ahead with forcingDepNode::hir_owner(Something::foo)
and ICEs.A short-term fix for this would be to have a newtype
struct HirOwnerDefId(DefId)
that is aDefId
with the additional invariant that it must correspond to a hir-owner. Then<HirOwnerDefId as RecoverKey>::recover()
could apply the same check as done here and returnNone
if it doesn't hold. Most uses ofHirOwnerDefId
should stay hidden behind the hir map wrapper, so this shouldn't be too disruptive.Another workaround would be to diversify the
DefPathData
variants again so that a field and a method would not have the sameDefPath
anymore. Either fixes would be acceptable solutions for unblocking this PR, in my opinion.I think one way to fix the problem at the conceptual level would be to add the invariant that
RecoverKey::recover()
must only returnSome(_)
if the recovered key is actually a valid query-key for the given query. That is, the result ofRecoverKey::recover()
would need to depend on the query, not just on the type of the query-key. It would then be able to do query-specific runtime checks about key validity.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.
This doesn't block this PR though. It's just #68289 ported to it. There's no further problems caused by this PR compared to master.
It seems like you're trying to fix #62649 here. I mentioned the
DefPathData
solution in a comment) there. I want to check the performance of makingas_local_hir_id
a query, but that is blocked on this PR.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.
Well, I'm fine with merging this if you mention #62649 in the FIXME comment above.
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.
I've added a reference to that issue.