Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Remove std and core features (#137)
Browse files Browse the repository at this point in the history
This commit performs a similar transformation as
bytecodealliance/wasmtime#554, with similar motivation listed out there
as well.
  • Loading branch information
alexcrichton authored and yurydelendik committed Dec 4, 2019
1 parent a612654 commit 194135a
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 68 deletions.
13 changes: 0 additions & 13 deletions Cargo.toml
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/binary_reader.rs
Expand Up @@ -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,
Expand Down
14 changes: 0 additions & 14 deletions src/lib.rs
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/operators_validator.rs
Expand Up @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions src/primitives.rs
Expand Up @@ -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 {
Expand All @@ -28,7 +25,6 @@ pub struct BinaryReaderError {

pub type Result<T> = result::Result<T, BinaryReaderError>;

#[cfg(feature = "std")]
impl Error for BinaryReaderError {}

impl fmt::Display for BinaryReaderError {
Expand Down
2 changes: 0 additions & 2 deletions src/readers/module.rs
Expand Up @@ -13,8 +13,6 @@
* limitations under the License.
*/

use core::iter::{IntoIterator, Iterator};

use super::{
BinaryReader, BinaryReaderError, CustomSectionKind, Range, Result, SectionCode, SectionHeader,
};
Expand Down
2 changes: 0 additions & 2 deletions src/tests.rs
Expand Up @@ -13,7 +13,6 @@
* limitations under the License.
*/

#[cfg(feature = "std")]
#[cfg(test)]
mod simple_tests {
use crate::operators_validator::OperatorValidatorConfig;
Expand Down Expand Up @@ -316,7 +315,6 @@ mod simple_tests {
}
}

#[cfg(feature = "std")]
#[cfg(test)]
mod wast_tests {
use crate::operators_validator::OperatorValidatorConfig;
Expand Down
6 changes: 2 additions & 4 deletions src/validator.rs
Expand Up @@ -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,
Expand Down
23 changes: 0 additions & 23 deletions test-no_std.sh

This file was deleted.

0 comments on commit 194135a

Please sign in to comment.