|
10 | 10 | use crate::rustc_internal::{self, opaque};
|
11 | 11 | use crate::stable_mir::mir::{CopyNonOverlapping, UserTypeProjection, VariantIdx};
|
12 | 12 | use crate::stable_mir::ty::{
|
13 |
| - allocation_filter, new_allocation, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy, |
| 13 | + allocation_filter, new_allocation, Const, FloatTy, IntTy, Movability, RigidTy, TyKind, UintTy, |
14 | 14 | };
|
15 | 15 | use crate::stable_mir::{self, Context};
|
16 | 16 | use rustc_hir as hir;
|
@@ -187,7 +187,11 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
|
187 | 187 | use mir::Rvalue::*;
|
188 | 188 | match self {
|
189 | 189 | Use(op) => stable_mir::mir::Rvalue::Use(op.stable(tables)),
|
190 |
| - Repeat(op, len) => stable_mir::mir::Rvalue::Repeat(op.stable(tables), opaque(len)), |
| 190 | + Repeat(op, len) => { |
| 191 | + let cnst = ConstantKind::from_const(*len, tables.tcx); |
| 192 | + let len = Const { literal: cnst.stable(tables) }; |
| 193 | + stable_mir::mir::Rvalue::Repeat(op.stable(tables), len) |
| 194 | + } |
191 | 195 | Ref(region, kind, place) => stable_mir::mir::Rvalue::Ref(
|
192 | 196 | opaque(region),
|
193 | 197 | kind.stable(tables),
|
@@ -372,7 +376,11 @@ impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
|
372 | 376 | use stable_mir::ty::TermKind;
|
373 | 377 | match self {
|
374 | 378 | ty::TermKind::Ty(ty) => TermKind::Type(tables.intern_ty(*ty)),
|
375 |
| - ty::TermKind::Const(const_) => TermKind::Const(opaque(const_)), |
| 379 | + ty::TermKind::Const(cnst) => { |
| 380 | + let cnst = ConstantKind::from_const(*cnst, tables.tcx); |
| 381 | + let cnst = Const { literal: cnst.stable(tables) }; |
| 382 | + TermKind::Const(cnst) |
| 383 | + } |
376 | 384 | }
|
377 | 385 | }
|
378 | 386 | }
|
@@ -829,7 +837,10 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
|
829 | 837 | match self {
|
830 | 838 | ty::GenericArgKind::Lifetime(region) => GenericArgKind::Lifetime(opaque(region)),
|
831 | 839 | ty::GenericArgKind::Type(ty) => GenericArgKind::Type(tables.intern_ty(*ty)),
|
832 |
| - ty::GenericArgKind::Const(const_) => GenericArgKind::Const(opaque(&const_)), |
| 840 | + ty::GenericArgKind::Const(cnst) => { |
| 841 | + let cnst = ConstantKind::from_const(*cnst, tables.tcx); |
| 842 | + GenericArgKind::Const(stable_mir::ty::Const { literal: cnst.stable(tables) }) |
| 843 | + } |
833 | 844 | }
|
834 | 845 | }
|
835 | 846 | }
|
@@ -1035,7 +1046,9 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
|
1035 | 1046 | }
|
1036 | 1047 | ty::Str => TyKind::RigidTy(RigidTy::Str),
|
1037 | 1048 | ty::Array(ty, constant) => {
|
1038 |
| - TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), opaque(constant))) |
| 1049 | + let cnst = ConstantKind::from_const(*constant, tables.tcx); |
| 1050 | + let cnst = stable_mir::ty::Const { literal: cnst.stable(tables) }; |
| 1051 | + TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), cnst)) |
1039 | 1052 | }
|
1040 | 1053 | ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(tables.intern_ty(*ty))),
|
1041 | 1054 | ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
|
|
0 commit comments