Skip to content

Commit 4fe3411

Browse files
committed
[Rust] Fix impl Display for LowLevelILRegisterKind
1 parent 0cf7c07 commit 4fe3411

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

rust/src/low_level_il.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use std::borrow::Cow;
1616
use std::fmt;
17-
use std::fmt::{Display, Formatter};
17+
use std::fmt::{Debug, Display};
1818
// TODO : provide some way to forbid emitting register reads for certain registers
1919
// also writing for certain registers (e.g. zero register must prohibit il.set_reg and il.reg
2020
// (replace with nop or const(0) respectively)
@@ -83,15 +83,15 @@ impl LowLevelILTempRegister {
8383
}
8484
}
8585

86-
impl fmt::Debug for LowLevelILTempRegister {
87-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
86+
impl Debug for LowLevelILTempRegister {
87+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
8888
write!(f, "temp{}", self.temp_id)
8989
}
9090
}
9191

92-
impl fmt::Display for LowLevelILTempRegister {
93-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
94-
fmt::Debug::fmt(self, f)
92+
impl Display for LowLevelILTempRegister {
93+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
94+
Debug::fmt(self, f)
9595
}
9696
}
9797

@@ -148,18 +148,21 @@ impl<R: ArchReg> LowLevelILRegisterKind<R> {
148148
}
149149
}
150150

151-
impl<R: ArchReg> fmt::Debug for LowLevelILRegisterKind<R> {
152-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
151+
impl<R: ArchReg> Debug for LowLevelILRegisterKind<R> {
152+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
153153
match *self {
154154
LowLevelILRegisterKind::Arch(ref r) => r.fmt(f),
155-
LowLevelILRegisterKind::Temp(ref id) => fmt::Debug::fmt(id, f),
155+
LowLevelILRegisterKind::Temp(ref id) => Debug::fmt(id, f),
156156
}
157157
}
158158
}
159159

160-
impl<R: ArchReg> fmt::Display for LowLevelILRegisterKind<R> {
161-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
162-
fmt::Debug::fmt(self, f)
160+
impl<R: ArchReg> Display for LowLevelILRegisterKind<R> {
161+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
162+
match *self {
163+
LowLevelILRegisterKind::Arch(ref r) => write!(f, "{}", r.name()),
164+
LowLevelILRegisterKind::Temp(ref id) => Display::fmt(id, f),
165+
}
163166
}
164167
}
165168

@@ -191,7 +194,7 @@ impl<R: ArchReg> LowLevelILSSARegister<R> {
191194
}
192195

193196
impl<R: ArchReg> Display for LowLevelILSSARegister<R> {
194-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
197+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
195198
write!(f, "{}#{}", self.reg, self.version)
196199
}
197200
}

0 commit comments

Comments
 (0)