-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Forbid lowering the same NodeId
multiple times
#96346
Comments
@rustbot claim |
Hey @kckeiks , are you still working on this task by chance? |
@raiyansayeed I was but I have a couple of other issues that I'm working on so you can take this one if you want. |
@raiyansayeed feel free to ping me too on Zulip if you need help or something. |
@rustbot claim |
@raiyansayeed are you still working on this? |
No activity, feel free to claim it again. @rustbot release-assignment |
@rustbot claim |
@rustbot claim |
…jgillot Lower AST node id only once Fixes rust-lang#96346. I basically followed the given instructions except the inline part. `lower_jump_destination` can't reuse local existing `HirId` due to unknown name resolution result so I created an additional mapping for labels. r? `@cjgillot`
…jgillot Lower AST node id only once Fixes rust-lang#96346. I basically followed the given instructions except the inline part. `lower_jump_destination` can't reuse local existing `HirId` due to unknown name resolution result so I created an additional mapping for labels. r? ``@cjgillot``
…jgillot Lower AST node id only once Fixes rust-lang#96346. I basically followed the given instructions except the inline part. `lower_jump_destination` can't reuse local existing `HirId` due to unknown name resolution result so I created an additional mapping for labels. r? ````@cjgillot````
…jgillot Lower AST node id only once Fixes rust-lang#96346. I basically followed the given instructions except the inline part. `lower_jump_destination` can't reuse local existing `HirId` due to unknown name resolution result so I created an additional mapping for labels. r? `````@cjgillot`````
Rollup merge of rust-lang#130259 - adwinwhite:lower-node-id-once, r=cjgillot Lower AST node id only once Fixes rust-lang#96346. I basically followed the given instructions except the inline part. `lower_jump_destination` can't reuse local existing `HirId` due to unknown name resolution result so I created an additional mapping for labels. r? ```@cjgillot```
During AST->HIR lowering, the method
lower_node_id
is tasked to transformNodeId
s that identify AST nodes intoHirId
s that identify HIR nodes. This method maintains anode_id_to_local_id: FxHashMap<NodeId, hir::ItemLocalId>
to remember this mapping.However, this mapping is not entirely useful, and mostly exists (1) to make the developer's life easier, (2) to lower resolutions to local bindings
Res::Local
inlower_res
. The mappingnode_id_to_local_id
should be removed, and multiple calls tolocal_node_id
with the sameNodeId
should be forbidden. For usage (2),Res::Local
only appears for ident patterns (PatKind::Ident
) which are lowered bylower_pat_ident
. Hence,lower_res
should use a dedicated hash-map filled bylower_pat_ident
.Furthermore,
next_id
callslower_node_id
with anode_id: NodeId
which is entirely local to that function, and will never be known to any other code. Manipulations ofnode_id_to_local_id
there are entirely useless.Instructions:
lower_node_id
intonext_id
and skip manipulations ofnode_id_to_local_id
;Entry::Occupied
branch inlower_node_id
by apanic!
, and fix all the ICEs;node_id_to_local_id_for_res
(name to bikeshed) which is only filled bylower_pat_ident
and read bylower_res
; this mapping should be saved bywith_hir_id_owner
likenode_id_to_local_id
is;node_id_to_local_id
, or eventually keep it only to debug-assert that we don't calllower_node_id
twice on the sameNodeId
.The text was updated successfully, but these errors were encountered: