From 19d21ff831eddec4a96d9b30de29cb2209caa4f1 Mon Sep 17 00:00:00 2001 From: Edoardo Marangoni Date: Wed, 15 Jan 2025 15:15:54 +0100 Subject: [PATCH] chore: Make linter happy --- lib/c-api/src/wasm_c_api/types/extern_.rs | 7 +++- lib/c-api/src/wasm_c_api/types/mod.rs | 2 + lib/c-api/src/wasm_c_api/types/tag.rs | 10 +++++ lib/c-api/src/wasm_c_api/types/value.rs | 3 ++ lib/c-api/src/wasm_c_api/value.rs | 7 +++- lib/compiler-llvm/src/compiler.rs | 14 +++---- lib/compiler-llvm/src/translator/code.rs | 47 ++++++++++------------- lib/compiler-llvm/src/translator/state.rs | 4 +- lib/compiler/src/engine/artifact.rs | 1 + lib/compiler/src/engine/link.rs | 4 +- lib/compiler/src/engine/unwind/systemv.rs | 1 - lib/compiler/src/types/relocation.rs | 16 ++++---- lib/types/src/types.rs | 4 +- lib/types/src/vmoffsets.rs | 1 + lib/vm/src/libcalls.rs | 46 ++++++++++++++++------ lib/vm/src/libcalls/eh/dwarf/eh.rs | 11 +++--- lib/vm/src/libcalls/eh/dwarf/mod.rs | 4 +- lib/vm/src/libcalls/eh/mod.rs | 5 +++ tests/lib/wast/src/wast.rs | 2 +- 19 files changed, 119 insertions(+), 70 deletions(-) create mode 100644 lib/c-api/src/wasm_c_api/types/tag.rs diff --git a/lib/c-api/src/wasm_c_api/types/extern_.rs b/lib/c-api/src/wasm_c_api/types/extern_.rs index 4218c2a70d4..fcbbbc2adc3 100644 --- a/lib/c-api/src/wasm_c_api/types/extern_.rs +++ b/lib/c-api/src/wasm_c_api/types/extern_.rs @@ -1,7 +1,7 @@ use super::super::externals::wasm_extern_t; use super::{ wasm_functype_t, wasm_globaltype_t, wasm_memorytype_t, wasm_tabletype_t, WasmFunctionType, - WasmGlobalType, WasmMemoryType, WasmTableType, + WasmGlobalType, WasmMemoryType, WasmTableType, WasmTagType, }; use std::convert::{TryFrom, TryInto}; use std::mem; @@ -18,6 +18,7 @@ pub enum wasm_externkind_enum { WASM_EXTERN_GLOBAL = 1, WASM_EXTERN_TABLE = 2, WASM_EXTERN_MEMORY = 3, + WASM_EXTERN_TAG = 4, } impl From for wasm_externkind_enum { @@ -32,6 +33,7 @@ impl From<&ExternType> for wasm_externkind_enum { ExternType::Global(_) => Self::WASM_EXTERN_GLOBAL, ExternType::Table(_) => Self::WASM_EXTERN_TABLE, ExternType::Memory(_) => Self::WASM_EXTERN_MEMORY, + ExternType::Tag(_) => Self::WASM_EXTERN_TAG, } } } @@ -42,6 +44,7 @@ pub(crate) enum WasmExternType { Global(WasmGlobalType), Table(WasmTableType), Memory(WasmMemoryType), + Tag(WasmTagType), } #[allow(non_camel_case_types)] @@ -66,6 +69,7 @@ impl wasm_externtype_t { ExternType::Memory(memory_type) => { WasmExternType::Memory(WasmMemoryType::new(memory_type)) } + ExternType::Tag(tag_type) => WasmExternType::Tag(WasmTagType::new(tag_type)), }, } } @@ -110,6 +114,7 @@ pub unsafe extern "C" fn wasm_externtype_kind( WasmExternType::Global(_) => wasm_externkind_enum::WASM_EXTERN_GLOBAL, WasmExternType::Table(_) => wasm_externkind_enum::WASM_EXTERN_TABLE, WasmExternType::Memory(_) => wasm_externkind_enum::WASM_EXTERN_MEMORY, + WasmExternType::Tag(_) => wasm_externkind_enum::WASM_EXTERN_TAG, }) as wasm_externkind_t } diff --git a/lib/c-api/src/wasm_c_api/types/mod.rs b/lib/c-api/src/wasm_c_api/types/mod.rs index c5b7ed03f67..c6e7c18ef78 100644 --- a/lib/c-api/src/wasm_c_api/types/mod.rs +++ b/lib/c-api/src/wasm_c_api/types/mod.rs @@ -7,6 +7,7 @@ mod import; mod memory; mod mutability; mod table; +mod tag; mod value; pub use export::*; @@ -18,6 +19,7 @@ pub use import::*; pub use memory::*; pub use mutability::*; pub use table::*; +use tag::*; pub use value::*; #[allow(non_camel_case_types)] diff --git a/lib/c-api/src/wasm_c_api/types/tag.rs b/lib/c-api/src/wasm_c_api/types/tag.rs new file mode 100644 index 00000000000..057d8b7b8ea --- /dev/null +++ b/lib/c-api/src/wasm_c_api/types/tag.rs @@ -0,0 +1,10 @@ +use wasmer_types::TagType; + +#[derive(Debug, Clone)] +pub(crate) struct WasmTagType {} + +impl WasmTagType { + pub(crate) fn new(_tag_type: TagType) -> Self { + panic!() + } +} diff --git a/lib/c-api/src/wasm_c_api/types/value.rs b/lib/c-api/src/wasm_c_api/types/value.rs index 96712f369c2..fc00f9fec39 100644 --- a/lib/c-api/src/wasm_c_api/types/value.rs +++ b/lib/c-api/src/wasm_c_api/types/value.rs @@ -12,6 +12,7 @@ pub enum wasm_valkind_enum { WASM_F64 = 3, WASM_EXTERNREF = 128, WASM_FUNCREF = 129, + WASM_EXNREF = 130, } impl From for wasm_valkind_enum { @@ -24,6 +25,7 @@ impl From for wasm_valkind_enum { Type::V128 => todo!("no v128 type in Wasm C API yet!"), Type::ExternRef => Self::WASM_EXTERNREF, Type::FuncRef => Self::WASM_FUNCREF, + Type::ExceptionRef => Self::WASM_EXNREF, } } } @@ -38,6 +40,7 @@ impl From for Type { WASM_F64 => Type::F64, WASM_EXTERNREF => Type::ExternRef, WASM_FUNCREF => Type::FuncRef, + WASM_EXNREF => Type::ExternRef, } } } diff --git a/lib/c-api/src/wasm_c_api/value.rs b/lib/c-api/src/wasm_c_api/value.rs index 5a5a6e67561..a678751ba48 100644 --- a/lib/c-api/src/wasm_c_api/value.rs +++ b/lib/c-api/src/wasm_c_api/value.rs @@ -97,10 +97,12 @@ impl std::fmt::Debug for wasm_val_t { Ok(wasm_valkind_enum::WASM_EXTERNREF) => { ds.field("anyref", &unsafe { self.of.wref }); } - Ok(wasm_valkind_enum::WASM_FUNCREF) => { ds.field("funcref", &unsafe { self.of.wref }); } + Ok(wasm_valkind_enum::WASM_EXNREF) => { + ds.field("exnref", &unsafe { self.of.wref }); + } Err(_) => { ds.field("value", &"Invalid value type"); } @@ -152,6 +154,7 @@ pub unsafe extern "C" fn wasm_val_copy( }, wasm_valkind_enum::WASM_EXTERNREF => wasm_val_inner { wref: val.of.wref }, wasm_valkind_enum::WASM_FUNCREF => wasm_val_inner { wref: val.of.wref }, + wasm_valkind_enum::WASM_EXNREF => wasm_val_inner { wref: val.of.wref }, } }); otherwise ()); } @@ -188,6 +191,7 @@ impl TryFrom for wasm_valkind_enum { 3 => wasm_valkind_enum::WASM_F64, 128 => wasm_valkind_enum::WASM_EXTERNREF, 129 => wasm_valkind_enum::WASM_FUNCREF, + 130 => wasm_valkind_enum::WASM_EXNREF, _ => return Err("valkind value out of bounds"), }) } @@ -214,6 +218,7 @@ impl TryFrom<&wasm_val_t> for Value { return Err("EXTERNREF not supported at this time") } wasm_valkind_enum::WASM_FUNCREF => return Err("FUNCREF not supported at this time"), + wasm_valkind_enum::WASM_EXNREF => return Err("EXNREF not supported at this time"), }) } } diff --git a/lib/compiler-llvm/src/compiler.rs b/lib/compiler-llvm/src/compiler.rs index bcc58f9d37c..2a6d932937f 100644 --- a/lib/compiler-llvm/src/compiler.rs +++ b/lib/compiler-llvm/src/compiler.rs @@ -84,6 +84,7 @@ impl SymbolRegistry for ShortNames { } impl LLVMCompiler { + #[allow(clippy::too_many_arguments)] fn compile_native_object( &self, target: &Target, @@ -311,15 +312,14 @@ impl Compiler for LLVMCompiler { .relocations .iter() .filter(|v| v.kind.needs_got()) - .for_each(|v| _ = got_targets.insert(v.reloc_target.clone())); + .for_each(|v| _ = got_targets.insert(v.reloc_target)); compiled_function .custom_sections .iter() - .map(|v| v.1.relocations.iter()) - .flatten() + .flat_map(|v| v.1.relocations.iter()) .filter(|v| v.kind.needs_got()) - .for_each(|v| _ = got_targets.insert(v.reloc_target.clone())); + .for_each(|v| _ = got_targets.insert(v.reloc_target)); if compiled_function .eh_frame_section_indices @@ -449,11 +449,7 @@ impl Compiler for LLVMCompiler { map.insert(reloc, i); } - let got_data: Vec = got_data - .into_iter() - .map(|v| v.to_ne_bytes()) - .flatten() - .collect(); + let got_data: Vec = got_data.into_iter().flat_map(|v| v.to_ne_bytes()).collect(); let index = SectionIndex::from_u32(module_custom_sections.len() as u32); module_custom_sections.push(CustomSection { protection: CustomSectionProtection::Read, diff --git a/lib/compiler-llvm/src/translator/code.rs b/lib/compiler-llvm/src/translator/code.rs index 56c5f68fc68..d5c7ceba49d 100644 --- a/lib/compiler-llvm/src/translator/code.rs +++ b/lib/compiler-llvm/src/translator/code.rs @@ -1428,7 +1428,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { fn get_or_insert_global_tag(&mut self, tag: u32) -> BasicValueEnum<'ctx> { if let Some(tag) = self.tags_cache.get(&tag) { - return tag.clone(); + return *tag; } let tag_ty = self @@ -1455,7 +1455,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { let tag_glbl = tag_glbl.as_basic_value_enum(); - self.tags_cache.insert(tag, tag_glbl.clone()); + self.tags_cache.insert(tag, tag_glbl); tag_glbl } @@ -1465,7 +1465,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { signature: &FunctionType, ) -> Result, CompileError> { if let Some(ty) = self.exception_types_cache.get(&tag) { - return Ok(ty.clone()); + return Ok(*ty); } let types = signature .params() @@ -1474,7 +1474,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { .collect::, CompileError>>()?; let ty = self.context.struct_type(&types, false); - self.exception_types_cache.insert(tag, ty.clone()); + self.exception_types_cache.insert(tag, ty); Ok(ty) } @@ -1489,7 +1489,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { if size == 4 { (tag + 2099) as usize } else if size == 8 { - let mut base = vec!['w' as u8, 'a' as u8, 's' as u8, 'm' as u8]; + let mut base = vec![b'w', b'a', b's', b'm']; base.append(&mut tag.to_be_bytes().to_vec()); u64::from_be_bytes(base.try_into().unwrap()) as usize } else { @@ -12341,7 +12341,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { // Read each value from the data ptr. let values = params - .into_iter() + .iter() .enumerate() .map(|(i, v)| { let name = format!("value{i}"); @@ -12414,7 +12414,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { // Read each value from the data ptr. let mut values = params - .into_iter() + .iter() .enumerate() .map(|(i, v)| { let name = format!("value{i}"); @@ -12524,26 +12524,21 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { let params = signature.params(); let values = self.state.popn_save_extra(params.len())?; - values - .iter() - .enumerate() - .map(|(i, (v, _))| { - let t = type_to_llvm(self.intrinsics, params[i])?; - if t != v.get_type() { - return Err(CompileError::Codegen(format!( - "Incompatible types: {:?} != {:?}", - t, - v.get_type() - ))); - } + values.iter().enumerate().try_for_each(|(i, (v, _))| { + let t = type_to_llvm(self.intrinsics, params[i])?; + if t != v.get_type() { + return Err(CompileError::Codegen(format!( + "Incompatible types: {:?} != {:?}", + t, + v.get_type() + ))); + } - Ok(()) - }) - .collect::>()?; + Ok(()) + })?; - let exception_type: inkwell::types::StructType = self - .get_or_insert_exception_type(tag_index, signature)? - .clone(); + let exception_type: inkwell::types::StructType = + self.get_or_insert_exception_type(tag_index, signature)?; let size = exception_type.size_of().unwrap(); @@ -12626,7 +12621,7 @@ impl<'ctx, 'a> LLVMFunctionCodeGenerator<'ctx, 'a> { err!(self.builder.build_invoke( self.intrinsics.rethrow, - &[exc.into()], + &[exc], unreachable_block, pad, "throw", diff --git a/lib/compiler-llvm/src/translator/state.rs b/lib/compiler-llvm/src/translator/state.rs index b5c7f507589..1ff5307ef82 100644 --- a/lib/compiler-llvm/src/translator/state.rs +++ b/lib/compiler-llvm/src/translator/state.rs @@ -504,7 +504,7 @@ impl<'ctx> State<'ctx> { } pub(crate) fn get_landingpad(&mut self) -> Option> { - self.landingpads.back().map(|v| v.catch_block.clone()) + self.landingpads.back().map(|v| v.catch_block) } pub(crate) fn get_landingpad_for_tag(&mut self, tag: u32) -> Option> { @@ -512,7 +512,7 @@ impl<'ctx> State<'ctx> { if let Some(v) = self.landingpads_scope.get(&tag) { v.back().cloned() } else { - self.landingpads.back().map(|v| v.catch_block.clone()) + self.landingpads.back().map(|v| v.catch_block) } } diff --git a/lib/compiler/src/engine/artifact.rs b/lib/compiler/src/engine/artifact.rs index 659c2a51c40..7d86933a9ce 100644 --- a/lib/compiler/src/engine/artifact.rs +++ b/lib/compiler/src/engine/artifact.rs @@ -111,6 +111,7 @@ pub struct Artifact { /// module, corresponding to `ArtifactBuildVariant::Plain`, or loaded /// from an archive, corresponding to `ArtifactBuildVariant::Archived`. #[cfg_attr(feature = "artifact-size", derive(loupe::MemoryUsage))] +#[allow(clippy::large_enum_variant)] pub enum ArtifactBuildVariant { Plain(ArtifactBuild), Archived(ArtifactBuildFromArchive), diff --git a/lib/compiler/src/engine/link.rs b/lib/compiler/src/engine/link.rs index 2ee43f6fd9d..826233dd4fd 100644 --- a/lib/compiler/src/engine/link.rs +++ b/lib/compiler/src/engine/link.rs @@ -17,6 +17,7 @@ use std::{ use wasmer_types::{entity::PrimaryMap, LocalFunctionIndex, ModuleInfo}; use wasmer_vm::{libcalls::function_pointer, SectionBodyPtr}; +#[allow(clippy::too_many_arguments)] fn apply_relocation( body: usize, r: &impl RelocationLike, @@ -255,7 +256,7 @@ fn apply_relocation( RelocationKind::MachoArm64RelocPointerToGot => unsafe { if let Some(got) = got_info { let base = got.0; - let base = std::mem::transmute::(base); + let base = base as *const usize; if let Some(reloc_idx) = got.1.map.get(&reloc_target) { let got_address = base.wrapping_add(*reloc_idx); @@ -279,6 +280,7 @@ fn apply_relocation( /// Links a module, patching the allocated functions with the /// required relocations and jump tables. +#[allow(clippy::too_many_arguments)] pub fn link_module<'a>( _module: &ModuleInfo, allocated_functions: &PrimaryMap, diff --git a/lib/compiler/src/engine/unwind/systemv.rs b/lib/compiler/src/engine/unwind/systemv.rs index 57a2e60346f..d0d0f4a6b2a 100644 --- a/lib/compiler/src/engine/unwind/systemv.rs +++ b/lib/compiler/src/engine/unwind/systemv.rs @@ -248,7 +248,6 @@ impl UnwindRegistry { // Skip over the CIE and zero-length FDEs. // LLVM's libunwind emits a warning on zero-length FDEs. if current != start && len != 0 { - println!("Hehe!"); __register_frame(current); self.registrations.push(current as usize); } diff --git a/lib/compiler/src/types/relocation.rs b/lib/compiler/src/types/relocation.rs index 295a3674503..54dbf9e4c0a 100644 --- a/lib/compiler/src/types/relocation.rs +++ b/lib/compiler/src/types/relocation.rs @@ -141,14 +141,14 @@ pub enum RelocationKind { impl RelocationKind { pub fn needs_got(&self) -> bool { - match self { - RelocationKind::MachoArm64RelocGotLoadPage21 - | RelocationKind::MachoArm64RelocGotLoadPageoff12 - | RelocationKind::MachoArm64RelocPointerToGot - | RelocationKind::MachoX86_64RelocGotLoad - | RelocationKind::MachoX86_64RelocGot => true, - _ => false, - } + matches!( + self, + Self::MachoArm64RelocGotLoadPage21 + | Self::MachoArm64RelocGotLoadPageoff12 + | Self::MachoArm64RelocPointerToGot + | Self::MachoX86_64RelocGotLoad + | Self::MachoX86_64RelocGot + ) } } diff --git a/lib/types/src/types.rs b/lib/types/src/types.rs index 156be64022f..d44053fbbdd 100644 --- a/lib/types/src/types.rs +++ b/lib/types/src/types.rs @@ -493,12 +493,12 @@ impl TagType { /// Return types. pub fn results(&self) -> &[Type] { - &self.ty.results() + self.ty.results() } /// Parameter types. pub fn params(&self) -> &[Type] { - &self.ty.params() + self.ty.params() } /// Create a new [`TagType`] with the given kind and the associated type. diff --git a/lib/types/src/vmoffsets.rs b/lib/types/src/vmoffsets.rs index d76a708570a..dc59d9fc984 100644 --- a/lib/types/src/vmoffsets.rs +++ b/lib/types/src/vmoffsets.rs @@ -639,6 +639,7 @@ impl VMOffsets { /// Offsets for `VMTag` imports. impl VMOffsets { /// Return the size of `VMTagImport`. + #[allow(clippy::identity_op)] pub const fn size_of_vmtag_import(&self) -> u8 { 1 * self.pointer_size } diff --git a/lib/vm/src/libcalls.rs b/lib/vm/src/libcalls.rs index 373d725893d..61d19b5cab3 100644 --- a/lib/vm/src/libcalls.rs +++ b/lib/vm/src/libcalls.rs @@ -665,6 +665,10 @@ pub unsafe extern "C" fn wasmer_vm_raise_trap(trap_code: TrapCode) -> ! { } /// Implementation for throwing an exception. +/// +/// # Safety +/// +/// Calls libunwind to perform unwinding magic. #[no_mangle] pub unsafe extern "C-unwind" fn wasmer_vm_throw(tag: u64, data_ptr: usize, data_size: u64) -> ! { //println!("Throwing exception with tag {tag}"); @@ -678,11 +682,15 @@ pub unsafe extern "C-unwind" fn wasmer_vm_throw(tag: u64, data_ptr: usize, data_ c => { dbg!(c); unreachable!() - }, + } } } /// Implementation for throwing an exception. +/// +/// # Safety +/// +/// Calls libunwind to perform unwinding magic. #[no_mangle] pub unsafe extern "C-unwind" fn wasmer_vm_rethrow(exc: *mut UwExceptionWrapper) -> ! { if exc.is_null() { @@ -709,33 +717,49 @@ pub unsafe extern "C-unwind" fn wasmer_vm_rethrow(exc: *mut UwExceptionWrapper) /// (debug) Print an usize. #[no_mangle] -pub unsafe extern "C-unwind" fn wasmer_vm_dbg_usize(value: usize) { - println!("wasmer_vm_dbg_usize: {value}"); +pub extern "C-unwind" fn wasmer_vm_dbg_usize(value: usize) { + #[allow(clippy::print_stdout)] + { + println!("wasmer_vm_dbg_usize: {value}"); + } } /// Implementation for allocating an exception. #[no_mangle] -pub unsafe extern "C-unwind" fn wasmer_vm_alloc_exception(size: usize) -> u64 { +pub extern "C-unwind" fn wasmer_vm_alloc_exception(size: usize) -> u64 { Vec::::with_capacity(size).leak().as_ptr() as usize as u64 } /// Implementation for deleting the data of an exception. +/// +/// # Safety +/// +/// `exception` must be dereferenceable. #[no_mangle] pub unsafe extern "C-unwind" fn wasmer_vm_delete_exception(exception: *mut WasmerException) { - let size = (*exception).data_size as usize; - let data = Vec::::from_raw_parts((*exception).data_ptr as *mut u8, size, size); - std::mem::drop(data); + if !exception.is_null() { + let size = (*exception).data_size as usize; + let data = Vec::::from_raw_parts((*exception).data_ptr as *mut u8, size, size); + std::mem::drop(data); + } } /// Implementation for reading a [`WasmerException`] from a [`UwExceptionWrapper`]. +/// # Safety +/// +/// `exception` must be dereferenceable. #[no_mangle] pub unsafe extern "C-unwind" fn wasmer_vm_read_exception( - exc: *const UwExceptionWrapper, + exception: *const UwExceptionWrapper, ) -> *const WasmerException { - if let Some(w) = (*exc).cause.downcast_ref() { - w as *const WasmerException + if !exception.is_null() { + if let Some(w) = (*exception).cause.downcast_ref() { + w as *const WasmerException + } else { + panic!() + } } else { - panic!() + std::ptr::null() } } diff --git a/lib/vm/src/libcalls/eh/dwarf/eh.rs b/lib/vm/src/libcalls/eh/dwarf/eh.rs index f11d55bf654..275c1bd41a8 100644 --- a/lib/vm/src/libcalls/eh/dwarf/eh.rs +++ b/lib/vm/src/libcalls/eh/dwarf/eh.rs @@ -1,5 +1,5 @@ //! Parsing of GCC-style Language-Specific Data Area (LSDA) -//! For details see: +//! For details se*const (): //! * //! * //! * @@ -10,10 +10,11 @@ //! (`/libgcc/unwind-c.c` as of this writing). #![allow(non_upper_case_globals)] +#![allow(clippy::transmutes_expressible_as_ptr_casts)] +#![allow(clippy::comparison_chain)] #![allow(unused)] use core::{mem, ptr}; -use std::u16; use crate::libcalls::eh::InnerException; @@ -194,7 +195,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>) -> Result } // Ip is not present in the table. This indicates a nounwind call. - return Ok(EHAction::Terminate); + Ok(EHAction::Terminate) } else { todo!() } @@ -298,14 +299,14 @@ unsafe fn read_encoded_pointer( let addr = round_up( { let this = reader.ptr; - unsafe { mem::transmute(this.cast::<()>()) } + unsafe { mem::transmute::<*const (), usize>(this.cast::<()>()) } }, mem::size_of::<*const u8>(), )?; // In the mean-time, this operation is defined to be "as if" it was // a wrapping_offset, so we can emulate it as such. This should properly // restore pointer provenance even under today's compiler. - let self_addr = unsafe { mem::transmute::<_, isize>(this.cast::<()>()) }; + let self_addr = unsafe { mem::transmute::<*const (), isize>(this.cast::<()>()) }; let dest_addr = addr as isize; let offset = dest_addr.wrapping_sub(self_addr); diff --git a/lib/vm/src/libcalls/eh/dwarf/mod.rs b/lib/vm/src/libcalls/eh/dwarf/mod.rs index d54f4b21e67..e2ef3a8b5d6 100644 --- a/lib/vm/src/libcalls/eh/dwarf/mod.rs +++ b/lib/vm/src/libcalls/eh/dwarf/mod.rs @@ -17,8 +17,8 @@ pub struct DwarfReader { } impl DwarfReader { - pub fn new(ptr: *const u8) -> DwarfReader { - DwarfReader { ptr } + pub fn new(ptr: *const u8) -> Self { + Self { ptr } } /// Read a type T and then bump the pointer by that amount. diff --git a/lib/vm/src/libcalls/eh/mod.rs b/lib/vm/src/libcalls/eh/mod.rs index 899320e98f9..e463e057a29 100644 --- a/lib/vm/src/libcalls/eh/mod.rs +++ b/lib/vm/src/libcalls/eh/mod.rs @@ -69,6 +69,11 @@ struct InnerException { } #[no_mangle] +/// The implementation of Wasmer's personality function. +/// +/// # Safety +/// +/// Performs libunwind unwinding magic. pub unsafe extern "C" fn wasmer_eh_personality( version: std::ffi::c_int, actions: uw::_Unwind_Action, diff --git a/tests/lib/wast/src/wast.rs b/tests/lib/wast/src/wast.rs index b16abf82fa7..075500a4a16 100644 --- a/tests/lib/wast/src/wast.rs +++ b/tests/lib/wast/src/wast.rs @@ -550,7 +550,7 @@ impl Wast { } fn assert_exception(&self, result: Result>) -> Result<()> { - if !result.is_err() { + if result.is_ok() { anyhow::bail!("Expected exception to be thrown, returned {result:?} instead"); } Ok(())