From 2af4a014502832ff961d2efb6cc6d737f0c80ffb Mon Sep 17 00:00:00 2001 From: Camelid Date: Sat, 9 Jan 2021 17:44:10 -0800 Subject: [PATCH] Document `NodeId` --- compiler/rustc_ast/src/node_id.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index 6e7d2bab287..955183a5a7c 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -2,6 +2,12 @@ use rustc_span::ExpnId; use std::fmt; rustc_index::newtype_index! { + /// Identifies an AST node. + /// + /// This identifies top-level definitions, expressions, and everything in between. + /// This is later turned into [`DefId`] and `HirId` for the HIR. + /// + /// [`DefId`]: rustc_span::def_id::DefId pub struct NodeId { DEBUG_FORMAT = "NodeId({})" } @@ -9,12 +15,12 @@ rustc_index::newtype_index! { rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeId); -/// `NodeId` used to represent the root of the crate. +/// The [`NodeId`] used to represent the root of the crate. pub const CRATE_NODE_ID: NodeId = NodeId::from_u32(0); /// 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, +/// positive IDs. pub const DUMMY_NODE_ID: NodeId = NodeId::MAX; impl NodeId {