|
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;
|
@@ -173,7 +173,11 @@ impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
|
173 | 173 | use mir::Rvalue::*;
|
174 | 174 | match self {
|
175 | 175 | Use(op) => stable_mir::mir::Rvalue::Use(op.stable(tables)),
|
176 |
| - Repeat(op, len) => stable_mir::mir::Rvalue::Repeat(op.stable(tables), opaque(len)), |
| 176 | + Repeat(op, len) => { |
| 177 | + let cnst = ConstantKind::from_const(*len, tables.tcx); |
| 178 | + let len = Const { literal: cnst.stable(tables) }; |
| 179 | + stable_mir::mir::Rvalue::Repeat(op.stable(tables), len) |
| 180 | + } |
177 | 181 | Ref(region, kind, place) => stable_mir::mir::Rvalue::Ref(
|
178 | 182 | opaque(region),
|
179 | 183 | kind.stable(tables),
|
@@ -358,7 +362,11 @@ impl<'tcx> Stable<'tcx> for ty::TermKind<'tcx> {
|
358 | 362 | use stable_mir::ty::TermKind;
|
359 | 363 | match self {
|
360 | 364 | ty::TermKind::Ty(ty) => TermKind::Type(tables.intern_ty(*ty)),
|
361 |
| - ty::TermKind::Const(const_) => TermKind::Const(opaque(const_)), |
| 365 | + ty::TermKind::Const(cnst) => { |
| 366 | + let cnst = ConstantKind::from_const(*cnst, tables.tcx); |
| 367 | + let cnst = Const { literal: cnst.stable(tables) }; |
| 368 | + TermKind::Const(cnst) |
| 369 | + } |
362 | 370 | }
|
363 | 371 | }
|
364 | 372 | }
|
@@ -815,7 +823,10 @@ impl<'tcx> Stable<'tcx> for ty::GenericArgKind<'tcx> {
|
815 | 823 | match self {
|
816 | 824 | ty::GenericArgKind::Lifetime(region) => GenericArgKind::Lifetime(opaque(region)),
|
817 | 825 | ty::GenericArgKind::Type(ty) => GenericArgKind::Type(tables.intern_ty(*ty)),
|
818 |
| - ty::GenericArgKind::Const(const_) => GenericArgKind::Const(opaque(&const_)), |
| 826 | + ty::GenericArgKind::Const(cnst) => { |
| 827 | + let cnst = ConstantKind::from_const(*cnst, tables.tcx); |
| 828 | + GenericArgKind::Const(stable_mir::ty::Const { literal: cnst.stable(tables) }) |
| 829 | + } |
819 | 830 | }
|
820 | 831 | }
|
821 | 832 | }
|
@@ -1008,7 +1019,9 @@ impl<'tcx> Stable<'tcx> for Ty<'tcx> {
|
1008 | 1019 | }
|
1009 | 1020 | ty::Str => TyKind::RigidTy(RigidTy::Str),
|
1010 | 1021 | ty::Array(ty, constant) => {
|
1011 |
| - TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), opaque(constant))) |
| 1022 | + let cnst = ConstantKind::from_const(*constant, tables.tcx); |
| 1023 | + let cnst = stable_mir::ty::Const { literal: cnst.stable(tables) }; |
| 1024 | + TyKind::RigidTy(RigidTy::Array(tables.intern_ty(*ty), cnst)) |
1012 | 1025 | }
|
1013 | 1026 | ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(tables.intern_ty(*ty))),
|
1014 | 1027 | ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
|
|
0 commit comments