-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Assign HirIds in HIR traversal order #102522
Comments
@rustbot claim |
@rustbot claim |
Hi! I'd love to get started contributing to Rust, but I'd need a little help getting started since this would be my first ever GitHub contribution. You've included the tags Easy, Help-Wanted, and Mentor, so if you're willing to help, I'm eager to get to work. Thanks! |
This hasn't been assigned to anyone yet. @DavidCoy77 are you working on this? In case you are not working on this, I would like to pick this up. |
@rustbot claim Since there has been no activity on this since November, I am assuming that there is no work in-flight. Please let me know if that's not the case. I am a first-time contributor looking for a good mentorship project, and this fits my interest area. |
Closing as not planned. It's really hard (= mostly rewrites lowering to change the id generation order), with very uncertain benefits (= simplify lint level computation). |
AST->HIR lowering assigns a
HirId
to most nodes in the HIR tree. TheHirId
consists of anOwnerId
, which tells to which item (function, trait, associated function...) a node belongs to, and anItemLocalId
which is its index inside thatOwnerId
.ItemLocalId
s are assigned in the order they are created during lowering, by a simple counter. As a consequence, their values when looking at the HIR tree do not follow a consistent order. Making that order consistent may help simplifying some code that needs to visit HIR when it may just iterate onItemLocalId
s.Steps:
rustc_passes::hir_id_validator
, add a check that theItemLocalId
of the parent of each node has a lower value that theItemLocalId
of the node itself;rustc_ast_lowering
, in particular calls tolower_node_id
andnext_id
until the tests pass.Bonus: manage to get the order of
ItemLocalId
s be the order in which a HIR visitor (defined inrustc_hir::intravisit
) visits all theHirId
s.I recommend using
-Zunpretty=hir-tree
to debug. Please contact me on zulip for any question.The text was updated successfully, but these errors were encountered: