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

Commit cf9b089

Browse files
committed
Fix mistakes and clippy diagnostics
1 parent 7c27b57 commit cf9b089

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

crates/tinywasm/src/config.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use core::{default, fmt};
2-
3-
use crate::SuspendConditions;
1+
use core::fmt;
42

53
/// Default initial size for the 32-bit value stack (i32, f32 values).
64
pub const DEFAULT_VALUE_STACK_32_INIT_SIZE: usize = 32 * 1024; // 32KB

crates/tinywasm/src/func.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl FuncHandle {
8181
// 7. Push the frame f to the call stack
8282
// & 8. Push the values to the stack (Not needed since the call frame owns the values)
8383

84-
let mut stack = Stack::new(call_frame, &store.config);
84+
let stack = Stack::new(call_frame, &store.config);
8585

8686
// 9. Invoke the function instance
8787
let runtime = store.runtime();

crates/tinywasm/src/interpreter/executor.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,16 @@ impl<'store, 'stack> Executor<'store, 'stack> {
126126
/// or after all state mutations including increasing instruction pointer
127127
#[must_use = "If this returns ControlFlow::Break, the caller should propagate it"]
128128
fn check_should_suspend(&mut self) -> ControlFlow<ReasonToBreak> {
129-
if let Some(flag) = &self.store.suspend_cond.suspend_flag {
130-
if flag.load(core::sync::atomic::Ordering::Acquire) {
131-
return ReasonToBreak::Suspended(SuspendReason::SuspendedFlag, None).into();
132-
}
129+
if let Some(flag) = &self.store.suspend_cond.suspend_flag
130+
&& flag.load(core::sync::atomic::Ordering::Acquire) {
131+
return ReasonToBreak::Suspended(SuspendReason::SuspendedFlag, None).into();
132+
133133
}
134134

135135
#[cfg(feature = "std")]
136-
if let Some(when) = &self.store.suspend_cond.timeout_instant {
137-
if crate::std::time::Instant::now() >= *when {
138-
return ReasonToBreak::Suspended(SuspendReason::SuspendedEpoch, None).into();
139-
}
136+
if let Some(when) = &self.store.suspend_cond.timeout_instant
137+
&& crate::std::time::Instant::now() >= *when {
138+
return ReasonToBreak::Suspended(SuspendReason::SuspendedEpoch, None).into();
140139
}
141140

142141
if let Some(mut cb) = self.store.suspend_cond.suspend_cb.take() {
@@ -879,7 +878,7 @@ impl<'store, 'stack> Executor<'store, 'stack> {
879878
}
880879
}
881880
fn exec_call_direct<const IS_RETURN_CALL: bool>(&mut self, v: u32) -> ControlFlow<ReasonToBreak> {
882-
self.check_should_suspend(); // don't commit to function if we should be stopping now
881+
self.check_should_suspend()?; // don't commit to function if we should be stopping now
883882
let func_inst = self.store.get_func(self.module.resolve_func_addr(v));
884883
match func_inst.func.clone() {
885884
crate::Function::Wasm(wasm_func) => self.exec_call::<IS_RETURN_CALL>(wasm_func, func_inst.owner),

crates/tinywasm/src/interpreter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl<'_a> coro::CoroState<Stack, FuncContext<'_a>> for SuspendedInterpreterRunti
6868
}
6969
};
7070

71-
return Ok(match res {
71+
Ok(match res {
7272
ExecOutcome::Return(()) => {
7373
// we are finished
7474
InterpreterRuntimeResumeOutcome::Return(stack)
@@ -79,7 +79,7 @@ impl<'_a> coro::CoroState<Stack, FuncContext<'_a>> for SuspendedInterpreterRunti
7979
self.0 = Some(SuspendedInterpreterRuntimeBody::new(host_coro, stack, module, cf));
8080
InterpreterRuntimeResumeOutcome::Suspended(suspend_reason)
8181
}
82-
});
82+
})
8383
}
8484
}
8585

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::BlockType;
44
use crate::Trap;
55
use crate::interpreter::executor::ReasonToBreak;
66
use crate::interpreter::values::*;
7-
use crate::{Error, unlikely};
7+
use crate::unlikely;
88

99
use alloc::boxed::Box;
1010
use alloc::{rc::Rc, vec, vec::Vec};

crates/tinywasm/src/store/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use alloc::{boxed::Box, format, string::ToString, vec::Vec};
2-
use core::default;
32
use core::fmt::Debug;
43
use core::sync::atomic::{AtomicUsize, Ordering};
54
use tinywasm_types::*;

0 commit comments

Comments
 (0)