Skip to content

Commit 9ce7268

Browse files
committed
Auto merge of #80860 - camelid:nodeid-docs, r=sanxiyn
Document `NodeId`
2 parents 178108b + 0f3e2f6 commit 9ce7268

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Diff for: compiler/rustc_ast/src/node_id.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ use rustc_span::ExpnId;
22
use std::fmt;
33

44
rustc_index::newtype_index! {
5+
/// Identifies an AST node.
6+
///
7+
/// This identifies top-level definitions, expressions, and everything in between.
8+
/// This is later turned into [`DefId`] and `HirId` for the HIR.
9+
///
10+
/// [`DefId`]: rustc_span::def_id::DefId
511
pub struct NodeId {
612
DEBUG_FORMAT = "NodeId({})"
713
}
814
}
915

1016
rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeId);
1117

12-
/// `NodeId` used to represent the root of the crate.
18+
/// The [`NodeId`] used to represent the root of the crate.
1319
pub const CRATE_NODE_ID: NodeId = NodeId::from_u32(0);
1420

15-
/// When parsing and doing expansions, we initially give all AST nodes this AST
16-
/// node value. Then later, during expansion, we renumber them to have small,
17-
/// positive ids.
21+
/// When parsing and at the beginning of doing expansions, we initially give all AST nodes
22+
/// this dummy AST [`NodeId`]. Then, during a later phase of expansion, we renumber them
23+
/// to have small, positive IDs.
1824
pub const DUMMY_NODE_ID: NodeId = NodeId::MAX;
1925

2026
impl NodeId {

0 commit comments

Comments
 (0)