Skip to content

Commit 86f5b8a

Browse files
authored
Rollup merge of #90450 - pierwill:rm-hiridvec, r=cjgillot
Remove `rustc_hir::hir_id::HirIdVec` See #90408 (comment): > IIRC, `HirIdVec` is never used, you can delete it. PR #72015 has been abandoned. r? `@cjgillot`
2 parents 365483a + 9137960 commit 86f5b8a

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

compiler/rustc_hir/src/hir_id.rs

-68
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::def_id::{LocalDefId, CRATE_DEF_INDEX};
2-
use rustc_index::vec::IndexVec;
32
use std::fmt;
43

54
/// Uniquely identifies a node in the HIR of the current crate. It is
@@ -66,70 +65,3 @@ pub const CRATE_HIR_ID: HirId = HirId {
6665
owner: LocalDefId { local_def_index: CRATE_DEF_INDEX },
6766
local_id: ItemLocalId::from_u32(0),
6867
};
69-
70-
/// N.B. This collection is currently unused, but will be used by #72015 and future PRs.
71-
#[derive(Clone, Default, Debug, Encodable, Decodable)]
72-
pub struct HirIdVec<T> {
73-
map: IndexVec<LocalDefId, IndexVec<ItemLocalId, T>>,
74-
}
75-
76-
impl<T> HirIdVec<T> {
77-
pub fn push_owner(&mut self, id: LocalDefId) {
78-
self.map.ensure_contains_elem(id, IndexVec::new);
79-
}
80-
81-
pub fn push(&mut self, id: HirId, value: T) {
82-
if id.local_id == ItemLocalId::from_u32(0) {
83-
self.push_owner(id.owner);
84-
}
85-
let submap = &mut self.map[id.owner];
86-
let _ret_id = submap.push(value);
87-
debug_assert_eq!(_ret_id, id.local_id);
88-
}
89-
90-
pub fn push_sparse(&mut self, id: HirId, value: T)
91-
where
92-
T: Default,
93-
{
94-
self.map.ensure_contains_elem(id.owner, IndexVec::new);
95-
let submap = &mut self.map[id.owner];
96-
let i = id.local_id.index();
97-
let len = submap.len();
98-
if i >= len {
99-
submap.extend(std::iter::repeat_with(T::default).take(i - len + 1));
100-
}
101-
submap[id.local_id] = value;
102-
}
103-
104-
pub fn get(&self, id: HirId) -> Option<&T> {
105-
self.map.get(id.owner)?.get(id.local_id)
106-
}
107-
108-
pub fn get_owner(&self, id: LocalDefId) -> &IndexVec<ItemLocalId, T> {
109-
&self.map[id]
110-
}
111-
112-
pub fn iter(&self) -> impl Iterator<Item = &T> {
113-
self.map.iter().flat_map(|la| la.iter())
114-
}
115-
116-
pub fn iter_enumerated(&self) -> impl Iterator<Item = (HirId, &T)> {
117-
self.map.iter_enumerated().flat_map(|(owner, la)| {
118-
la.iter_enumerated().map(move |(local_id, attr)| (HirId { owner, local_id }, attr))
119-
})
120-
}
121-
}
122-
123-
impl<T> std::ops::Index<HirId> for HirIdVec<T> {
124-
type Output = T;
125-
126-
fn index(&self, id: HirId) -> &T {
127-
&self.map[id.owner][id.local_id]
128-
}
129-
}
130-
131-
impl<T> std::ops::IndexMut<HirId> for HirIdVec<T> {
132-
fn index_mut(&mut self, id: HirId) -> &mut T {
133-
&mut self.map[id.owner][id.local_id]
134-
}
135-
}

0 commit comments

Comments
 (0)