Add Debug and Clone derives for stable mir datastructures

This commit is contained in:
Oli Scherer 2023-03-16 16:17:25 +00:00
parent 942cac1b8d
commit 480e042097
2 changed files with 10 additions and 2 deletions

View File

@ -1,12 +1,15 @@
#[derive(Clone, Debug)]
pub struct Body {
pub blocks: Vec<BasicBlock>,
}
#[derive(Clone, Debug)]
pub struct BasicBlock {
pub statements: Vec<Statement>,
pub terminator: Terminator,
}
#[derive(Clone, Debug)]
pub enum Terminator {
Goto {
target: usize,
@ -41,21 +44,25 @@ pub enum Terminator {
},
}
#[derive(Clone, Debug)]
pub enum Statement {
Assign(Place, Operand),
Nop,
}
#[derive(Clone, Debug)]
pub enum Operand {
Copy(Place),
Move(Place),
Constant(String),
}
#[derive(Clone, Debug)]
pub struct Place {
pub local: usize,
}
#[derive(Clone, Debug)]
pub struct SwitchTarget {
pub value: u128,
pub target: usize,

View File

@ -4,6 +4,7 @@
// ignore-stage-1
// ignore-cross-compile
// ignore-remote
// edition: 2021
#![feature(rustc_private)]
@ -43,11 +44,11 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
assert_eq!(block.statements.len(), 1);
match &block.statements[0] {
stable_mir::mir::Statement::Assign(..) => {}
_ => panic!(),
other => panic!("{other:?}"),
}
match &block.terminator {
stable_mir::mir::Terminator::Return => {}
_ => panic!(),
other => panic!("{other:?}"),
}
}