Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 40e5dcf

Browse files
chore: cleanup clippy errors
Signed-off-by: Henry Gressmann <[email protected]>
1 parent d8e058d commit 40e5dcf

File tree

9 files changed

+22
-23
lines changed

9 files changed

+22
-23
lines changed

crates/tinywasm/src/instance.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
#[derive(Debug, Clone)]
1717
pub struct ModuleInstance(Arc<ModuleInstanceInner>);
1818

19+
#[allow(dead_code)]
1920
#[derive(Debug)]
2021
pub(crate) struct ModuleInstanceInner {
2122
pub(crate) store_id: usize,
@@ -78,7 +79,7 @@ impl ModuleInstance {
7879
&self.0.func_addrs
7980
}
8081

81-
pub(crate) fn global_addrs(&self) -> &[GlobalAddr] {
82+
pub(crate) fn _global_addrs(&self) -> &[GlobalAddr] {
8283
&self.0.global_addrs
8384
}
8485

@@ -100,7 +101,7 @@ impl ModuleInstance {
100101
}
101102

102103
// resolve a table address to the global store address
103-
pub(crate) fn resolve_table_addr(&self, addr: TableAddr) -> TableAddr {
104+
pub(crate) fn _resolve_table_addr(&self, addr: TableAddr) -> TableAddr {
104105
self.0.table_addrs[addr as usize]
105106
}
106107

crates/tinywasm/src/runtime/stack/call_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl CallFrame {
9797
.get_relative_to_top(break_to_relative as usize)
9898
.ok_or(Error::LabelStackUnderflow)?;
9999

100-
value_stack.break_to(break_to.stack_ptr, break_to.args.results as usize);
100+
value_stack.break_to(break_to.stack_ptr, break_to.args.results);
101101

102102
// instr_ptr points to the label instruction, but the next step
103103
// will increment it by 1 since we're changing the "current" instr_ptr

crates/tinywasm/src/runtime/stack/value_stack.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use core::ops::Range;
22

33
use crate::{runtime::RawWasmValue, Error, Result};
44
use alloc::vec::Vec;
5-
use log::info;
65

76
// minimum stack size
87
pub(crate) const STACK_SIZE: usize = 1024;
@@ -25,11 +24,6 @@ impl Default for ValueStack {
2524
}
2625

2726
impl ValueStack {
28-
#[cfg(test)]
29-
pub(crate) fn data(&self) -> &[RawWasmValue] {
30-
&self.stack
31-
}
32-
3327
#[inline]
3428
pub(crate) fn extend_from_within(&mut self, range: Range<usize>) {
3529
self.top += range.len();

crates/tinywasm/src/runtime/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use core::fmt::Debug;
22

3-
use tinywasm_types::{ConstInstruction, ValType, WasmValue};
3+
use tinywasm_types::{ValType, WasmValue};
44

55
/// A raw wasm value.
66
///

crates/tinywasm/src/store.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
#![allow(dead_code)] // TODO: remove this
2+
13
use core::{
24
cell::RefCell,
35
sync::atomic::{AtomicUsize, Ordering},
46
};
57

68
use alloc::{format, rc::Rc, string::ToString, vec, vec::Vec};
79
use tinywasm_types::{
8-
Addr, Data, Element, ElementKind, FuncAddr, Function, Global, GlobalType, Import, Instruction, MemAddr, MemArg,
9-
MemoryArch, MemoryType, ModuleInstanceAddr, TableAddr, TableType, TypeAddr, ValType,
10+
Addr, Data, Element, ElementKind, FuncAddr, Function, Global, GlobalType, Import, Instruction, MemAddr, MemoryArch,
11+
MemoryType, ModuleInstanceAddr, TableAddr, TableType, TypeAddr, ValType,
1012
};
1113

1214
use crate::{
@@ -155,6 +157,7 @@ impl Store {
155157
idx: ModuleInstanceAddr,
156158
) -> Result<Vec<Addr>> {
157159
// TODO: initialize imported globals
160+
#![allow(clippy::unnecessary_filter_map)] // this is cleaner
158161
let imported_globals = wasm_imports
159162
.iter()
160163
.filter_map(|import| match &import.kind {
@@ -170,6 +173,8 @@ impl Store {
170173
};
171174
match global {
172175
Extern::Global(global) => Ok(global),
176+
177+
#[allow(unreachable_patterns)] // this is non-exhaustive
173178
_ => Err(Error::Other(format!(
174179
"expected global import for {}::{}",
175180
import.module, import.name
@@ -343,7 +348,7 @@ impl MemoryInstance {
343348
}
344349
}
345350

346-
pub(crate) fn store(&mut self, addr: usize, align: usize, data: &[u8]) -> Result<()> {
351+
pub(crate) fn store(&mut self, addr: usize, _align: usize, data: &[u8]) -> Result<()> {
347352
if addr + data.len() > self.data.len() {
348353
return Err(Error::Other(format!(
349354
"memory store out of bounds: offset={}, len={}, mem_size={}",
@@ -358,7 +363,7 @@ impl MemoryInstance {
358363
Ok(())
359364
}
360365

361-
pub(crate) fn load(&self, addr: usize, align: usize, len: usize) -> Result<&[u8]> {
366+
pub(crate) fn load(&self, addr: usize, _align: usize, len: usize) -> Result<&[u8]> {
362367
if addr + len > self.data.len() {
363368
return Err(Error::Other(format!(
364369
"memory load out of bounds: offset={}, len={}, mem_size={}",

crates/tinywasm/tests/generated/progress-mvp.svg

Lines changed: 4 additions & 4 deletions
Loading

crates/tinywasm/tests/testsuite/indexmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ where
1515
}
1616

1717
pub fn insert(&mut self, key: K, value: V) -> Option<V> {
18-
if self.map.contains_key(&key) {
19-
return self.map.insert(key, value);
18+
if let std::collections::hash_map::Entry::Occupied(mut e) = self.map.entry(key.clone()) {
19+
return Some(e.insert(value));
2020
}
2121

2222
self.keys.push(key.clone());

crates/tinywasm/tests/testsuite/run.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ impl TestSuite {
8282
})
8383
.expect("failed to instantiate module")
8484
}))
85-
.map_err(|e| eyre!("failed to parse module: {:?}", try_downcast_panic(e)))
86-
.and_then(|res| Ok(res));
85+
.map_err(|e| eyre!("failed to parse module: {:?}", try_downcast_panic(e)));
8786

8887
match &result {
8988
Err(_) => last_module = None,

crates/tinywasm/tests/testsuite/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn exec_fn(
5252
pub fn catch_unwind_silent<F: FnOnce() -> R, R>(f: F) -> std::thread::Result<R> {
5353
let prev_hook = panic::take_hook();
5454
panic::set_hook(Box::new(|_| {}));
55-
let result = panic::catch_unwind(AssertUnwindSafe(|| f()));
55+
let result = panic::catch_unwind(AssertUnwindSafe(f));
5656
panic::set_hook(prev_hook);
5757
result
5858
}

0 commit comments

Comments
 (0)