Skip to content

Rust cleanup #6789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
7 changes: 4 additions & 3 deletions arch/msp430/src/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use log::error;

const MIN_MNEMONIC: usize = 9;

#[derive(Debug)]
pub struct Msp430 {
handle: CoreArchitecture,
custom_handle: CustomArchitectureHandle<Msp430>,
Expand Down Expand Up @@ -193,7 +194,7 @@ impl Architecture for Msp430 {
&self,
data: &[u8],
addr: u64,
il: &mut MutableLiftedILFunction<Self>,
il: &mut MutableLiftedILFunction,
) -> Option<(usize, bool)> {
match msp430_asm::decode(data) {
Ok(inst) => {
Expand Down Expand Up @@ -225,8 +226,8 @@ impl Architecture for Msp430 {
fn flag_group_llil<'a>(
&self,
_group: Self::FlagGroup,
_il: &'a mut MutableLiftedILFunction<Self>,
) -> Option<MutableLiftedILExpr<'a, Self, ValueExpr>> {
_il: &'a mut MutableLiftedILFunction,
) -> Option<MutableLiftedILExpr<'a, ValueExpr>> {
None
}

Expand Down
11 changes: 3 additions & 8 deletions arch/msp430/src/lift.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::architecture::offset_to_absolute;
use crate::flag::{Flag, FlagWrite};
use crate::register::Register;
use crate::Msp430;

use binaryninja::{architecture::FlagCondition, low_level_il::lifting::LowLevelILLabel};

Expand Down Expand Up @@ -164,11 +163,7 @@ macro_rules! conditional_jump {
};
}

pub(crate) fn lift_instruction(
inst: &Instruction,
addr: u64,
il: &MutableLiftedILFunction<Msp430>,
) {
pub(crate) fn lift_instruction(inst: &Instruction, addr: u64, il: &MutableLiftedILFunction) {
match inst {
Instruction::Rrc(inst) => {
let size = match inst.operand_width() {
Expand Down Expand Up @@ -628,8 +623,8 @@ pub(crate) fn lift_instruction(
fn lift_source_operand<'a>(
operand: &Operand,
size: usize,
il: &'a MutableLiftedILFunction<Msp430>,
) -> MutableLiftedILExpr<'a, Msp430, ValueExpr> {
il: &'a MutableLiftedILFunction,
) -> MutableLiftedILExpr<'a, ValueExpr> {
match operand {
Operand::RegisterDirect(r) => il.reg(size, Register::try_from(*r as u32).unwrap()),
Operand::Indexed((r, offset)) => il
Expand Down
6 changes: 3 additions & 3 deletions arch/msp430/src/register.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use binaryninja::architecture;
use binaryninja::architecture::{ImplicitRegisterExtend, RegisterId};

use binaryninja::low_level_il::LowLevelILRegister;
use binaryninja::low_level_il::LowLevelILRegisterKind;
use std::borrow::Cow;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -134,8 +134,8 @@ impl architecture::RegisterInfo for Register {
}
}

impl From<Register> for LowLevelILRegister<Register> {
impl From<Register> for LowLevelILRegisterKind<Register> {
fn from(register: Register) -> Self {
LowLevelILRegister::ArchReg(register)
LowLevelILRegisterKind::Arch(register)
}
}
5 changes: 3 additions & 2 deletions arch/riscv/disasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl FloatRegType for () {}
impl FloatRegType for f32 {}
impl FloatRegType for f64 {}

pub trait RegFile: Debug + Sized + Copy + Clone {
pub trait RegFile: Debug + Sized + Copy + Clone + Send + Sync + 'static {
type Int: IntRegType;
type Float: FloatRegType;

Expand Down Expand Up @@ -2331,7 +2331,7 @@ impl StandardExtension for ExtensionSupported {
}
}

pub trait RiscVDisassembler: Debug + Sized + Copy + Clone {
pub trait RiscVDisassembler: 'static + Debug + Sized + Copy + Clone + Send + Sync {
type RegFile: RegFile;
type MulDivExtension: StandardExtension;
type AtomicExtension: StandardExtension;
Expand Down Expand Up @@ -3175,6 +3175,7 @@ pub trait RiscVDisassembler: Debug + Sized + Copy + Clone {

#[derive(Copy, Clone, Debug)]
pub struct RiscVIMACDisassembler<RF: RegFile>(PhantomData<RF>);

impl<RF: RegFile> RiscVDisassembler for RiscVIMACDisassembler<RF> {
type RegFile = RF;
type MulDivExtension = ExtensionSupported;
Expand Down
Loading
Loading