|
4 | 4 | //! until stable MIR is complete. |
5 | 5 |
|
6 | 6 | use std::cell::{Cell, RefCell}; |
7 | | -use std::fmt::Debug; |
8 | | -use std::hash::Hash; |
9 | | -use std::ops::Index; |
10 | 7 |
|
11 | | -use rustc_data_structures::fx; |
12 | | -use rustc_data_structures::fx::FxIndexMap; |
13 | 8 | use rustc_middle::ty::TyCtxt; |
14 | 9 | use rustc_span::def_id::CrateNum; |
15 | 10 | use scoped_tls::scoped_thread_local; |
16 | 11 | use stable_mir::Error; |
17 | 12 | use stable_mir::convert::{RustcInternal, Stable}; |
18 | 13 |
|
19 | 14 | use crate::rustc_smir::context::SmirCtxt; |
20 | | -use crate::rustc_smir::{Bridge, IndexedVal, SmirContainer, Tables}; |
| 15 | +use crate::rustc_smir::{Bridge, SmirContainer, Tables}; |
21 | 16 | use crate::stable_mir; |
22 | 17 |
|
23 | 18 | pub mod pretty; |
@@ -273,35 +268,3 @@ macro_rules! run_driver { |
273 | 268 | StableMir::new($callback).run($args) |
274 | 269 | }}; |
275 | 270 | } |
276 | | - |
277 | | -/// Similar to rustc's `FxIndexMap`, `IndexMap` with extra |
278 | | -/// safety features added. |
279 | | -pub struct IndexMap<K, V> { |
280 | | - index_map: fx::FxIndexMap<K, V>, |
281 | | -} |
282 | | - |
283 | | -impl<K, V> Default for IndexMap<K, V> { |
284 | | - fn default() -> Self { |
285 | | - Self { index_map: FxIndexMap::default() } |
286 | | - } |
287 | | -} |
288 | | - |
289 | | -impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> IndexMap<K, V> { |
290 | | - pub fn create_or_fetch(&mut self, key: K) -> V { |
291 | | - let len = self.index_map.len(); |
292 | | - let v = self.index_map.entry(key).or_insert(V::to_val(len)); |
293 | | - *v |
294 | | - } |
295 | | -} |
296 | | - |
297 | | -impl<K: PartialEq + Hash + Eq, V: Copy + Debug + PartialEq + IndexedVal> Index<V> |
298 | | - for IndexMap<K, V> |
299 | | -{ |
300 | | - type Output = K; |
301 | | - |
302 | | - fn index(&self, index: V) -> &Self::Output { |
303 | | - let (k, v) = self.index_map.get_index(index.to_index()).unwrap(); |
304 | | - assert_eq!(*v, index, "Provided value doesn't match with indexed value"); |
305 | | - k |
306 | | - } |
307 | | -} |
0 commit comments