Skip to content

Commit 480e042

Browse files
committed
Add Debug and Clone derives for stable mir datastructures
1 parent 942cac1 commit 480e042

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/rustc_smir/src/stable_mir/mir/body.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
#[derive(Clone, Debug)]
12
pub struct Body {
23
pub blocks: Vec<BasicBlock>,
34
}
45

6+
#[derive(Clone, Debug)]
57
pub struct BasicBlock {
68
pub statements: Vec<Statement>,
79
pub terminator: Terminator,
810
}
911

12+
#[derive(Clone, Debug)]
1013
pub enum Terminator {
1114
Goto {
1215
target: usize,
@@ -41,21 +44,25 @@ pub enum Terminator {
4144
},
4245
}
4346

47+
#[derive(Clone, Debug)]
4448
pub enum Statement {
4549
Assign(Place, Operand),
4650
Nop,
4751
}
4852

53+
#[derive(Clone, Debug)]
4954
pub enum Operand {
5055
Copy(Place),
5156
Move(Place),
5257
Constant(String),
5358
}
5459

60+
#[derive(Clone, Debug)]
5561
pub struct Place {
5662
pub local: usize,
5763
}
5864

65+
#[derive(Clone, Debug)]
5966
pub struct SwitchTarget {
6067
pub value: u128,
6168
pub target: usize,

tests/ui-fulldeps/stable-mir/crate-info.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// ignore-stage-1
55
// ignore-cross-compile
66
// ignore-remote
7+
// edition: 2021
78

89
#![feature(rustc_private)]
910

@@ -43,11 +44,11 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
4344
assert_eq!(block.statements.len(), 1);
4445
match &block.statements[0] {
4546
stable_mir::mir::Statement::Assign(..) => {}
46-
_ => panic!(),
47+
other => panic!("{other:?}"),
4748
}
4849
match &block.terminator {
4950
stable_mir::mir::Terminator::Return => {}
50-
_ => panic!(),
51+
other => panic!("{other:?}"),
5152
}
5253
}
5354

0 commit comments

Comments
 (0)