Auto merge of #80860 - camelid:nodeid-docs, r=sanxiyn

Document `NodeId`
This commit is contained in:
bors 2021-02-11 00:51:45 +00:00
commit 9ce7268bcf
1 changed files with 10 additions and 4 deletions

View File

@ -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.
/// When parsing and at the beginning of doing expansions, we initially give all AST nodes
/// this dummy AST [`NodeId`]. Then, during a later phase of expansion, we renumber them
/// to have small, positive IDs.
pub const DUMMY_NODE_ID: NodeId = NodeId::MAX;
impl NodeId {