mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add Foreign to SMIR
This commit is contained in:
parent
8d361cbd91
commit
9b32319205
@ -31,6 +31,10 @@ pub fn adt_def(did: DefId) -> stable_mir::ty::AdtDef {
|
||||
with_tables(|t| t.adt_def(did))
|
||||
}
|
||||
|
||||
pub fn foreign_def(did: DefId) -> stable_mir::ty::ForeignDef {
|
||||
with_tables(|t| t.foreign_def(did))
|
||||
}
|
||||
|
||||
impl<'tcx> Tables<'tcx> {
|
||||
pub fn item_def_id(&self, item: &stable_mir::CrateItem) -> DefId {
|
||||
self.def_ids[item.0]
|
||||
@ -44,6 +48,10 @@ impl<'tcx> Tables<'tcx> {
|
||||
stable_mir::ty::AdtDef(self.create_def_id(did))
|
||||
}
|
||||
|
||||
pub fn foreign_def(&mut self, did: DefId) -> stable_mir::ty::ForeignDef {
|
||||
stable_mir::ty::ForeignDef(self.create_def_id(did))
|
||||
}
|
||||
|
||||
fn create_def_id(&mut self, did: DefId) -> stable_mir::DefId {
|
||||
// FIXME: this becomes inefficient when we have too many ids
|
||||
for (i, &d) in self.def_ids.iter().enumerate() {
|
||||
|
@ -113,7 +113,9 @@ impl<'tcx> Tables<'tcx> {
|
||||
.collect(),
|
||||
),
|
||||
)),
|
||||
ty::Foreign(_) => todo!(),
|
||||
ty::Foreign(def_id) => {
|
||||
TyKind::RigidTy(RigidTy::Foreign(rustc_internal::foreign_def(*def_id)))
|
||||
}
|
||||
ty::Str => TyKind::RigidTy(RigidTy::Str),
|
||||
ty::Array(ty, constant) => {
|
||||
TyKind::RigidTy(RigidTy::Array(self.intern_ty(*ty), opaque(constant)))
|
||||
|
@ -26,6 +26,7 @@ pub enum RigidTy {
|
||||
Uint(UintTy),
|
||||
Float(FloatTy),
|
||||
Adt(AdtDef, AdtSubsts),
|
||||
Foreign(ForeignDef),
|
||||
Str,
|
||||
Array(Ty, Const),
|
||||
Slice(Ty),
|
||||
@ -60,6 +61,9 @@ pub enum FloatTy {
|
||||
F64,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct ForeignDef(pub(crate) DefId);
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct AdtDef(pub(crate) DefId);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user