1use std::fmt;
2
3use rustc_span::LocalExpnId;
4
5impl ::std::fmt::Debug for NodeId {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("NodeId({0})", self.as_u32()))
}
}rustc_index::newtype_index! {
6 #[encodable]
13 #[orderable]
14 #[debug_format = "NodeId({})"]
15 pub struct NodeId {
16 const CRATE_NODE_ID = 0;
18 }
19}
20
21pub type NodeMap<T> = ::rustc_data_structures::unord::UnordMap<NodeId, T>;
pub type NodeSet = ::rustc_data_structures::unord::UnordSet<NodeId>;
pub type NodeMapEntry<'a, T> =
::rustc_data_structures::fx::StdEntry<'a, NodeId, T>;rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeMapEntry, NodeId);
22
23pub const DUMMY_NODE_ID: NodeId = NodeId::MAX;
27
28impl NodeId {
29 pub fn placeholder_from_expn_id(expn_id: LocalExpnId) -> Self {
30 NodeId::from_u32(expn_id.as_u32())
31 }
32
33 pub fn placeholder_to_expn_id(self) -> LocalExpnId {
34 LocalExpnId::from_u32(self.as_u32())
35 }
36}
37
38impl fmt::Display for NodeId {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 fmt::Display::fmt(&self.as_u32(), f)
41 }
42}