Skip to content

Commit 93e2c7f

Browse files
committed
format verifyinstructions
1 parent 9c9b624 commit 93e2c7f

File tree

3 files changed

+277
-297
lines changed

3 files changed

+277
-297
lines changed

libchisel/src/instructionerrors.rs

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,36 @@ use std::fmt;
44

55
#[derive(Debug)]
66
pub enum InstructionError {
7-
GlobalNotFound,
8-
LocalNotFound,
9-
UnmatchedInstruction,
10-
InvalidOperation(Instruction),
7+
GlobalNotFound,
8+
LocalNotFound,
9+
UnmatchedInstruction,
10+
InvalidOperation(Instruction),
1111
}
1212

1313
impl fmt::Display for InstructionError {
14-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15-
match self {
16-
InstructionError::GlobalNotFound =>
17-
write!(f, "Global not found"),
18-
InstructionError::LocalNotFound =>
19-
write!(f, "Local not found"),
20-
InstructionError::UnmatchedInstruction =>
21-
write!(f, "Unmatched instruction"),
22-
InstructionError::InvalidOperation(i) =>
23-
write!(f, "{}", format!("Invalid operation: {:?}", i).as_str()),
24-
}
25-
}
14+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15+
match self {
16+
InstructionError::GlobalNotFound => write!(f, "Global not found"),
17+
InstructionError::LocalNotFound => write!(f, "Local not found"),
18+
InstructionError::UnmatchedInstruction => write!(f, "Unmatched instruction"),
19+
InstructionError::InvalidOperation(i) => {
20+
write!(f, "{}", format!("Invalid operation: {:?}", i).as_str())
21+
}
22+
}
23+
}
2624
}
2725

2826
impl error::Error for InstructionError {
29-
fn description(&self) -> &str {
30-
match self {
31-
InstructionError::GlobalNotFound =>
32-
"Global not found",
33-
InstructionError::LocalNotFound =>
34-
"Local not found",
35-
InstructionError::UnmatchedInstruction =>
36-
"Unmatched instruction",
37-
InstructionError::InvalidOperation(_) =>
38-
"Invalid operation"
39-
}
40-
}
27+
fn description(&self) -> &str {
28+
match self {
29+
InstructionError::GlobalNotFound => "Global not found",
30+
InstructionError::LocalNotFound => "Local not found",
31+
InstructionError::UnmatchedInstruction => "Unmatched instruction",
32+
InstructionError::InvalidOperation(_) => "Invalid operation",
33+
}
34+
}
4135

42-
fn cause(&self) -> Option<&error::Error> {
43-
None
44-
}
36+
fn cause(&self) -> Option<&error::Error> {
37+
None
38+
}
4539
}

libchisel/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use parity_wasm::elements::Module;
66

77
pub mod checkstartfunc;
88
pub mod deployer;
9+
mod instructionerrors;
910
pub mod remapimports;
1011
pub mod trimexports;
1112
pub mod verifyexports;
1213
pub mod verifyimports;
1314
pub mod verifyinstructions;
14-
mod instructionerrors;
1515

1616
use crate::instructionerrors::*;
1717
use parity_wasm::elements::*;

0 commit comments

Comments
 (0)