-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Forbid lowering the same NodeId multiple times #96346
Copy link
Copy link
Closed
Labels
E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
During AST->HIR lowering, the method
lower_node_idis tasked to transformNodeIds that identify AST nodes intoHirIds 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::Localinlower_res. The mappingnode_id_to_local_idshould be removed, and multiple calls tolocal_node_idwith the sameNodeIdshould be forbidden. For usage (2),Res::Localonly appears for ident patterns (PatKind::Ident) which are lowered bylower_pat_ident. Hence,lower_resshould use a dedicated hash-map filled bylower_pat_ident.Furthermore,
next_idcallslower_node_idwith anode_id: NodeIdwhich is entirely local to that function, and will never be known to any other code. Manipulations ofnode_id_to_local_idthere are entirely useless.Instructions:
lower_node_idintonext_idand skip manipulations ofnode_id_to_local_id;Entry::Occupiedbranch inlower_node_idby apanic!, and fix all the ICEs;node_id_to_local_id_for_res(name to bikeshed) which is only filled bylower_pat_identand read bylower_res; this mapping should be saved bywith_hir_id_ownerlikenode_id_to_local_idis;node_id_to_local_id, or eventually keep it only to debug-assert that we don't calllower_node_idtwice on the sameNodeId.