Index def_ids directly
This commit is contained in:
parent
af6299a1f7
commit
17ffb59d39
@ -21,7 +21,7 @@ fn with_tables<R>(mut f: impl FnMut(&mut Tables<'_>) -> R) -> R {
|
||||
}
|
||||
|
||||
pub fn item_def_id(item: &stable_mir::CrateItem) -> DefId {
|
||||
with_tables(|t| t.item_def_id(item))
|
||||
with_tables(|t| t[item.0])
|
||||
}
|
||||
|
||||
pub fn crate_item(did: DefId) -> stable_mir::CrateItem {
|
||||
@ -78,22 +78,6 @@ fn index(&self, index: stable_mir::DefId) -> &Self::Output {
|
||||
}
|
||||
|
||||
impl<'tcx> Tables<'tcx> {
|
||||
pub fn item_def_id(&self, item: &stable_mir::CrateItem) -> DefId {
|
||||
self[item.0]
|
||||
}
|
||||
|
||||
pub fn trait_def_id(&self, trait_def: &stable_mir::ty::TraitDef) -> DefId {
|
||||
self[trait_def.0]
|
||||
}
|
||||
|
||||
pub fn impl_trait_def_id(&self, impl_def: &stable_mir::ty::ImplDef) -> DefId {
|
||||
self[impl_def.0]
|
||||
}
|
||||
|
||||
pub fn generic_def_id(&self, generic_def: &stable_mir::ty::GenericDef) -> DefId {
|
||||
self[generic_def.0]
|
||||
}
|
||||
|
||||
pub fn crate_item(&mut self, did: DefId) -> stable_mir::CrateItem {
|
||||
stable_mir::CrateItem(self.create_def_id(did))
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ fn all_trait_decls(&mut self) -> stable_mir::TraitDecls {
|
||||
}
|
||||
|
||||
fn trait_decl(&mut self, trait_def: &stable_mir::ty::TraitDef) -> stable_mir::ty::TraitDecl {
|
||||
let def_id = self.trait_def_id(trait_def);
|
||||
let def_id = self[trait_def.0];
|
||||
let trait_def = self.tcx.trait_def(def_id);
|
||||
trait_def.stable(self)
|
||||
}
|
||||
@ -68,13 +68,13 @@ fn all_trait_impls(&mut self) -> stable_mir::ImplTraitDecls {
|
||||
}
|
||||
|
||||
fn trait_impl(&mut self, impl_def: &stable_mir::ty::ImplDef) -> stable_mir::ty::ImplTrait {
|
||||
let def_id = self.impl_trait_def_id(impl_def);
|
||||
let def_id = self[impl_def.0];
|
||||
let impl_trait = self.tcx.impl_trait_ref(def_id).unwrap();
|
||||
impl_trait.stable(self)
|
||||
}
|
||||
|
||||
fn mir_body(&mut self, item: &stable_mir::CrateItem) -> stable_mir::mir::Body {
|
||||
let def_id = self.item_def_id(item);
|
||||
let def_id = self[item.0];
|
||||
let mir = self.tcx.optimized_mir(def_id);
|
||||
stable_mir::mir::Body {
|
||||
blocks: mir
|
||||
|
Loading…
Reference in New Issue
Block a user