diff --git a/lib/environ/src/lib.rs b/lib/environ/src/lib.rs index 72f0bebbb5..bd7d17c836 100644 --- a/lib/environ/src/lib.rs +++ b/lib/environ/src/lib.rs @@ -14,14 +14,14 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - print_stdout, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::print_stdout, + clippy::unicode_not_nfc, + clippy::use_self ) )] #![cfg_attr(not(feature = "std"), no_std)] diff --git a/lib/environ/src/vmoffsets.rs b/lib/environ/src/vmoffsets.rs index 16884c834b..18c0e644ab 100644 --- a/lib/environ/src/vmoffsets.rs +++ b/lib/environ/src/vmoffsets.rs @@ -17,11 +17,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMMemoryDefinition`. impl VMOffsets { /// The offset of the `base` field. + #[allow(clippy::erasing_op)] pub fn vmmemory_definition_base(&self) -> u8 { 0 * self.pointer_size } /// The offset of the `current_length` field. + #[allow(clippy::identity_op)] pub fn vmmemory_definition_current_length(&self) -> u8 { 1 * self.pointer_size } @@ -35,11 +37,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMMemoryImport`. impl VMOffsets { /// The offset of the `from` field. + #[allow(clippy::erasing_op)] pub fn vmmemory_import_from(&self) -> u8 { 0 * self.pointer_size } /// Return the size of `VMMemoryImport`. + #[allow(clippy::identity_op)] pub fn size_of_vmmemory_import(&self) -> u8 { 1 * self.pointer_size } @@ -64,11 +68,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMGlobalImport`. impl VMOffsets { /// The offset of the `from` field. + #[allow(clippy::erasing_op)] pub fn vmglobal_import_from(&self) -> u8 { 0 * self.pointer_size } /// Return the size of `VMGlobalImport`. + #[allow(clippy::identity_op)] pub fn size_of_vmglobal_import(&self) -> u8 { 1 * self.pointer_size } @@ -86,11 +92,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMTableDefinition`. impl VMOffsets { /// The offset of the `base` field. + #[allow(clippy::erasing_op)] pub fn vmtable_definition_base(&self) -> u8 { 0 * self.pointer_size } /// The offset of the `current_elements` field. + #[allow(clippy::identity_op)] pub fn vmtable_definition_current_elements(&self) -> u8 { 1 * self.pointer_size } @@ -104,11 +112,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMTableImport`. impl VMOffsets { /// The offset of the `from` field. + #[allow(clippy::erasing_op)] pub fn vmtable_import_from(&self) -> u8 { 0 * self.pointer_size } /// Return the size of `VMTableImport`. + #[allow(clippy::identity_op)] pub fn size_of_vmtable_import(&self) -> u8 { 1 * self.pointer_size } @@ -133,11 +143,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMCallerCheckedAnyfunc`. impl VMOffsets { /// The offset of the `func_ptr` field. + #[allow(clippy::erasing_op)] pub fn vmcaller_checked_anyfunc_func_ptr(&self) -> u8 { 0 * self.pointer_size } /// The offset of the `type_id` field. + #[allow(clippy::identity_op)] pub fn vmcaller_checked_anyfunc_type_id(&self) -> u8 { 1 * self.pointer_size } @@ -151,11 +163,13 @@ impl VMOffsets { /// Offsets for `wasmtime_execute::VMContext`. impl VMOffsets { /// The offset of the `memories` field. + #[allow(clippy::erasing_op)] pub fn vmctx_memories(&self) -> u8 { 0 * self.pointer_size } /// The offset of the `globals` field. + #[allow(clippy::identity_op)] pub fn vmctx_globals(&self) -> u8 { 1 * self.pointer_size } diff --git a/lib/execute/src/instance.rs b/lib/execute/src/instance.rs index 5d6e86b5d7..958287eb4a 100644 --- a/lib/execute/src/instance.rs +++ b/lib/execute/src/instance.rs @@ -89,7 +89,7 @@ impl Instance { /// Return the offset from the vmctx pointer to its containing Instance. pub fn vmctx_offset() -> isize { - offset_of!(Instance, vmctx) as isize + offset_of!(Self, vmctx) as isize } /// Grow memory by the specified amount of pages. @@ -173,7 +173,7 @@ fn instantiate_tables( for init in &module.table_elements { debug_assert!(init.base.is_none(), "globalvar base not supported yet"); - let slice = &mut tables[init.table_index].as_mut(); + let slice = tables[init.table_index].as_mut(); let subslice = &mut slice[init.offset..init.offset + init.elements.len()]; for (i, func_idx) in init.elements.iter().enumerate() { let callee_sig = module.functions[*func_idx]; diff --git a/lib/execute/src/lib.rs b/lib/execute/src/lib.rs index 3e6c62393b..394aa02358 100644 --- a/lib/execute/src/lib.rs +++ b/lib/execute/src/lib.rs @@ -11,14 +11,14 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - print_stdout, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::print_stdout, + clippy::unicode_not_nfc, + clippy::use_self ) )] #![cfg_attr(not(feature = "std"), no_std)] diff --git a/lib/execute/src/libcalls.rs b/lib/execute/src/libcalls.rs index 8d38337b79..08f7c4e78c 100644 --- a/lib/execute/src/libcalls.rs +++ b/lib/execute/src/libcalls.rs @@ -14,6 +14,7 @@ pub extern "C" fn wasmtime_f32_trunc(x: f32) -> f32 { x.trunc() } +#[allow(clippy::float_arithmetic, clippy::float_cmp)] pub extern "C" fn wasmtime_f32_nearest(x: f32) -> f32 { // Rust doesn't have a nearest function, so do it manually. if x == 0.0 { @@ -50,6 +51,7 @@ pub extern "C" fn wasmtime_f64_trunc(x: f64) -> f64 { x.trunc() } +#[allow(clippy::float_arithmetic, clippy::float_cmp)] pub extern "C" fn wasmtime_f64_nearest(x: f64) -> f64 { // Rust doesn't have a nearest function, so do it manually. if x == 0.0 { diff --git a/lib/execute/src/vmcontext.rs b/lib/execute/src/vmcontext.rs index 58350f9aea..ec985af9b5 100644 --- a/lib/execute/src/vmcontext.rs +++ b/lib/execute/src/vmcontext.rs @@ -174,26 +174,32 @@ mod test_vmglobal_definition { } impl VMGlobalDefinition { + #[allow(cast_ptr_alignment)] pub unsafe fn as_i32(&mut self) -> &mut i32 { &mut *(self.storage.as_mut().as_mut_ptr() as *mut u8 as *mut i32) } + #[allow(cast_ptr_alignment)] pub unsafe fn as_i64(&mut self) -> &mut i64 { &mut *(self.storage.as_mut().as_mut_ptr() as *mut u8 as *mut i64) } + #[allow(cast_ptr_alignment)] pub unsafe fn as_f32(&mut self) -> &mut f32 { &mut *(self.storage.as_mut().as_mut_ptr() as *mut u8 as *mut f32) } + #[allow(cast_ptr_alignment)] pub unsafe fn as_f32_bits(&mut self) -> &mut u32 { &mut *(self.storage.as_mut().as_mut_ptr() as *mut u8 as *mut u32) } + #[allow(cast_ptr_alignment)] pub unsafe fn as_f64(&mut self) -> &mut f64 { &mut *(self.storage.as_mut().as_mut_ptr() as *mut u8 as *mut f64) } + #[allow(cast_ptr_alignment)] pub unsafe fn as_f64_bits(&mut self) -> &mut u64 { &mut *(self.storage.as_mut().as_mut_ptr() as *mut u8 as *mut u64) } @@ -572,8 +578,8 @@ impl VMContext { } /// Return a mutable reference to the associated `Instance`. + #[allow(cast_ptr_alignment)] pub unsafe fn instance(&mut self) -> &mut Instance { - &mut *((self as *mut VMContext as *mut u8).offset(-Instance::vmctx_offset()) - as *mut Instance) + &mut *((self as *mut Self as *mut u8).offset(-Instance::vmctx_offset()) as *mut Instance) } } diff --git a/lib/obj/src/lib.rs b/lib/obj/src/lib.rs index 0af2d9bfc8..e06fb7a73a 100644 --- a/lib/obj/src/lib.rs +++ b/lib/obj/src/lib.rs @@ -15,14 +15,14 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - print_stdout, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::print_stdout, + clippy::unicode_not_nfc, + clippy::use_self ) )] diff --git a/lib/wast/src/lib.rs b/lib/wast/src/lib.rs index 5064a55368..ca4d3d3c3a 100644 --- a/lib/wast/src/lib.rs +++ b/lib/wast/src/lib.rs @@ -11,14 +11,14 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - print_stdout, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::print_stdout, + clippy::unicode_not_nfc, + clippy::use_self ) )] diff --git a/src/run_wast.rs b/src/run_wast.rs index 879ec303e5..63520186b9 100644 --- a/src/run_wast.rs +++ b/src/run_wast.rs @@ -15,13 +15,13 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::unicode_not_nfc, + clippy::use_self ) )] diff --git a/src/wasm2obj.rs b/src/wasm2obj.rs index de7558a7d8..dab26c404a 100644 --- a/src/wasm2obj.rs +++ b/src/wasm2obj.rs @@ -19,13 +19,13 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::unicode_not_nfc, + clippy::use_self ) )] diff --git a/src/wasmtime.rs b/src/wasmtime.rs index 1280a83b85..b1c6d4ce1e 100644 --- a/src/wasmtime.rs +++ b/src/wasmtime.rs @@ -20,13 +20,13 @@ #![cfg_attr( feature = "cargo-clippy", warn( - float_arithmetic, - mut_mut, - nonminimal_bool, - option_map_unwrap_or, - option_map_unwrap_or_else, - unicode_not_nfc, - use_self + clippy::float_arithmetic, + clippy::mut_mut, + clippy::nonminimal_bool, + clippy::option_map_unwrap_or, + clippy::option_map_unwrap_or_else, + clippy::unicode_not_nfc, + clippy::use_self ) )]