mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
impl stable for kinds
This commit is contained in:
parent
a79567b01c
commit
a49138e46e
@ -230,72 +230,64 @@ pub(crate) trait Stable<'tcx> {
|
|||||||
impl<'tcx> Stable<'tcx> 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, tables: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||||
use rustc_middle::mir::StatementKind::*;
|
Statement { kind: self.kind.stable(tables), span: self.source_info.span.stable(tables) }
|
||||||
let span = self.source_info.span.stable(tables);
|
}
|
||||||
match &self.kind {
|
}
|
||||||
Assign(assign) => Statement {
|
|
||||||
kind: stable_mir::mir::StatementKind::Assign(
|
impl<'tcx> Stable<'tcx> for mir::StatementKind<'tcx> {
|
||||||
assign.0.stable(tables),
|
type T = stable_mir::mir::StatementKind;
|
||||||
assign.1.stable(tables),
|
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||||
),
|
match self {
|
||||||
span,
|
mir::StatementKind::Assign(assign) => stable_mir::mir::StatementKind::Assign(
|
||||||
},
|
assign.0.stable(tables),
|
||||||
FakeRead(fake_read_place) => Statement {
|
assign.1.stable(tables),
|
||||||
kind: stable_mir::mir::StatementKind::FakeRead(
|
),
|
||||||
|
mir::StatementKind::FakeRead(fake_read_place) => {
|
||||||
|
stable_mir::mir::StatementKind::FakeRead(
|
||||||
fake_read_place.0.stable(tables),
|
fake_read_place.0.stable(tables),
|
||||||
fake_read_place.1.stable(tables),
|
fake_read_place.1.stable(tables),
|
||||||
),
|
)
|
||||||
span,
|
}
|
||||||
},
|
mir::StatementKind::SetDiscriminant { place, variant_index } => {
|
||||||
SetDiscriminant { place: plc, variant_index: idx } => Statement {
|
stable_mir::mir::StatementKind::SetDiscriminant {
|
||||||
kind: stable_mir::mir::StatementKind::SetDiscriminant {
|
place: place.as_ref().stable(tables),
|
||||||
place: plc.as_ref().stable(tables),
|
variant_index: variant_index.stable(tables),
|
||||||
variant_index: idx.stable(tables),
|
}
|
||||||
},
|
}
|
||||||
span,
|
mir::StatementKind::Deinit(place) => {
|
||||||
},
|
stable_mir::mir::StatementKind::Deinit(place.stable(tables))
|
||||||
Deinit(place) => Statement {
|
}
|
||||||
kind: stable_mir::mir::StatementKind::Deinit(place.stable(tables)),
|
|
||||||
span,
|
mir::StatementKind::StorageLive(place) => {
|
||||||
},
|
stable_mir::mir::StatementKind::StorageLive(place.stable(tables))
|
||||||
StorageLive(place) => Statement {
|
}
|
||||||
kind: stable_mir::mir::StatementKind::StorageLive(place.stable(tables)),
|
|
||||||
span,
|
mir::StatementKind::StorageDead(place) => {
|
||||||
},
|
stable_mir::mir::StatementKind::StorageDead(place.stable(tables))
|
||||||
StorageDead(place) => Statement {
|
}
|
||||||
kind: stable_mir::mir::StatementKind::StorageDead(place.stable(tables)),
|
mir::StatementKind::Retag(retag, place) => {
|
||||||
span,
|
stable_mir::mir::StatementKind::Retag(retag.stable(tables), place.stable(tables))
|
||||||
},
|
}
|
||||||
Retag(retag, place) => Statement {
|
mir::StatementKind::PlaceMention(place) => {
|
||||||
kind: stable_mir::mir::StatementKind::Retag(
|
stable_mir::mir::StatementKind::PlaceMention(place.stable(tables))
|
||||||
retag.stable(tables),
|
}
|
||||||
place.stable(tables),
|
mir::StatementKind::AscribeUserType(place_projection, variance) => {
|
||||||
),
|
stable_mir::mir::StatementKind::AscribeUserType {
|
||||||
span,
|
|
||||||
},
|
|
||||||
PlaceMention(place) => Statement {
|
|
||||||
kind: stable_mir::mir::StatementKind::PlaceMention(place.stable(tables)),
|
|
||||||
span,
|
|
||||||
},
|
|
||||||
AscribeUserType(place_projection, variance) => Statement {
|
|
||||||
kind: stable_mir::mir::StatementKind::AscribeUserType {
|
|
||||||
place: place_projection.as_ref().0.stable(tables),
|
place: place_projection.as_ref().0.stable(tables),
|
||||||
projections: place_projection.as_ref().1.stable(tables),
|
projections: place_projection.as_ref().1.stable(tables),
|
||||||
variance: variance.stable(tables),
|
variance: variance.stable(tables),
|
||||||
},
|
}
|
||||||
span,
|
|
||||||
},
|
|
||||||
Coverage(coverage) => {
|
|
||||||
Statement { kind: stable_mir::mir::StatementKind::Coverage(opaque(coverage)), span }
|
|
||||||
}
|
}
|
||||||
Intrinsic(intrinstic) => Statement {
|
mir::StatementKind::Coverage(coverage) => {
|
||||||
kind: stable_mir::mir::StatementKind::Intrinsic(intrinstic.stable(tables)),
|
stable_mir::mir::StatementKind::Coverage(opaque(coverage))
|
||||||
span,
|
|
||||||
},
|
|
||||||
ConstEvalCounter => {
|
|
||||||
Statement { kind: stable_mir::mir::StatementKind::ConstEvalCounter, span }
|
|
||||||
}
|
}
|
||||||
Nop => Statement { kind: stable_mir::mir::StatementKind::Nop, span },
|
mir::StatementKind::Intrinsic(intrinstic) => {
|
||||||
|
stable_mir::mir::StatementKind::Intrinsic(intrinstic.stable(tables))
|
||||||
|
}
|
||||||
|
mir::StatementKind::ConstEvalCounter => {
|
||||||
|
stable_mir::mir::StatementKind::ConstEvalCounter
|
||||||
|
}
|
||||||
|
mir::StatementKind::Nop => stable_mir::mir::StatementKind::Nop,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -844,76 +836,84 @@ impl<'tcx> Stable<'tcx> for mir::InlineAsmOperand<'tcx> {
|
|||||||
impl<'tcx> Stable<'tcx> 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, tables: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||||
use rustc_middle::mir::TerminatorKind::*;
|
|
||||||
use stable_mir::mir::Terminator;
|
use stable_mir::mir::Terminator;
|
||||||
|
Terminator { kind: self.kind.stable(tables), span: self.source_info.span.stable(tables) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> Stable<'tcx> for mir::TerminatorKind<'tcx> {
|
||||||
|
type T = stable_mir::mir::TerminatorKind;
|
||||||
|
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||||
use stable_mir::mir::TerminatorKind;
|
use stable_mir::mir::TerminatorKind;
|
||||||
let span = self.source_info.span.stable(tables);
|
match self {
|
||||||
match &self.kind {
|
mir::TerminatorKind::Goto { target } => {
|
||||||
Goto { target } => {
|
TerminatorKind::Goto { target: target.as_usize() }
|
||||||
Terminator { kind: TerminatorKind::Goto { target: target.as_usize() }, span }
|
|
||||||
}
|
}
|
||||||
SwitchInt { discr, targets } => Terminator {
|
mir::TerminatorKind::SwitchInt { discr, targets } => TerminatorKind::SwitchInt {
|
||||||
kind: TerminatorKind::SwitchInt {
|
discr: discr.stable(tables),
|
||||||
discr: discr.stable(tables),
|
targets: targets
|
||||||
targets: targets
|
.iter()
|
||||||
.iter()
|
.map(|(value, target)| stable_mir::mir::SwitchTarget {
|
||||||
.map(|(value, target)| stable_mir::mir::SwitchTarget {
|
value,
|
||||||
value,
|
target: target.as_usize(),
|
||||||
target: target.as_usize(),
|
})
|
||||||
})
|
.collect(),
|
||||||
.collect(),
|
otherwise: targets.otherwise().as_usize(),
|
||||||
otherwise: targets.otherwise().as_usize(),
|
|
||||||
},
|
|
||||||
span,
|
|
||||||
},
|
},
|
||||||
UnwindResume => Terminator { kind: TerminatorKind::Resume, span },
|
mir::TerminatorKind::UnwindResume => TerminatorKind::Resume,
|
||||||
UnwindTerminate(_) => Terminator { kind: TerminatorKind::Abort, span },
|
mir::TerminatorKind::UnwindTerminate(_) => TerminatorKind::Abort,
|
||||||
Return => Terminator { kind: TerminatorKind::Return, span },
|
mir::TerminatorKind::Return => TerminatorKind::Return,
|
||||||
Unreachable => Terminator { kind: TerminatorKind::Unreachable, span },
|
mir::TerminatorKind::Unreachable => TerminatorKind::Unreachable,
|
||||||
Drop { place, target, unwind, replace: _ } => Terminator {
|
mir::TerminatorKind::Drop { place, target, unwind, replace: _ } => {
|
||||||
kind: TerminatorKind::Drop {
|
TerminatorKind::Drop {
|
||||||
place: place.stable(tables),
|
place: place.stable(tables),
|
||||||
target: target.as_usize(),
|
target: target.as_usize(),
|
||||||
unwind: unwind.stable(tables),
|
unwind: unwind.stable(tables),
|
||||||
},
|
|
||||||
span,
|
|
||||||
},
|
|
||||||
Call { func, args, destination, target, unwind, call_source: _, fn_span: _ } => {
|
|
||||||
Terminator {
|
|
||||||
kind: TerminatorKind::Call {
|
|
||||||
func: func.stable(tables),
|
|
||||||
args: args.iter().map(|arg| arg.stable(tables)).collect(),
|
|
||||||
destination: destination.stable(tables),
|
|
||||||
target: target.map(|t| t.as_usize()),
|
|
||||||
unwind: unwind.stable(tables),
|
|
||||||
},
|
|
||||||
span,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert { cond, expected, msg, target, unwind } => Terminator {
|
mir::TerminatorKind::Call {
|
||||||
kind: TerminatorKind::Assert {
|
func,
|
||||||
|
args,
|
||||||
|
destination,
|
||||||
|
target,
|
||||||
|
unwind,
|
||||||
|
call_source: _,
|
||||||
|
fn_span: _,
|
||||||
|
} => TerminatorKind::Call {
|
||||||
|
func: func.stable(tables),
|
||||||
|
args: args.iter().map(|arg| arg.stable(tables)).collect(),
|
||||||
|
destination: destination.stable(tables),
|
||||||
|
target: target.map(|t| t.as_usize()),
|
||||||
|
unwind: unwind.stable(tables),
|
||||||
|
},
|
||||||
|
mir::TerminatorKind::Assert { cond, expected, msg, target, unwind } => {
|
||||||
|
TerminatorKind::Assert {
|
||||||
cond: cond.stable(tables),
|
cond: cond.stable(tables),
|
||||||
expected: *expected,
|
expected: *expected,
|
||||||
msg: msg.stable(tables),
|
msg: msg.stable(tables),
|
||||||
target: target.as_usize(),
|
target: target.as_usize(),
|
||||||
unwind: unwind.stable(tables),
|
unwind: unwind.stable(tables),
|
||||||
},
|
|
||||||
span,
|
|
||||||
},
|
|
||||||
InlineAsm { template, operands, options, line_spans, destination, unwind } => {
|
|
||||||
Terminator {
|
|
||||||
kind: TerminatorKind::InlineAsm {
|
|
||||||
template: format!("{template:?}"),
|
|
||||||
operands: operands.iter().map(|operand| operand.stable(tables)).collect(),
|
|
||||||
options: format!("{options:?}"),
|
|
||||||
line_spans: format!("{line_spans:?}"),
|
|
||||||
destination: destination.map(|d| d.as_usize()),
|
|
||||||
unwind: unwind.stable(tables),
|
|
||||||
},
|
|
||||||
span,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable!(),
|
mir::TerminatorKind::InlineAsm {
|
||||||
|
template,
|
||||||
|
operands,
|
||||||
|
options,
|
||||||
|
line_spans,
|
||||||
|
destination,
|
||||||
|
unwind,
|
||||||
|
} => TerminatorKind::InlineAsm {
|
||||||
|
template: format!("{template:?}"),
|
||||||
|
operands: operands.iter().map(|operand| operand.stable(tables)).collect(),
|
||||||
|
options: format!("{options:?}"),
|
||||||
|
line_spans: format!("{line_spans:?}"),
|
||||||
|
destination: destination.map(|d| d.as_usize()),
|
||||||
|
unwind: unwind.stable(tables),
|
||||||
|
},
|
||||||
|
mir::TerminatorKind::Yield { .. }
|
||||||
|
| mir::TerminatorKind::GeneratorDrop
|
||||||
|
| mir::TerminatorKind::FalseEdge { .. }
|
||||||
|
| mir::TerminatorKind::FalseUnwind { .. } => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user