Skip to content

Commit

Permalink
Auto merge of rust-lang#80860 - camelid:nodeid-docs, r=sanxiyn
Browse files Browse the repository at this point in the history
Document `NodeId`
  • Loading branch information
bors committed Feb 11, 2021
2 parents 178108b + 0f3e2f6 commit 9ce7268
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions compiler/rustc_ast/src/node_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ 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({})"
}
}

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 {
Expand Down

0 comments on commit 9ce7268

Please sign in to comment.