|
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, GenericArgKind, GenericArgs, IntTy, RigidTy, TyKind, UintTy}; |
| 11 | +use crate::stable_mir::ty::{FloatTy, GenericArgKind, GenericArgs, IntTy, Movability, RigidTy, TyKind, UintTy}; |
12 | 12 | use crate::stable_mir::{self, Context};
|
| 13 | +use rustc_hir as hir; |
13 | 14 | use rustc_middle::mir;
|
14 | 15 | use rustc_middle::ty::{self, Ty, TyCtxt};
|
15 | 16 | use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
@@ -167,7 +168,30 @@ impl<'tcx> Tables<'tcx> {
|
167 | 168 | .collect(),
|
168 | 169 | ),
|
169 | 170 | )),
|
170 |
| - ty::Generator(_, _, _) => todo!(), |
| 171 | + ty::Generator(def_id, generic_args, movability) => TyKind::RigidTy(RigidTy::Generator( |
| 172 | + rustc_internal::generator_def(*def_id), |
| 173 | + GenericArgs( |
| 174 | + generic_args |
| 175 | + .iter() |
| 176 | + .map(|arg| match arg.unpack() { |
| 177 | + ty::GenericArgKind::Lifetime(region) => { |
| 178 | + GenericArgKind::Lifetime(opaque(®ion)) |
| 179 | + } |
| 180 | + ty::GenericArgKind::Type(ty) => { |
| 181 | + GenericArgKind::Type(self.intern_ty(ty)) |
| 182 | + } |
| 183 | + ty::GenericArgKind::Const(const_) => { |
| 184 | + GenericArgKind::Const(opaque(&const_)) |
| 185 | + } |
| 186 | + }) |
| 187 | + .collect(), |
| 188 | + ), |
| 189 | + match movability { |
| 190 | + hir::Movability::Static => Movability::Static, |
| 191 | + hir::Movability::Movable => Movability::Movable, |
| 192 | + |
| 193 | + } |
| 194 | + )), |
171 | 195 | ty::Never => TyKind::RigidTy(RigidTy::Never),
|
172 | 196 | ty::Tuple(fields) => TyKind::RigidTy(RigidTy::Tuple(
|
173 | 197 | fields.iter().map(|ty| self.intern_ty(ty)).collect(),
|
|
0 commit comments