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