|  | 
| 8 | 8 | //! For now, we are developing everything inside `rustc`, thus, we keep this module private. | 
| 9 | 9 | 
 | 
| 10 | 10 | use crate::rustc_internal::{self, opaque}; | 
| 11 |  | -use crate::stable_mir::ty::{FloatTy, IntTy, RigidTy, TyKind, UintTy}; | 
|  | 11 | +use crate::stable_mir::ty::{AdtSubsts, FloatTy, GenericArgKind, IntTy, RigidTy, TyKind, UintTy}; | 
| 12 | 12 | use crate::stable_mir::{self, Context}; | 
| 13 | 13 | use rustc_middle::mir; | 
| 14 | 14 | use rustc_middle::ty::{self, Ty, TyCtxt}; | 
| @@ -94,7 +94,25 @@ impl<'tcx> Tables<'tcx> { | 
| 94 | 94 |                 ty::FloatTy::F32 => TyKind::RigidTy(RigidTy::Float(FloatTy::F32)), | 
| 95 | 95 |                 ty::FloatTy::F64 => TyKind::RigidTy(RigidTy::Float(FloatTy::F64)), | 
| 96 | 96 |             }, | 
| 97 |  | -            ty::Adt(_, _) => todo!(), | 
|  | 97 | +            ty::Adt(adt_def, substs) => TyKind::RigidTy(RigidTy::Adt( | 
|  | 98 | +                rustc_internal::adt_def(adt_def.did()), | 
|  | 99 | +                AdtSubsts( | 
|  | 100 | +                    substs | 
|  | 101 | +                        .iter() | 
|  | 102 | +                        .map(|arg| match arg.unpack() { | 
|  | 103 | +                            ty::GenericArgKind::Lifetime(region) => { | 
|  | 104 | +                                GenericArgKind::Lifetime(opaque(®ion)) | 
|  | 105 | +                            } | 
|  | 106 | +                            ty::GenericArgKind::Type(ty) => { | 
|  | 107 | +                                GenericArgKind::Type(self.intern_ty(ty)) | 
|  | 108 | +                            } | 
|  | 109 | +                            ty::GenericArgKind::Const(const_) => { | 
|  | 110 | +                                GenericArgKind::Const(opaque(&const_)) | 
|  | 111 | +                            } | 
|  | 112 | +                        }) | 
|  | 113 | +                        .collect(), | 
|  | 114 | +                ), | 
|  | 115 | +            )), | 
| 98 | 116 |             ty::Foreign(_) => todo!(), | 
| 99 | 117 |             ty::Str => todo!(), | 
| 100 | 118 |             ty::Array(_, _) => todo!(), | 
| @@ -149,13 +167,6 @@ pub(crate) trait Stable { | 
| 149 | 167 |     fn stable(&self) -> Self::T; | 
| 150 | 168 | } | 
| 151 | 169 | 
 | 
| 152 |  | -impl Stable for DefId { | 
| 153 |  | -    type T = stable_mir::CrateItem; | 
| 154 |  | -    fn stable(&self) -> Self::T { | 
| 155 |  | -        rustc_internal::crate_item(*self) | 
| 156 |  | -    } | 
| 157 |  | -} | 
| 158 |  | - | 
| 159 | 170 | impl<'tcx> Stable for mir::Statement<'tcx> { | 
| 160 | 171 |     type T = stable_mir::mir::Statement; | 
| 161 | 172 |     fn stable(&self) -> Self::T { | 
| @@ -190,7 +201,9 @@ impl<'tcx> Stable for mir::Rvalue<'tcx> { | 
| 190 | 201 |             Ref(region, kind, place) => { | 
| 191 | 202 |                 stable_mir::mir::Rvalue::Ref(opaque(region), kind.stable(), place.stable()) | 
| 192 | 203 |             } | 
| 193 |  | -            ThreadLocalRef(def_id) => stable_mir::mir::Rvalue::ThreadLocalRef(def_id.stable()), | 
|  | 204 | +            ThreadLocalRef(def_id) => { | 
|  | 205 | +                stable_mir::mir::Rvalue::ThreadLocalRef(rustc_internal::crate_item(*def_id)) | 
|  | 206 | +            } | 
| 194 | 207 |             AddressOf(mutability, place) => { | 
| 195 | 208 |                 stable_mir::mir::Rvalue::AddressOf(mutability.stable(), place.stable()) | 
| 196 | 209 |             } | 
|  | 
0 commit comments