Skip to content

Commit 078486b

Browse files
committed
in which NodeMap and friends are macrotized!
1 parent 1329605 commit 078486b

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/librustc/util/nodemap.rs

+12-17
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,16 @@ use syntax::ast;
1919
pub use rustc_data_structures::fx::FxHashMap;
2020
pub use rustc_data_structures::fx::FxHashSet;
2121

22-
pub type NodeMap<T> = FxHashMap<ast::NodeId, T>;
23-
pub type DefIdMap<T> = FxHashMap<DefId, T>;
24-
pub type HirIdMap<T> = FxHashMap<HirId, T>;
25-
pub type ItemLocalMap<T> = FxHashMap<ItemLocalId, T>;
22+
macro_rules! define_id_collections {
23+
($map_name:ident, $set_name:ident, $key:ty) => {
24+
pub type $map_name<T> = FxHashMap<$key, T>;
25+
pub fn $map_name<T>() -> $map_name<T> { FxHashMap() }
26+
pub type $set_name = FxHashSet<$key>;
27+
pub fn $set_name() -> $set_name { FxHashSet() }
28+
}
29+
}
2630

27-
pub type NodeSet = FxHashSet<ast::NodeId>;
28-
pub type DefIdSet = FxHashSet<DefId>;
29-
pub type HirIdSet = FxHashSet<HirId>;
30-
pub type ItemLocalSet = FxHashSet<ItemLocalId>;
31-
32-
pub fn NodeMap<T>() -> NodeMap<T> { FxHashMap() }
33-
pub fn DefIdMap<T>() -> DefIdMap<T> { FxHashMap() }
34-
pub fn HirIdMap<T>() -> HirIdMap<T> { FxHashMap() }
35-
pub fn ItemLocalMap<T>() -> ItemLocalMap<T> { FxHashMap() }
36-
pub fn NodeSet() -> NodeSet { FxHashSet() }
37-
pub fn DefIdSet() -> DefIdSet { FxHashSet() }
38-
pub fn HirIdSet() -> HirIdSet { FxHashSet() }
39-
pub fn ItemLocalSet() -> ItemLocalSet { FxHashSet() }
31+
define_id_collections!(NodeMap, NodeSet, ast::NodeId);
32+
define_id_collections!(DefIdMap, DefIdSet, DefId);
33+
define_id_collections!(HirIdMap, HirIdSet, HirId);
34+
define_id_collections!(ItemLocalMap, ItemLocalSet, ItemLocalId);

0 commit comments

Comments
 (0)