Skip to content

Commit f9f760f

Browse files
chore: cleanup
Signed-off-by: Henry Gressmann <[email protected]>
1 parent 0f3581e commit f9f760f

23 files changed

+188
-132
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ edition="2024"
1919
license="MIT OR Apache-2.0"
2020
authors=["Henry Gressmann <[email protected]>"]
2121
repository="https://github.com/explodingcamera/tinywasm"
22+
categories=["wasm", "no-std"]
23+
keywords=["tinywasm"]
2224

2325
[package]
2426
name="tinywasm-root"

crates/cli/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ license.workspace=true
77
authors.workspace=true
88
repository.workspace=true
99
rust-version.workspace=true
10+
keywords.workspace=true
11+
categories=["wasm"]
1012

1113
[[bin]]
1214
name="tinywasm-cli"

crates/parser/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ license.workspace=true
77
authors.workspace=true
88
repository.workspace=true
99
rust-version.workspace=true
10+
keywords.workspace=true
11+
categories.workspace=true
1012

1113
[dependencies]
1214
wasmparser={workspace=true, features=["validate", "features", "simd"]}

crates/parser/src/module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub(crate) struct ModuleReader {
3030
}
3131

3232
impl ModuleReader {
33-
pub(crate) fn new() -> ModuleReader {
33+
pub(crate) fn new() -> Self {
3434
Self::default()
3535
}
3636

crates/parser/src/visit.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,13 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
370370

371371
let if_instruction = &mut self.instructions[if_label_pointer];
372372

373-
let (else_offset, end_offset) = match if_instruction {
374-
Instruction::If(else_offset, end_offset)
375-
| Instruction::IfWithFuncType(_, else_offset, end_offset)
376-
| Instruction::IfWithType(_, else_offset, end_offset) => (else_offset, end_offset),
377-
_ => {
378-
self.errors.push(crate::ParseError::UnsupportedOperator(
379-
"Expected to end an if block, but the last label was not an if".to_string(),
380-
));
381-
382-
return;
383-
}
373+
let (Instruction::If(else_offset, end_offset)
374+
| Instruction::IfWithFuncType(_, else_offset, end_offset)
375+
| Instruction::IfWithType(_, else_offset, end_offset)) = if_instruction
376+
else {
377+
return self.errors.push(crate::ParseError::UnsupportedOperator(
378+
"Expected to end an if block, but the last label was not an if".to_string(),
379+
));
384380
};
385381

386382
*else_offset = (label_pointer - if_label_pointer)

crates/tinywasm/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ license.workspace=true
77
authors.workspace=true
88
repository.workspace=true
99
rust-version.workspace=true
10+
keywords.workspace=true
11+
categories.workspace=true
1012
readme="../../README.md"
1113

1214
[lib]
@@ -32,7 +34,7 @@ serde_json={version="1.0"}
3234
serde={version="1.0", features=["derive"]}
3335

3436
[features]
35-
default=["std", "parser", "logging", "archive", "canonicalize_nans"]
37+
default=["std", "parser", "logging", "archive", "canonicalize_nans", "__simd"]
3638

3739
logging=["log", "tinywasm-parser?/logging", "tinywasm-types/logging"]
3840
std=["tinywasm-parser?/std", "tinywasm-types/std"]

crates/tinywasm/src/error.rs

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub enum Error {
5151

5252
#[derive(Debug)]
5353
/// Errors that can occur when linking a WebAssembly module
54+
#[non_exhaustive]
5455
pub enum LinkingError {
5556
/// An unknown import was encountered
5657
UnknownImport {
@@ -83,6 +84,7 @@ impl LinkingError {
8384
/// A WebAssembly trap
8485
///
8586
/// See <https://webassembly.github.io/spec/core/intro/overview.html#trap>
87+
#[non_exhaustive]
8688
pub enum Trap {
8789
/// An unreachable instruction was executed
8890
Unreachable,

crates/tinywasm/src/func.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::interpreter::stack::{CallFrame, Stack};
2+
use crate::{log, unlikely, Function};
23
use crate::{Error, FuncContext, Result, Store};
3-
use crate::{Function, log, unlikely};
44
use alloc::{boxed::Box, format, string::String, string::ToString, vec, vec::Vec};
55
use tinywasm_types::{ExternRef, FuncRef, FuncType, ModuleInstanceAddr, ValType, WasmValue};
66

@@ -38,11 +38,11 @@ impl FuncHandle {
3838

3939
// 5. For each value type and the corresponding value, check if types match
4040
if !(func_ty.params.iter().zip(params).enumerate().all(|(_i, (ty, param))| {
41-
if ty != &param.val_type() {
41+
if ty == &param.val_type() {
42+
true
43+
} else {
4244
log::error!("param type mismatch at index {_i}: expected {ty:?}, got {param:?}");
4345
false
44-
} else {
45-
true
4646
}
4747
})) {
4848
return Err(Error::Other("Type mismatch".into()));

crates/tinywasm/src/imports.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl Extern {
170170
let inner_func = move |ctx: FuncContext<'_>, args: &[WasmValue]| -> Result<Vec<WasmValue>> {
171171
let args = P::from_wasm_value_tuple(args)?;
172172
let result = func(ctx, args)?;
173-
Ok(result.into_wasm_value_tuple().to_vec())
173+
Ok(result.into_wasm_value_tuple())
174174
};
175175

176176
let ty = tinywasm_types::FuncType { params: P::val_types(), results: R::val_types() };
@@ -263,7 +263,7 @@ impl ResolvedImports {
263263
impl Imports {
264264
/// Create a new empty import set
265265
pub fn new() -> Self {
266-
Imports { values: BTreeMap::new(), modules: BTreeMap::new() }
266+
Self { values: BTreeMap::new(), modules: BTreeMap::new() }
267267
}
268268

269269
/// Merge two import sets

crates/tinywasm/src/instance.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{Error, FuncHandle, FuncHandleTyped, Imports, MemoryRef, MemoryRefMut
1212
#[derive(Debug, Clone)]
1313
pub struct ModuleInstance(pub(crate) Rc<ModuleInstanceInner>);
1414

15-
#[allow(dead_code)]
15+
#[expect(dead_code)]
1616
#[derive(Debug)]
1717
pub(crate) struct ModuleInstanceInner {
1818
pub(crate) failed_to_instantiate: bool,
@@ -90,7 +90,7 @@ impl ModuleInstance {
9090
exports: module.0.exports,
9191
};
9292

93-
let instance = ModuleInstance::new(instance);
93+
let instance = Self::new(instance);
9494
store.add_instance(instance.clone());
9595

9696
match (elem_trapped, data_trapped) {

0 commit comments

Comments
 (0)