mirror of
https://github.com/pezkuwichain/wasm-instrument.git
synced 2026-06-09 20:11:06 +00:00
Add a clippy job to the CI (#163)
* Add clippy CI check * Fix remaining clippy lints * Cargo fmt
This commit is contained in:
committed by
GitHub
parent
b8e6b9e319
commit
72626a566a
@@ -29,6 +29,25 @@ jobs:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
clippy:
|
||||
runs-on: "ubuntu-latest"
|
||||
steps:
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
components: clippy
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Cargo clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
command: clippy
|
||||
args: --all-targets --all-features -- -D warnings
|
||||
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
+2
-3
@@ -130,8 +130,7 @@ fn do_main() -> Result<(), Error> {
|
||||
|
||||
let mut source_input = source::SourceInput::new(target_dir, wasm_binary);
|
||||
|
||||
let source_target_val =
|
||||
matches.value_of("source_target").unwrap_or_else(|| source::EMSCRIPTEN_TRIPLET);
|
||||
let source_target_val = matches.value_of("source_target").unwrap_or(source::EMSCRIPTEN_TRIPLET);
|
||||
if source_target_val == source::UNKNOWN_TRIPLET {
|
||||
source_input = source_input.unknown()
|
||||
} else if source_target_val == source::EMSCRIPTEN_TRIPLET {
|
||||
@@ -194,7 +193,7 @@ fn do_main() -> Result<(), Error> {
|
||||
matches.is_present("enforce_stack_adjustment"),
|
||||
matches
|
||||
.value_of("shrink_stack")
|
||||
.unwrap_or_else(|| "49152")
|
||||
.unwrap_or("49152")
|
||||
.parse()
|
||||
.expect("New stack size is not valid u32"),
|
||||
matches.is_present("skip_optimization"),
|
||||
|
||||
+3
-2
@@ -100,8 +100,9 @@ pub fn build(
|
||||
if !skip_optimization {
|
||||
let preserved_exports = match target_runtime {
|
||||
TargetRuntime::PWasm(_) => vec![target_runtime.symbols().create],
|
||||
TargetRuntime::Substrate(_) =>
|
||||
vec![target_runtime.symbols().call, target_runtime.symbols().create],
|
||||
TargetRuntime::Substrate(_) => {
|
||||
vec![target_runtime.symbols().call, target_runtime.symbols().create]
|
||||
},
|
||||
};
|
||||
optimize(&mut ctor_module, preserved_exports)?;
|
||||
}
|
||||
|
||||
@@ -153,8 +153,7 @@ fn build_control_flow_graph(
|
||||
|
||||
graph.set_first_instr_pos(entry_node_id, 0);
|
||||
|
||||
let mut stack = Vec::new();
|
||||
stack.push(ControlFrame::new(entry_node_id, terminal_node_id, false));
|
||||
let mut stack = vec![ControlFrame::new(entry_node_id, terminal_node_id, false)];
|
||||
|
||||
let mut metered_blocks_iter = blocks.iter().peekable();
|
||||
for (cursor, instruction) in body.code().elements().iter().enumerate() {
|
||||
|
||||
+8
-6
@@ -32,10 +32,12 @@ impl fmt::Display for Error {
|
||||
Error::NoTypeSection => write!(f, "No type section in the module"),
|
||||
Error::NoExportSection => write!(f, "No export section in the module"),
|
||||
Error::NoCodeSection => write!(f, "No code section inthe module"),
|
||||
Error::InvalidCreateSignature(sym) =>
|
||||
write!(f, "Exported symbol `{}` has invalid signature, should be () -> ()", sym),
|
||||
Error::InvalidCreateMember(sym) =>
|
||||
write!(f, "Exported symbol `{}` should be a function", sym),
|
||||
Error::InvalidCreateSignature(sym) => {
|
||||
write!(f, "Exported symbol `{}` has invalid signature, should be () -> ()", sym)
|
||||
},
|
||||
Error::InvalidCreateMember(sym) => {
|
||||
write!(f, "Exported symbol `{}` should be a function", sym)
|
||||
},
|
||||
Error::NoCreateSymbol(sym) => write!(f, "No exported `{}` symbol", sym),
|
||||
Error::NoImportSection => write!(f, "No import section in the module"),
|
||||
}
|
||||
@@ -285,7 +287,7 @@ mod test {
|
||||
.module("env")
|
||||
.field("memory")
|
||||
.external()
|
||||
.memory(1 as u32, Some(1 as u32))
|
||||
.memory(1, Some(1))
|
||||
.build()
|
||||
.function()
|
||||
.signature()
|
||||
@@ -336,7 +338,7 @@ mod test {
|
||||
.module("env")
|
||||
.field("memory")
|
||||
.external()
|
||||
.memory(1 as u32, Some(1 as u32))
|
||||
.memory(1, Some(1))
|
||||
.build()
|
||||
.data()
|
||||
.offset(elements::Instruction::I32Const(16))
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ mod tests {
|
||||
let mut module = builder::module()
|
||||
.with_global(GlobalEntry::new(
|
||||
GlobalType::new(ValueType::I32, false),
|
||||
InitExpr::new(vec![Instruction::I32Const(42 as i32)]),
|
||||
InitExpr::new(vec![Instruction::I32Const(42)]),
|
||||
))
|
||||
.build();
|
||||
let mut runtime_type: [u8; 4] = Default::default();
|
||||
|
||||
Reference in New Issue
Block a user