Apply cargo-fix on wasmi (#191)
* cargo-fix wasmi * fmt * Remove allow_failures * Add dyn in benches * Fix nightly
This commit is contained in:
parent
57cc6c6a3d
commit
b67af25899
|
@ -11,8 +11,6 @@ matrix:
|
||||||
- rust: stable
|
- rust: stable
|
||||||
- rust: stable
|
- rust: stable
|
||||||
env: TARGET=armv7-unknown-linux-gnueabihf
|
env: TARGET=armv7-unknown-linux-gnueabihf
|
||||||
allow_failures:
|
|
||||||
- rust: nightly
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- if [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then rustup target add wasm32-unknown-unknown; fi
|
- if [ "$TRAVIS_RUST_VERSION" == "nightly" ]; then rustup target add wasm32-unknown-unknown; fi
|
||||||
|
|
|
@ -35,6 +35,8 @@ std = [
|
||||||
]
|
]
|
||||||
# Enable for no_std support
|
# Enable for no_std support
|
||||||
core = [
|
core = [
|
||||||
|
# `core` doesn't support vec_memory
|
||||||
|
"vec_memory",
|
||||||
"wasmi-validation/core",
|
"wasmi-validation/core",
|
||||||
"libm"
|
"libm"
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,7 +13,7 @@ use wasmi::{ImportsBuilder, Module, ModuleInstance, NopExternals, RuntimeValue};
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
|
|
||||||
// Load a module from a file.
|
// Load a module from a file.
|
||||||
fn load_from_file(filename: &str) -> Result<Module, Box<error::Error>> {
|
fn load_from_file(filename: &str) -> Result<Module, Box<dyn error::Error>> {
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
let mut file = File::open(filename)?;
|
let mut file = File::open(filename)?;
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{
|
||||||
use alloc::prelude::v1::*;
|
rc::{Rc, Weak},
|
||||||
use alloc::rc::{Rc, Weak};
|
vec::Vec,
|
||||||
|
};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use host::Externals;
|
use host::Externals;
|
||||||
use isa;
|
use isa;
|
||||||
|
|
|
@ -114,11 +114,11 @@ pub trait HostError: 'static + ::core::fmt::Display + ::core::fmt::Debug + Send
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HostError {
|
impl dyn HostError {
|
||||||
/// Attempt to downcast this `HostError` to a concrete type by reference.
|
/// Attempt to downcast this `HostError` to a concrete type by reference.
|
||||||
pub fn downcast_ref<T: HostError>(&self) -> Option<&T> {
|
pub fn downcast_ref<T: HostError>(&self) -> Option<&T> {
|
||||||
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
||||||
unsafe { Some(&*(self as *const HostError as *const T)) }
|
unsafe { Some(&*(self as *const dyn HostError as *const T)) }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ impl HostError {
|
||||||
/// reference.
|
/// reference.
|
||||||
pub fn downcast_mut<T: HostError>(&mut self) -> Option<&mut T> {
|
pub fn downcast_mut<T: HostError>(&mut self) -> Option<&mut T> {
|
||||||
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
if self.__private_get_type_id__() == TypeId::of::<T>() {
|
||||||
unsafe { Some(&mut *(self as *mut HostError as *mut T)) }
|
unsafe { Some(&mut *(self as *mut dyn HostError as *mut T)) }
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -257,5 +257,5 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that `HostError` trait is object safe.
|
// Tests that `HostError` trait is object safe.
|
||||||
fn _host_error_is_object_safe(_: &HostError) {}
|
fn _host_error_is_object_safe(_: &dyn HostError) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{collections::BTreeMap, string::String};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
|
|
||||||
use alloc::collections::BTreeMap;
|
|
||||||
|
|
||||||
use func::FuncRef;
|
use func::FuncRef;
|
||||||
use global::GlobalRef;
|
use global::GlobalRef;
|
||||||
|
@ -103,7 +100,7 @@ pub trait ImportResolver {
|
||||||
/// [`ImportResolver`]: trait.ImportResolver.html
|
/// [`ImportResolver`]: trait.ImportResolver.html
|
||||||
/// [`ModuleImportResolver`]: trait.ModuleImportResolver.html
|
/// [`ModuleImportResolver`]: trait.ModuleImportResolver.html
|
||||||
pub struct ImportsBuilder<'a> {
|
pub struct ImportsBuilder<'a> {
|
||||||
modules: BTreeMap<String, &'a ModuleImportResolver>,
|
modules: BTreeMap<String, &'a dyn ModuleImportResolver>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for ImportsBuilder<'a> {
|
impl<'a> Default for ImportsBuilder<'a> {
|
||||||
|
@ -124,7 +121,7 @@ impl<'a> ImportsBuilder<'a> {
|
||||||
pub fn with_resolver<N: Into<String>>(
|
pub fn with_resolver<N: Into<String>>(
|
||||||
mut self,
|
mut self,
|
||||||
name: N,
|
name: N,
|
||||||
resolver: &'a ModuleImportResolver,
|
resolver: &'a dyn ModuleImportResolver,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.modules.insert(name.into(), resolver);
|
self.modules.insert(name.into(), resolver);
|
||||||
self
|
self
|
||||||
|
@ -133,11 +130,15 @@ impl<'a> ImportsBuilder<'a> {
|
||||||
/// Register an resolver by a name.
|
/// Register an resolver by a name.
|
||||||
///
|
///
|
||||||
/// Mutable borrowed version.
|
/// Mutable borrowed version.
|
||||||
pub fn push_resolver<N: Into<String>>(&mut self, name: N, resolver: &'a ModuleImportResolver) {
|
pub fn push_resolver<N: Into<String>>(
|
||||||
|
&mut self,
|
||||||
|
name: N,
|
||||||
|
resolver: &'a dyn ModuleImportResolver,
|
||||||
|
) {
|
||||||
self.modules.insert(name.into(), resolver);
|
self.modules.insert(name.into(), resolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolver(&self, name: &str) -> Option<&ModuleImportResolver> {
|
fn resolver(&self, name: &str) -> Option<&dyn ModuleImportResolver> {
|
||||||
self.modules.get(name).cloned()
|
self.modules.get(name).cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,7 @@
|
||||||
//! - Reserved immediates are ignored for `call_indirect`, `current_memory`, `grow_memory`.
|
//! - Reserved immediates are ignored for `call_indirect`, `current_memory`, `grow_memory`.
|
||||||
//!
|
//!
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
use alloc::vec::Vec;
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
|
|
||||||
/// Should we keep a value before "discarding" a stack frame?
|
/// Should we keep a value before "discarding" a stack frame?
|
||||||
///
|
///
|
||||||
|
|
15
src/lib.rs
15
src/lib.rs
|
@ -96,8 +96,6 @@
|
||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
//// alloc is required in no_std
|
|
||||||
#![cfg_attr(not(feature = "std"), feature(alloc, alloc_prelude))]
|
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -119,8 +117,11 @@ extern crate parity_wasm;
|
||||||
|
|
||||||
extern crate wasmi_validation as validation;
|
extern crate wasmi_validation as validation;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
use alloc::{
|
||||||
use alloc::prelude::v1::*;
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error;
|
use std::error;
|
||||||
|
@ -239,7 +240,7 @@ pub enum TrapKind {
|
||||||
/// Typically returned from an implementation of [`Externals`].
|
/// Typically returned from an implementation of [`Externals`].
|
||||||
///
|
///
|
||||||
/// [`Externals`]: trait.Externals.html
|
/// [`Externals`]: trait.Externals.html
|
||||||
Host(Box<host::HostError>),
|
Host(Box<dyn host::HostError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TrapKind {
|
impl TrapKind {
|
||||||
|
@ -273,7 +274,7 @@ pub enum Error {
|
||||||
/// Trap.
|
/// Trap.
|
||||||
Trap(Trap),
|
Trap(Trap),
|
||||||
/// Custom embedder error.
|
/// Custom embedder error.
|
||||||
Host(Box<host::HostError>),
|
Host(Box<dyn host::HostError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
@ -285,7 +286,7 @@ impl Error {
|
||||||
/// [`Host`]: enum.Error.html#variant.Host
|
/// [`Host`]: enum.Error.html#variant.Host
|
||||||
/// [`Trap`]: enum.Error.html#variant.Trap
|
/// [`Trap`]: enum.Error.html#variant.Trap
|
||||||
/// [`TrapKind::Host`]: enum.TrapKind.html#variant.Host
|
/// [`TrapKind::Host`]: enum.TrapKind.html#variant.Host
|
||||||
pub fn as_host_error(&self) -> Option<&host::HostError> {
|
pub fn as_host_error(&self) -> Option<&dyn host::HostError> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::Host(ref host_err) => Some(&**host_err),
|
Error::Host(ref host_err) => Some(&**host_err),
|
||||||
Error::Trap(ref trap) => match *trap.kind() {
|
Error::Trap(ref trap) => match *trap.kind() {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{rc::Rc, string::ToString, vec::Vec};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use core::{
|
use core::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
cmp, fmt,
|
cmp, fmt,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! An implementation of `ByteBuf` based on a plain `Vec`.
|
//! An implementation of `ByteBuf` based on a plain `Vec`.
|
||||||
|
|
||||||
use alloc::prelude::v1::*;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
pub struct ByteBuf {
|
pub struct ByteBuf {
|
||||||
buf: Vec<u8>,
|
buf: Vec<u8>,
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{
|
||||||
use alloc::prelude::v1::*;
|
borrow::ToOwned,
|
||||||
use alloc::rc::Rc;
|
rc::Rc,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use Trap;
|
use Trap;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
use libm::{F32Ext, F64Ext};
|
|
||||||
|
|
||||||
use core::cmp::{Ordering, PartialEq, PartialOrd};
|
use core::cmp::{Ordering, PartialEq, PartialOrd};
|
||||||
use core::ops::{Add, Div, Mul, Neg, Rem, Sub};
|
use core::ops::{Add, Div, Mul, Neg, Rem, Sub};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{string::String, vec::Vec};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
|
|
||||||
use parity_wasm::elements::{BlockType, FuncBody, Instruction};
|
use parity_wasm::elements::{BlockType, FuncBody, Instruction};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::vec::Vec;
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
isa,
|
isa,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::ops;
|
use core::ops;
|
||||||
use core::{u32, usize};
|
use core::{u32, usize};
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{rc::Rc, vec::Vec};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
use alloc::rc::Rc;
|
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use core::u32;
|
use core::u32;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
#[allow(unused_imports)]
|
use alloc::vec::Vec;
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
use parity_wasm::elements::{
|
use parity_wasm::elements::{
|
||||||
BlockType, FunctionType, GlobalType, MemoryType, TableType, ValueType,
|
BlockType, FunctionType, GlobalType, MemoryType, TableType, ValueType,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#[allow(unused_imports)]
|
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
context::ModuleContext, stack::StackWithLimit, util::Locals, Error, FuncValidator,
|
context::ModuleContext, stack::StackWithLimit, util::Locals, Error, FuncValidator,
|
||||||
DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX,
|
DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX,
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
// #![warn(missing_docs)]
|
// #![warn(missing_docs)]
|
||||||
|
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
//// alloc is required in no_std
|
|
||||||
#![cfg_attr(not(feature = "std"), feature(alloc, alloc_prelude))]
|
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -21,8 +19,7 @@ pub const DEFAULT_TABLE_INDEX: u32 = 0;
|
||||||
/// Maximal number of pages that a wasm instance supports.
|
/// Maximal number of pages that a wasm instance supports.
|
||||||
pub const LINEAR_MEMORY_MAX_PAGES: u32 = 65536;
|
pub const LINEAR_MEMORY_MAX_PAGES: u32 = 65536;
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
use alloc::{string::String, vec::Vec};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error;
|
use std::error;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#[allow(unused_imports)]
|
use alloc::{string::String, vec::Vec};
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
|
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
#[allow(unused_imports)]
|
use alloc::string::String;
|
||||||
use alloc::prelude::v1::*;
|
|
||||||
use parity_wasm::elements::{Local, ValueType};
|
use parity_wasm::elements::{Local, ValueType};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in New Issue