summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock76
-rw-r--r--crates/tinywasm/Cargo.toml6
-rw-r--r--crates/tinywasm/src/error.rs23
3 files changed, 19 insertions, 86 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ebce3fa..6557115 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -18,24 +18,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
-name = "ahash"
-version = "0.8.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a"
-dependencies = [
- "cfg-if",
- "once_cell",
- "version_check",
- "zerocopy",
-]
-
-[[package]]
-name = "allocator-api2"
-version = "0.2.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
-
-[[package]]
name = "argh"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -140,16 +122,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
-name = "hashbrown"
-version = "0.14.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
-dependencies = [
- "ahash",
- "allocator-api2",
-]
-
-[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -308,26 +280,6 @@ dependencies = [
]
[[package]]
-name = "thiserror-core"
-version = "1.0.50"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c001ee18b7e5e3f62cbf58c7fe220119e68d902bb7443179c0c8aef30090e999"
-dependencies = [
- "thiserror-core-impl",
-]
-
-[[package]]
-name = "thiserror-core-impl"
-version = "1.0.50"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e4c60d69f36615a077cc7663b9cb8e42275722d23e58a7fa3d2c7f2915d09d04"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
name = "thread_local"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -341,8 +293,6 @@ dependencies = [
name = "tinywasm"
version = "0.0.0"
dependencies = [
- "hashbrown",
- "thiserror-core",
"tracing",
"wasmparser-nostd",
]
@@ -438,12 +388,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
-name = "version_check"
-version = "0.9.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
-
-[[package]]
name = "wasmparser-nostd"
version = "0.100.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -473,23 +417,3 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-
-[[package]]
-name = "zerocopy"
-version = "0.7.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0"
-dependencies = [
- "zerocopy-derive",
-]
-
-[[package]]
-name = "zerocopy-derive"
-version = "0.7.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml
index 807a19f..02ea1f5 100644
--- a/crates/tinywasm/Cargo.toml
+++ b/crates/tinywasm/Cargo.toml
@@ -7,11 +7,11 @@ edition="2021"
path="src/lib.rs"
[dependencies]
-thiserror={version="1.0", package="thiserror-core", default-features=false}
+# fork of wasmparser with no_std support, see https://github.com/bytecodealliance/wasmtime/issues/3495
+# TODO: create dependency free parser
wasmparser={version="0.100", package="wasmparser-nostd", default-features=false}
tracing={version="0.1.38", default-features=false} # logging
-hashbrown="0.14"
[features]
default=["std"]
-std=["thiserror/std"]
+std=[]
diff --git a/crates/tinywasm/src/error.rs b/crates/tinywasm/src/error.rs
index a253880..9b97a59 100644
--- a/crates/tinywasm/src/error.rs
+++ b/crates/tinywasm/src/error.rs
@@ -1,18 +1,27 @@
use alloc::string::{String, ToString};
-use thiserror::Error;
+use core::fmt::Display;
-#[derive(Debug, Error)]
+#[derive(Debug)]
pub enum Error {
- #[error("error parsing module")]
ParseError { message: String, offset: usize },
-
- #[error("unsupported feature: {0}")]
UnsupportedFeature(String),
-
- #[error("unknown error: {0}")]
Other(String),
}
+impl Display for Error {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+ match self {
+ Self::ParseError { message, offset } => {
+ write!(f, "error parsing module: {} at offset {}", message, offset)
+ }
+ Self::UnsupportedFeature(feature) => write!(f, "unsupported feature: {}", feature),
+ Self::Other(message) => write!(f, "unknown error: {}", message),
+ }
+ }
+}
+
+impl crate::std::error::Error for Error {}
+
impl Error {
pub fn other<T>(message: &str) -> Result<T, Self> {
Err(Self::Other(message.to_string()))