Add tables to Stable::stable

This commit is contained in:
Santiago Pastorino 2023-07-20 22:20:53 -03:00
parent 092e4f46be
commit cbabd00c12
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF

View File

@ -49,8 +49,12 @@ impl<'tcx> Context for Tables<'tcx> {
.basic_blocks .basic_blocks
.iter() .iter()
.map(|block| stable_mir::mir::BasicBlock { .map(|block| stable_mir::mir::BasicBlock {
terminator: block.terminator().stable(), terminator: block.terminator().stable(self),
statements: block.statements.iter().map(mir::Statement::stable).collect(), statements: block
.statements
.iter()
.map(|statement| statement.stable(self))
.collect(),
}) })
.collect(), .collect(),
locals: mir.local_decls.iter().map(|decl| self.intern_ty(decl.ty)).collect(), locals: mir.local_decls.iter().map(|decl| self.intern_ty(decl.ty)).collect(),
@ -110,11 +114,13 @@ impl<'tcx> Tables<'tcx> {
} }
ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(self.intern_ty(*ty))), ty::Slice(ty) => TyKind::RigidTy(RigidTy::Slice(self.intern_ty(*ty))),
ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => { ty::RawPtr(ty::TypeAndMut { ty, mutbl }) => {
TyKind::RigidTy(RigidTy::RawPtr(self.intern_ty(*ty), mutbl.stable())) TyKind::RigidTy(RigidTy::RawPtr(self.intern_ty(*ty), mutbl.stable(self)))
}
ty::Ref(region, ty, mutbl) => {
TyKind::RigidTy(RigidTy::Ref(opaque(region), self.intern_ty(*ty), mutbl.stable()))
} }
ty::Ref(region, ty, mutbl) => TyKind::RigidTy(RigidTy::Ref(
opaque(region),
self.intern_ty(*ty),
mutbl.stable(self),
)),
ty::FnDef(def_id, generic_args) => TyKind::RigidTy(RigidTy::FnDef( ty::FnDef(def_id, generic_args) => TyKind::RigidTy(RigidTy::FnDef(
rustc_internal::fn_def(*def_id), rustc_internal::fn_def(*def_id),
self.generic_args(generic_args), self.generic_args(generic_args),
@ -187,20 +193,20 @@ fn smir_crate(tcx: TyCtxt<'_>, crate_num: CrateNum) -> stable_mir::Crate {
} }
/// Trait used to convert between an internal MIR type to a Stable MIR type. /// Trait used to convert between an internal MIR type to a Stable MIR type.
pub(crate) trait Stable { pub(crate) trait Stable<'tcx> {
/// The stable representation of the type implementing Stable. /// The stable representation of the type implementing Stable.
type T; type T;
/// Converts an object to the equivalent Stable MIR representation. /// Converts an object to the equivalent Stable MIR representation.
fn stable(&self) -> Self::T; fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T;
} }
impl<'tcx> Stable for mir::Statement<'tcx> { impl<'tcx> Stable<'tcx> for mir::Statement<'tcx> {
type T = stable_mir::mir::Statement; type T = stable_mir::mir::Statement;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use rustc_middle::mir::StatementKind::*; use rustc_middle::mir::StatementKind::*;
match &self.kind { match &self.kind {
Assign(assign) => { Assign(assign) => {
stable_mir::mir::Statement::Assign(assign.0.stable(), assign.1.stable()) stable_mir::mir::Statement::Assign(assign.0.stable(tables), assign.1.stable(tables))
} }
FakeRead(_) => todo!(), FakeRead(_) => todo!(),
SetDiscriminant { .. } => todo!(), SetDiscriminant { .. } => todo!(),
@ -218,45 +224,51 @@ impl<'tcx> Stable for mir::Statement<'tcx> {
} }
} }
impl<'tcx> Stable for mir::Rvalue<'tcx> { impl<'tcx> Stable<'tcx> for mir::Rvalue<'tcx> {
type T = stable_mir::mir::Rvalue; type T = stable_mir::mir::Rvalue;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::Rvalue::*; use mir::Rvalue::*;
match self { match self {
Use(op) => stable_mir::mir::Rvalue::Use(op.stable()), Use(op) => stable_mir::mir::Rvalue::Use(op.stable(tables)),
Repeat(_, _) => todo!(), Repeat(_, _) => todo!(),
Ref(region, kind, place) => { Ref(region, kind, place) => stable_mir::mir::Rvalue::Ref(
stable_mir::mir::Rvalue::Ref(opaque(region), kind.stable(), place.stable()) opaque(region),
} kind.stable(tables),
place.stable(tables),
),
ThreadLocalRef(def_id) => { ThreadLocalRef(def_id) => {
stable_mir::mir::Rvalue::ThreadLocalRef(rustc_internal::crate_item(*def_id)) stable_mir::mir::Rvalue::ThreadLocalRef(rustc_internal::crate_item(*def_id))
} }
AddressOf(mutability, place) => { AddressOf(mutability, place) => {
stable_mir::mir::Rvalue::AddressOf(mutability.stable(), place.stable()) stable_mir::mir::Rvalue::AddressOf(mutability.stable(tables), place.stable(tables))
} }
Len(place) => stable_mir::mir::Rvalue::Len(place.stable()), Len(place) => stable_mir::mir::Rvalue::Len(place.stable(tables)),
Cast(_, _, _) => todo!(), Cast(_, _, _) => todo!(),
BinaryOp(bin_op, ops) => { BinaryOp(bin_op, ops) => stable_mir::mir::Rvalue::BinaryOp(
stable_mir::mir::Rvalue::BinaryOp(bin_op.stable(), ops.0.stable(), ops.1.stable()) bin_op.stable(tables),
} ops.0.stable(tables),
ops.1.stable(tables),
),
CheckedBinaryOp(bin_op, ops) => stable_mir::mir::Rvalue::CheckedBinaryOp( CheckedBinaryOp(bin_op, ops) => stable_mir::mir::Rvalue::CheckedBinaryOp(
bin_op.stable(), bin_op.stable(tables),
ops.0.stable(), ops.0.stable(tables),
ops.1.stable(), ops.1.stable(tables),
), ),
NullaryOp(_, _) => todo!(), NullaryOp(_, _) => todo!(),
UnaryOp(un_op, op) => stable_mir::mir::Rvalue::UnaryOp(un_op.stable(), op.stable()), UnaryOp(un_op, op) => {
Discriminant(place) => stable_mir::mir::Rvalue::Discriminant(place.stable()), stable_mir::mir::Rvalue::UnaryOp(un_op.stable(tables), op.stable(tables))
}
Discriminant(place) => stable_mir::mir::Rvalue::Discriminant(place.stable(tables)),
Aggregate(_, _) => todo!(), Aggregate(_, _) => todo!(),
ShallowInitBox(_, _) => todo!(), ShallowInitBox(_, _) => todo!(),
CopyForDeref(place) => stable_mir::mir::Rvalue::CopyForDeref(place.stable()), CopyForDeref(place) => stable_mir::mir::Rvalue::CopyForDeref(place.stable(tables)),
} }
} }
} }
impl Stable for mir::Mutability { impl<'tcx> Stable<'tcx> for mir::Mutability {
type T = stable_mir::mir::Mutability; type T = stable_mir::mir::Mutability;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use mir::Mutability::*; use mir::Mutability::*;
match *self { match *self {
Not => stable_mir::mir::Mutability::Not, Not => stable_mir::mir::Mutability::Not,
@ -265,21 +277,21 @@ impl Stable for mir::Mutability {
} }
} }
impl Stable for mir::BorrowKind { impl<'tcx> Stable<'tcx> for mir::BorrowKind {
type T = stable_mir::mir::BorrowKind; type T = stable_mir::mir::BorrowKind;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::BorrowKind::*; use mir::BorrowKind::*;
match *self { match *self {
Shared => stable_mir::mir::BorrowKind::Shared, Shared => stable_mir::mir::BorrowKind::Shared,
Shallow => stable_mir::mir::BorrowKind::Shallow, Shallow => stable_mir::mir::BorrowKind::Shallow,
Mut { kind } => stable_mir::mir::BorrowKind::Mut { kind: kind.stable() }, Mut { kind } => stable_mir::mir::BorrowKind::Mut { kind: kind.stable(tables) },
} }
} }
} }
impl Stable for mir::MutBorrowKind { impl<'tcx> Stable<'tcx> for mir::MutBorrowKind {
type T = stable_mir::mir::MutBorrowKind; type T = stable_mir::mir::MutBorrowKind;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use mir::MutBorrowKind::*; use mir::MutBorrowKind::*;
match *self { match *self {
Default => stable_mir::mir::MutBorrowKind::Default, Default => stable_mir::mir::MutBorrowKind::Default,
@ -289,28 +301,28 @@ impl Stable for mir::MutBorrowKind {
} }
} }
impl<'tcx> Stable for mir::NullOp<'tcx> { impl<'tcx> Stable<'tcx> for mir::NullOp<'tcx> {
type T = stable_mir::mir::NullOp; type T = stable_mir::mir::NullOp;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::NullOp::*; use mir::NullOp::*;
match self { match self {
SizeOf => stable_mir::mir::NullOp::SizeOf, SizeOf => stable_mir::mir::NullOp::SizeOf,
AlignOf => stable_mir::mir::NullOp::AlignOf, AlignOf => stable_mir::mir::NullOp::AlignOf,
OffsetOf(indices) => { OffsetOf(indices) => stable_mir::mir::NullOp::OffsetOf(
stable_mir::mir::NullOp::OffsetOf(indices.iter().map(|idx| idx.stable()).collect()) indices.iter().map(|idx| idx.stable(tables)).collect(),
} ),
} }
} }
} }
impl Stable for mir::CastKind { impl<'tcx> Stable<'tcx> for mir::CastKind {
type T = stable_mir::mir::CastKind; type T = stable_mir::mir::CastKind;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::CastKind::*; use mir::CastKind::*;
match self { match self {
PointerExposeAddress => stable_mir::mir::CastKind::PointerExposeAddress, PointerExposeAddress => stable_mir::mir::CastKind::PointerExposeAddress,
PointerFromExposedAddress => stable_mir::mir::CastKind::PointerFromExposedAddress, PointerFromExposedAddress => stable_mir::mir::CastKind::PointerFromExposedAddress,
PointerCoercion(c) => stable_mir::mir::CastKind::PointerCoercion(c.stable()), PointerCoercion(c) => stable_mir::mir::CastKind::PointerCoercion(c.stable(tables)),
DynStar => stable_mir::mir::CastKind::DynStar, DynStar => stable_mir::mir::CastKind::DynStar,
IntToInt => stable_mir::mir::CastKind::IntToInt, IntToInt => stable_mir::mir::CastKind::IntToInt,
FloatToInt => stable_mir::mir::CastKind::FloatToInt, FloatToInt => stable_mir::mir::CastKind::FloatToInt,
@ -323,15 +335,15 @@ impl Stable for mir::CastKind {
} }
} }
impl Stable for ty::adjustment::PointerCoercion { impl<'tcx> Stable<'tcx> for ty::adjustment::PointerCoercion {
type T = stable_mir::mir::PointerCoercion; type T = stable_mir::mir::PointerCoercion;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use ty::adjustment::PointerCoercion; use ty::adjustment::PointerCoercion;
match self { match self {
PointerCoercion::ReifyFnPointer => stable_mir::mir::PointerCoercion::ReifyFnPointer, PointerCoercion::ReifyFnPointer => stable_mir::mir::PointerCoercion::ReifyFnPointer,
PointerCoercion::UnsafeFnPointer => stable_mir::mir::PointerCoercion::UnsafeFnPointer, PointerCoercion::UnsafeFnPointer => stable_mir::mir::PointerCoercion::UnsafeFnPointer,
PointerCoercion::ClosureFnPointer(unsafety) => { PointerCoercion::ClosureFnPointer(unsafety) => {
stable_mir::mir::PointerCoercion::ClosureFnPointer(unsafety.stable()) stable_mir::mir::PointerCoercion::ClosureFnPointer(unsafety.stable(tables))
} }
PointerCoercion::MutToConstPointer => { PointerCoercion::MutToConstPointer => {
stable_mir::mir::PointerCoercion::MutToConstPointer stable_mir::mir::PointerCoercion::MutToConstPointer
@ -342,9 +354,9 @@ impl Stable for ty::adjustment::PointerCoercion {
} }
} }
impl Stable for rustc_hir::Unsafety { impl<'tcx> Stable<'tcx> for rustc_hir::Unsafety {
type T = stable_mir::mir::Safety; type T = stable_mir::mir::Safety;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
match self { match self {
rustc_hir::Unsafety::Unsafe => stable_mir::mir::Safety::Unsafe, rustc_hir::Unsafety::Unsafe => stable_mir::mir::Safety::Unsafe,
rustc_hir::Unsafety::Normal => stable_mir::mir::Safety::Normal, rustc_hir::Unsafety::Normal => stable_mir::mir::Safety::Normal,
@ -352,28 +364,28 @@ impl Stable for rustc_hir::Unsafety {
} }
} }
impl Stable for FieldIdx { impl<'tcx> Stable<'tcx> for FieldIdx {
type T = usize; type T = usize;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
self.as_usize() self.as_usize()
} }
} }
impl<'tcx> Stable for mir::Operand<'tcx> { impl<'tcx> Stable<'tcx> for mir::Operand<'tcx> {
type T = stable_mir::mir::Operand; type T = stable_mir::mir::Operand;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use mir::Operand::*; use mir::Operand::*;
match self { match self {
Copy(place) => stable_mir::mir::Operand::Copy(place.stable()), Copy(place) => stable_mir::mir::Operand::Copy(place.stable(tables)),
Move(place) => stable_mir::mir::Operand::Move(place.stable()), Move(place) => stable_mir::mir::Operand::Move(place.stable(tables)),
Constant(c) => stable_mir::mir::Operand::Constant(c.to_string()), Constant(c) => stable_mir::mir::Operand::Constant(c.to_string()),
} }
} }
} }
impl<'tcx> Stable for mir::Place<'tcx> { impl<'tcx> Stable<'tcx> for mir::Place<'tcx> {
type T = stable_mir::mir::Place; type T = stable_mir::mir::Place;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
stable_mir::mir::Place { stable_mir::mir::Place {
local: self.local.as_usize(), local: self.local.as_usize(),
projection: format!("{:?}", self.projection), projection: format!("{:?}", self.projection),
@ -381,9 +393,9 @@ impl<'tcx> Stable for mir::Place<'tcx> {
} }
} }
impl Stable for mir::UnwindAction { impl<'tcx> Stable<'tcx> for mir::UnwindAction {
type T = stable_mir::mir::UnwindAction; type T = stable_mir::mir::UnwindAction;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use rustc_middle::mir::UnwindAction; use rustc_middle::mir::UnwindAction;
match self { match self {
UnwindAction::Continue => stable_mir::mir::UnwindAction::Continue, UnwindAction::Continue => stable_mir::mir::UnwindAction::Continue,
@ -394,46 +406,48 @@ impl Stable for mir::UnwindAction {
} }
} }
impl<'tcx> Stable for mir::AssertMessage<'tcx> { impl<'tcx> Stable<'tcx> for mir::AssertMessage<'tcx> {
type T = stable_mir::mir::AssertMessage; type T = stable_mir::mir::AssertMessage;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use rustc_middle::mir::AssertKind; use rustc_middle::mir::AssertKind;
match self { match self {
AssertKind::BoundsCheck { len, index } => stable_mir::mir::AssertMessage::BoundsCheck { AssertKind::BoundsCheck { len, index } => stable_mir::mir::AssertMessage::BoundsCheck {
len: len.stable(), len: len.stable(tables),
index: index.stable(), index: index.stable(tables),
}, },
AssertKind::Overflow(bin_op, op1, op2) => stable_mir::mir::AssertMessage::Overflow( AssertKind::Overflow(bin_op, op1, op2) => stable_mir::mir::AssertMessage::Overflow(
bin_op.stable(), bin_op.stable(tables),
op1.stable(), op1.stable(tables),
op2.stable(), op2.stable(tables),
), ),
AssertKind::OverflowNeg(op) => stable_mir::mir::AssertMessage::OverflowNeg(op.stable()), AssertKind::OverflowNeg(op) => {
stable_mir::mir::AssertMessage::OverflowNeg(op.stable(tables))
}
AssertKind::DivisionByZero(op) => { AssertKind::DivisionByZero(op) => {
stable_mir::mir::AssertMessage::DivisionByZero(op.stable()) stable_mir::mir::AssertMessage::DivisionByZero(op.stable(tables))
} }
AssertKind::RemainderByZero(op) => { AssertKind::RemainderByZero(op) => {
stable_mir::mir::AssertMessage::RemainderByZero(op.stable()) stable_mir::mir::AssertMessage::RemainderByZero(op.stable(tables))
} }
AssertKind::ResumedAfterReturn(generator) => { AssertKind::ResumedAfterReturn(generator) => {
stable_mir::mir::AssertMessage::ResumedAfterReturn(generator.stable()) stable_mir::mir::AssertMessage::ResumedAfterReturn(generator.stable(tables))
} }
AssertKind::ResumedAfterPanic(generator) => { AssertKind::ResumedAfterPanic(generator) => {
stable_mir::mir::AssertMessage::ResumedAfterPanic(generator.stable()) stable_mir::mir::AssertMessage::ResumedAfterPanic(generator.stable(tables))
} }
AssertKind::MisalignedPointerDereference { required, found } => { AssertKind::MisalignedPointerDereference { required, found } => {
stable_mir::mir::AssertMessage::MisalignedPointerDereference { stable_mir::mir::AssertMessage::MisalignedPointerDereference {
required: required.stable(), required: required.stable(tables),
found: found.stable(), found: found.stable(tables),
} }
} }
} }
} }
} }
impl Stable for mir::BinOp { impl<'tcx> Stable<'tcx> for mir::BinOp {
type T = stable_mir::mir::BinOp; type T = stable_mir::mir::BinOp;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use mir::BinOp; use mir::BinOp;
match self { match self {
BinOp::Add => stable_mir::mir::BinOp::Add, BinOp::Add => stable_mir::mir::BinOp::Add,
@ -462,9 +476,9 @@ impl Stable for mir::BinOp {
} }
} }
impl Stable for mir::UnOp { impl<'tcx> Stable<'tcx> for mir::UnOp {
type T = stable_mir::mir::UnOp; type T = stable_mir::mir::UnOp;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use mir::UnOp; use mir::UnOp;
match self { match self {
UnOp::Not => stable_mir::mir::UnOp::Not, UnOp::Not => stable_mir::mir::UnOp::Not,
@ -473,9 +487,9 @@ impl Stable for mir::UnOp {
} }
} }
impl Stable for rustc_hir::GeneratorKind { impl<'tcx> Stable<'tcx> for rustc_hir::GeneratorKind {
type T = stable_mir::mir::GeneratorKind; type T = stable_mir::mir::GeneratorKind;
fn stable(&self) -> Self::T { fn stable(&self, _: &mut Tables<'tcx>) -> Self::T {
use rustc_hir::{AsyncGeneratorKind, GeneratorKind}; use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
match self { match self {
GeneratorKind::Async(async_gen) => { GeneratorKind::Async(async_gen) => {
@ -491,16 +505,16 @@ impl Stable for rustc_hir::GeneratorKind {
} }
} }
impl<'tcx> Stable for mir::InlineAsmOperand<'tcx> { impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> {
type T = stable_mir::mir::InlineAsmOperand; type T = stable_mir::mir::InlineAsmOperand;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use rustc_middle::mir::InlineAsmOperand; use rustc_middle::mir::InlineAsmOperand;
let (in_value, out_place) = match self { let (in_value, out_place) = match self {
InlineAsmOperand::In { value, .. } => (Some(value.stable()), None), InlineAsmOperand::In { value, .. } => (Some(value.stable(tables)), None),
InlineAsmOperand::Out { place, .. } => (None, place.map(|place| place.stable())), InlineAsmOperand::Out { place, .. } => (None, place.map(|place| place.stable(tables))),
InlineAsmOperand::InOut { in_value, out_place, .. } => { InlineAsmOperand::InOut { in_value, out_place, .. } => {
(Some(in_value.stable()), out_place.map(|place| place.stable())) (Some(in_value.stable(tables)), out_place.map(|place| place.stable(tables)))
} }
InlineAsmOperand::Const { .. } InlineAsmOperand::Const { .. }
| InlineAsmOperand::SymFn { .. } | InlineAsmOperand::SymFn { .. }
@ -511,15 +525,15 @@ impl<'tcx> Stable for mir::InlineAsmOperand<'tcx> {
} }
} }
impl<'tcx> Stable for mir::Terminator<'tcx> { impl<'tcx> Stable<'tcx> for mir::Terminator<'tcx> {
type T = stable_mir::mir::Terminator; type T = stable_mir::mir::Terminator;
fn stable(&self) -> Self::T { fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use rustc_middle::mir::TerminatorKind::*; use rustc_middle::mir::TerminatorKind::*;
use stable_mir::mir::Terminator; use stable_mir::mir::Terminator;
match &self.kind { match &self.kind {
Goto { target } => Terminator::Goto { target: target.as_usize() }, Goto { target } => Terminator::Goto { target: target.as_usize() },
SwitchInt { discr, targets } => Terminator::SwitchInt { SwitchInt { discr, targets } => Terminator::SwitchInt {
discr: discr.stable(), discr: discr.stable(tables),
targets: targets targets: targets
.iter() .iter()
.map(|(value, target)| stable_mir::mir::SwitchTarget { .map(|(value, target)| stable_mir::mir::SwitchTarget {
@ -534,34 +548,34 @@ impl<'tcx> Stable for mir::Terminator<'tcx> {
Return => Terminator::Return, Return => Terminator::Return,
Unreachable => Terminator::Unreachable, Unreachable => Terminator::Unreachable,
Drop { place, target, unwind, replace: _ } => Terminator::Drop { Drop { place, target, unwind, replace: _ } => Terminator::Drop {
place: place.stable(), place: place.stable(tables),
target: target.as_usize(), target: target.as_usize(),
unwind: unwind.stable(), unwind: unwind.stable(tables),
}, },
Call { func, args, destination, target, unwind, call_source: _, fn_span: _ } => { Call { func, args, destination, target, unwind, call_source: _, fn_span: _ } => {
Terminator::Call { Terminator::Call {
func: func.stable(), func: func.stable(tables),
args: args.iter().map(|arg| arg.stable()).collect(), args: args.iter().map(|arg| arg.stable(tables)).collect(),
destination: destination.stable(), destination: destination.stable(tables),
target: target.map(|t| t.as_usize()), target: target.map(|t| t.as_usize()),
unwind: unwind.stable(), unwind: unwind.stable(tables),
} }
} }
Assert { cond, expected, msg, target, unwind } => Terminator::Assert { Assert { cond, expected, msg, target, unwind } => Terminator::Assert {
cond: cond.stable(), cond: cond.stable(tables),
expected: *expected, expected: *expected,
msg: msg.stable(), msg: msg.stable(tables),
target: target.as_usize(), target: target.as_usize(),
unwind: unwind.stable(), unwind: unwind.stable(tables),
}, },
InlineAsm { template, operands, options, line_spans, destination, unwind } => { InlineAsm { template, operands, options, line_spans, destination, unwind } => {
Terminator::InlineAsm { Terminator::InlineAsm {
template: format!("{:?}", template), template: format!("{:?}", template),
operands: operands.iter().map(|operand| operand.stable()).collect(), operands: operands.iter().map(|operand| operand.stable(tables)).collect(),
options: format!("{:?}", options), options: format!("{:?}", options),
line_spans: format!("{:?}", line_spans), line_spans: format!("{:?}", line_spans),
destination: destination.map(|d| d.as_usize()), destination: destination.map(|d| d.as_usize()),
unwind: unwind.stable(), unwind: unwind.stable(tables),
} }
} }
Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable!(), Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable!(),