1 use rustc_span::ExpnId;
4 rustc_index::newtype_index! {
6 DEBUG_FORMAT = "NodeId({})"
10 rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeId);
12 /// `NodeId` used to represent the root of the crate.
13 pub const CRATE_NODE_ID: NodeId = NodeId::from_u32(0);
15 /// When parsing and doing expansions, we initially give all AST nodes this AST
16 /// node value. Then later, in the renumber pass, we renumber them to have
17 /// small, positive ids.
18 pub const DUMMY_NODE_ID: NodeId = NodeId::MAX;
21 pub fn placeholder_from_expn_id(expn_id: ExpnId) -> Self {
22 NodeId::from_u32(expn_id.as_u32())
25 pub fn placeholder_to_expn_id(self) -> ExpnId {
26 ExpnId::from_u32(self.as_u32())
30 impl fmt::Display for NodeId {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 fmt::Display::fmt(&self.as_u32(), f)