From 2d69fbb206ef620251f7cf6618131e6be226eca7 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Thu, 30 Nov 2023 15:58:37 +0100 Subject: chore: remove unneeded dependencies Signed-off-by: Henry Gressmann --- Cargo.lock | 76 -------------------------------------------- crates/tinywasm/Cargo.toml | 6 ++-- crates/tinywasm/src/error.rs | 23 ++++++++++---- 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 @@ -17,24 +17,6 @@ version = "1.0.2" 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" @@ -139,16 +121,6 @@ version = "0.28.1" 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" @@ -307,26 +279,6 @@ dependencies = [ "unicode-ident", ] -[[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" @@ -341,8 +293,6 @@ dependencies = [ name = "tinywasm" version = "0.0.0" dependencies = [ - "hashbrown", - "thiserror-core", "tracing", "wasmparser-nostd", ] @@ -437,12 +387,6 @@ version = "0.1.0" 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" @@ -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(message: &str) -> Result { Err(Self::Other(message.to_string())) -- cgit v1.3.1