-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Document NodeId
#80860
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
Document NodeId
#80860
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
r? @Aaron1011 |
compiler/rustc_ast/src/node_id.rs
Outdated
/// Identifies an AST node. | ||
/// | ||
/// This identifies top-level definitions, expressions, and everything in between. | ||
/// This is later split into [`DefId`] and `HirId` for the HIR. |
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.
Could you say "converted" instead of "split"?
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.
"converted" didn't sound quite right to me, so I did "turned into" instead.
compiler/rustc_ast/src/node_id.rs
Outdated
/// When parsing and doing expansions, we initially give all AST nodes this AST | ||
/// node value. Then later, during expansion, we renumber them to have small, | ||
/// positive ids. | ||
/// [`NodeId`]. Then later, during expansion, we renumber them to have small, |
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 part is confusing to me: it says that "when parsing and doing expansions" we use a dummy ID, but "then later, during expansion" we create real IDs. Does it mean that at the beginning of expansions we use dummy IDs but a later phase of it we create real ones?
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.
That's correct - the creation of real NodeId
s is done here:
rust/compiler/rustc_expand/src/expand.rs
Lines 1702 to 1707 in 9bc8b00
fn visit_id(&mut self, id: &mut ast::NodeId) { | |
if self.monotonic { | |
debug_assert_eq!(*id, ast::DUMMY_NODE_ID); | |
*id = self.cx.resolver.next_node_id() | |
} | |
} |
@rustbot label: -S-waiting-on-review +S-waiting-on-author |
@bors r+ |
📌 Commit 2af4a01 has been approved by |
I was planning on clarifying the part about the dummy IDs a bit, and it might make sense for Aaron1011 to take another look too once I do that. @bors r- |
Ready for a final review! |
@bors r+ |
📌 Commit 0f3e2f6 has been approved by |
☀️ Test successful - checks-actions |
No description provided.