mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
alloc id is indexmapped
This commit is contained in:
@@ -107,12 +107,13 @@ fn create_def_id(&mut self, did: DefId) -> stable_mir::DefId {
|
||||
|
||||
fn create_alloc_id(&mut self, aid: AllocId) -> stable_mir::AllocId {
|
||||
// FIXME: this becomes inefficient when we have too many ids
|
||||
if let Some(i) = self.alloc_ids.iter().position(|a| *a == aid) {
|
||||
return stable_mir::AllocId(i);
|
||||
};
|
||||
let id = self.def_ids.len();
|
||||
self.alloc_ids.push(aid);
|
||||
stable_mir::AllocId(id)
|
||||
if let Some(i) = self.alloc_ids.get(&aid) {
|
||||
return *i;
|
||||
} else {
|
||||
let id = self.def_ids.len();
|
||||
self.alloc_ids.insert(aid, stable_mir::AllocId(id));
|
||||
stable_mir::AllocId(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_span(&mut self, span: Span) -> stable_mir::ty::Span {
|
||||
@@ -136,7 +137,7 @@ pub fn run(tcx: TyCtxt<'_>, f: impl FnOnce()) {
|
||||
Tables {
|
||||
tcx,
|
||||
def_ids: fx::FxIndexMap::default(),
|
||||
alloc_ids: vec![],
|
||||
alloc_ids: fx::FxIndexMap::default(),
|
||||
spans: vec![],
|
||||
types: vec![],
|
||||
},
|
||||
|
||||
@@ -196,7 +196,7 @@ fn eq(&self, other: &R) -> bool {
|
||||
pub struct Tables<'tcx> {
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
pub def_ids: FxIndexMap<DefId, stable_mir::DefId>,
|
||||
pub alloc_ids: Vec<AllocId>,
|
||||
pub alloc_ids: FxIndexMap<AllocId, stable_mir::AllocId>,
|
||||
pub spans: Vec<rustc_span::Span>,
|
||||
pub types: Vec<MaybeStable<stable_mir::ty::TyKind, Ty<'tcx>>>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user