cargo-fix wasmi
This commit is contained in:
parent
1bf3cbe5d0
commit
925634c4a0
|
@ -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) {}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,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 +124,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 +133,11 @@ 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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -239,7 +239,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 +273,7 @@ pub enum Error {
|
|||
/// Trap.
|
||||
Trap(Trap),
|
||||
/// Custom embedder error.
|
||||
Host(Box<host::HostError>),
|
||||
Host(Box<dyn host::HostError>),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
|
@ -285,7 +285,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() {
|
||||
|
|
Loading…
Reference in New Issue