-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Introduce HirId, a replacement for ast::NodeId after lowering to HIR #40518
Conversation
14150c7
to
2efd813
Compare
Alright, this passes |
Just pushed another commit that prepares some things for using HirIds as keys in the HIR map. |
@@ -18,7 +18,7 @@ trait SomeTrait { } | |||
|
|||
// Bounds on object types: | |||
|
|||
struct Foo<'a,'b,'c> { //~ ERROR parameter `'b` is never used | |||
struct Foo<'a,'b,'c> { //~ ERROR parameter `'c` is never used |
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.
Hahahaha I think I remember when this changed due to syntactical elision.
@bors r+ |
📌 Commit 2536302 has been approved by |
Introduce HirId, a replacement for ast::NodeId after lowering to HIR This is the first step towards implementing rust-lang#40303. This PR introduces the `HirId` type and generates a `HirId` for everything that would be assigned one (i.e. stuff in the HIR), but the HIR data types still use `NodeId` for now. Changing that is a big refactoring that I want to do in a separate PR. A `HirId` uniquely identifies a node in the HIR of the current crate. It is composed of the `owner`, which is the `DefIndex` of the directly enclosing `hir::Item`, `hir::TraitItem`, or `hir::ImplItem` (i.e. the closest "item-like"), and the `local_id` which is unique within the given owner. This PR is also running a number of consistency checks for the generated `HirId`s: - Does `NodeId` in the HIR have a corresponding `HirId`? - Is the `owner` part of each `HirId` consistent with its position in the HIR? - Do the numerical values of the `local_id` part all lie within a dense range of integers? cc @rust-lang/compiler r? @eddyb or @nikomatsakis
🔒 Merge conflict |
☔ The latest upstream changes (presumably #40693) made this pull request unmergeable. Please resolve the merge conflicts. |
HirId has a more stable representation than NodeId, meaning that modifications to one item don't influence (part of) the IDs within other items. The other part is a DefIndex for which there already is a way of stable hashing and persistence. This commit introduces the HirId type and generates a HirId for every NodeId during HIR lowering, but the resulting values are not yet used anywhere, except in consistency checks.
2536302
to
f7170fc
Compare
This way we can have all item-likes occupy a dense range of DefIndexes, which is good for making fast, array-based dictionaries.
f7170fc
to
090767b
Compare
@bors r=eddyb Rebased. |
📌 Commit 090767b has been approved by |
Introduce HirId, a replacement for ast::NodeId after lowering to HIR This is the first step towards implementing rust-lang#40303. This PR introduces the `HirId` type and generates a `HirId` for everything that would be assigned one (i.e. stuff in the HIR), but the HIR data types still use `NodeId` for now. Changing that is a big refactoring that I want to do in a separate PR. A `HirId` uniquely identifies a node in the HIR of the current crate. It is composed of the `owner`, which is the `DefIndex` of the directly enclosing `hir::Item`, `hir::TraitItem`, or `hir::ImplItem` (i.e. the closest "item-like"), and the `local_id` which is unique within the given owner. This PR is also running a number of consistency checks for the generated `HirId`s: - Does `NodeId` in the HIR have a corresponding `HirId`? - Is the `owner` part of each `HirId` consistent with its position in the HIR? - Do the numerical values of the `local_id` part all lie within a dense range of integers? cc @rust-lang/compiler r? @eddyb or @nikomatsakis
This is the first step towards implementing #40303. This PR introduces the
HirId
type and generates aHirId
for everything that would be assigned one (i.e. stuff in the HIR), but the HIR data types still useNodeId
for now. Changing that is a big refactoring that I want to do in a separate PR.A
HirId
uniquely identifies a node in the HIR of the current crate. It is composed of theowner
, which is theDefIndex
of the directly enclosinghir::Item
,hir::TraitItem
, orhir::ImplItem
(i.e. the closest "item-like"), and thelocal_id
which is unique within the given owner.This PR is also running a number of consistency checks for the generated
HirId
s:NodeId
in the HIR have a correspondingHirId
?owner
part of eachHirId
consistent with its position in the HIR?local_id
part all lie within a dense range of integers?cc @rust-lang/compiler
r? @eddyb or @nikomatsakis