diff --git a/Cargo.toml b/Cargo.toml index bb06dcb0..5fc92998 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,27 +11,14 @@ A simple event-driven library for parsing WebAssembly binary files. exclude = ["fuzz/**/*", "tests/**/*", "testsuite/**/*"] edition = "2018" -[dependencies] - [dev-dependencies] criterion = "0.2" wast = "3.0.4" -[dependencies.hashbrown] -version = "0.5.0" -optional = true - [badges] travis-ci = { repository = "yurydelendik/wasmparser.rs" } [features] -# The "std" feature enables use of libstd. The "core" feature enables use -# of some minimal std-like replacement libraries. At least one of these two -# features needs to be enabled. -default = ["std"] -std = [] -core = ["hashbrown"] - # The "deterministic" feature supports only wasm code with "deterministic" execution # across any hardware. This feature is very critical for many Blockchain infrastructures # that rely on deterministic executions of smart contracts across different hardwares. diff --git a/src/binary_reader.rs b/src/binary_reader.rs index 0e7227b3..882559c3 100644 --- a/src/binary_reader.rs +++ b/src/binary_reader.rs @@ -938,7 +938,7 @@ impl<'a> BinaryReader<'a> { } else { self.position = position; let idx = self.read_var_s33()?; - if idx < 0 || idx > (core::u32::MAX as i64) { + if idx < 0 || idx > (std::u32::MAX as i64) { return Err(BinaryReaderError { message: "invalid function type", offset: position, diff --git a/src/lib.rs b/src/lib.rs index 38266c46..13d791c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,20 +23,6 @@ //! this is not the right library for you. You could however, build such //! a data-structure using this library. -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(not(feature = "std"))] -#[macro_use] -extern crate alloc as std; -#[cfg(feature = "std")] -#[macro_use] -extern crate std; - -#[cfg(not(feature = "std"))] -use hashbrown::HashSet; -#[cfg(feature = "std")] -use std::collections::HashSet; - pub use crate::binary_reader::BinaryReader; pub use crate::binary_reader::Range; use crate::binary_reader::SectionHeader; diff --git a/src/operators_validator.rs b/src/operators_validator.rs index b304767d..cb1dd1a5 100644 --- a/src/operators_validator.rs +++ b/src/operators_validator.rs @@ -13,10 +13,9 @@ * limitations under the License. */ -use core::cmp::min; -use core::result; +use std::cmp::min; +use std::result; use std::str; -use std::vec::Vec; use crate::primitives::{ FuncType, GlobalType, MemoryImmediate, MemoryType, Operator, SIMDLaneIndex, TableType, Type, diff --git a/src/primitives.rs b/src/primitives.rs index 9543557b..7a039886 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -13,12 +13,9 @@ * limitations under the License. */ -use core::result; -use std::boxed::Box; -use std::fmt; - -#[cfg(feature = "std")] use std::error::Error; +use std::fmt; +use std::result; #[derive(Debug, Copy, Clone)] pub struct BinaryReaderError { @@ -28,7 +25,6 @@ pub struct BinaryReaderError { pub type Result = result::Result; -#[cfg(feature = "std")] impl Error for BinaryReaderError {} impl fmt::Display for BinaryReaderError { diff --git a/src/readers/module.rs b/src/readers/module.rs index 36a9c339..9a189193 100644 --- a/src/readers/module.rs +++ b/src/readers/module.rs @@ -13,8 +13,6 @@ * limitations under the License. */ -use core::iter::{IntoIterator, Iterator}; - use super::{ BinaryReader, BinaryReaderError, CustomSectionKind, Range, Result, SectionCode, SectionHeader, }; diff --git a/src/tests.rs b/src/tests.rs index 22798ac9..bf9a138c 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -13,7 +13,6 @@ * limitations under the License. */ -#[cfg(feature = "std")] #[cfg(test)] mod simple_tests { use crate::operators_validator::OperatorValidatorConfig; @@ -316,7 +315,6 @@ mod simple_tests { } } -#[cfg(feature = "std")] #[cfg(test)] mod wast_tests { use crate::operators_validator::OperatorValidatorConfig; diff --git a/src/validator.rs b/src/validator.rs index 485d550f..6e9e87ff 100644 --- a/src/validator.rs +++ b/src/validator.rs @@ -13,11 +13,9 @@ * limitations under the License. */ -use super::HashSet; -use core::result; +use std::collections::HashSet; +use std::result; use std::str; -use std::string::String; -use std::vec::Vec; use crate::limits::{ MAX_WASM_FUNCTIONS, MAX_WASM_FUNCTION_LOCALS, MAX_WASM_GLOBALS, MAX_WASM_MEMORIES, diff --git a/test-no_std.sh b/test-no_std.sh deleted file mode 100755 index 549e413f..00000000 --- a/test-no_std.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# This is the test script for testing the no_std configuration of -# packages which support it. - -# Repository top-level directory. -topdir=$(dirname "$0") -cd "$topdir" - -function banner { - echo "====== $* ======" -} - -banner "Rust unit tests" - -# Test with just "core" enabled. -cargo +nightly test --no-default-features --features core - -# Test with "core" and "std" enabled at the same time. -cargo +nightly test --features core - -banner "OK"