Fix clippy warning namespaces.

This commit is contained in:
Dan Gohman
2018-12-06 02:59:39 -05:00
parent 06de604729
commit 08488591a9
11 changed files with 79 additions and 57 deletions

View File

@@ -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)]

View File

@@ -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
}

View File

@@ -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];

View File

@@ -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)]

View File

@@ -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 {

View File

@@ -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)
}
}

View File

@@ -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
)
)]

View File

@@ -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
)
)]

View File

@@ -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
)
)]

View File

@@ -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
)
)]

View File

@@ -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
)
)]