Skip to content

Commit 65c7430

Browse files
committed
[Rust] Make LowLevelIL{Expression,Instruction} implement Copy
1 parent 1431470 commit 65c7430

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

rust/src/low_level_il/expression.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ where
5959
T: FnMut(&LowLevelILExpression<'func, M, F, ValueExpr>) -> VisitorAction;
6060
}
6161

62+
#[derive(Copy)]
6263
pub struct LowLevelILExpression<'func, M, F, R>
6364
where
6465
M: FunctionMutability,
@@ -72,6 +73,21 @@ where
7273
pub(crate) _ty: PhantomData<R>,
7374
}
7475

76+
impl<M, F, R> Clone for LowLevelILExpression<'_, M, F, R>
77+
where
78+
M: FunctionMutability,
79+
F: FunctionForm,
80+
R: ExpressionResultType,
81+
{
82+
fn clone(&self) -> Self {
83+
Self {
84+
function: self.function,
85+
index: self.index,
86+
_ty: PhantomData,
87+
}
88+
}
89+
}
90+
7591
impl<'func, M, F, R> LowLevelILExpression<'func, M, F, R>
7692
where
7793
M: FunctionMutability,

rust/src/low_level_il/function.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct Mutable;
3131
#[derive(Copy, Clone, Debug)]
3232
pub struct Finalized;
3333

34-
pub trait FunctionMutability: 'static + Debug {}
34+
pub trait FunctionMutability: 'static + Debug + Copy {}
3535
impl FunctionMutability for Mutable {}
3636
impl FunctionMutability for Finalized {}
3737

@@ -40,7 +40,7 @@ pub struct SSA;
4040
#[derive(Copy, Clone, Debug)]
4141
pub struct NonSSA;
4242

43-
pub trait FunctionForm: 'static + Debug {}
43+
pub trait FunctionForm: 'static + Debug + Copy {}
4444
impl FunctionForm for SSA {}
4545
impl FunctionForm for NonSSA {}
4646

rust/src/low_level_il/instruction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ where
6565
T: FnMut(&LowLevelILExpression<'func, M, F, ValueExpr>) -> VisitorAction;
6666
}
6767

68+
#[derive(Copy, Clone)]
6869
pub struct LowLevelILInstruction<'func, M, F>
6970
where
7071
M: FunctionMutability,

0 commit comments

Comments
 (0)