Various clippy fixes. (#403)

This commit is contained in:
Dan Gohman
2019-10-09 13:32:52 -07:00
committed by GitHub
parent 9465668199
commit fd3efad781
25 changed files with 144 additions and 160 deletions

View File

@@ -56,7 +56,7 @@ impl Export {
vmctx: *mut VMContext,
signature: ir::Signature,
) -> Self {
Export::Function {
Self::Function {
address,
vmctx,
signature,
@@ -69,7 +69,7 @@ impl Export {
vmctx: *mut VMContext,
table: TablePlan,
) -> Self {
Export::Table {
Self::Table {
definition,
vmctx,
table,
@@ -82,7 +82,7 @@ impl Export {
vmctx: *mut VMContext,
memory: MemoryPlan,
) -> Self {
Export::Memory {
Self::Memory {
definition,
vmctx,
memory,
@@ -95,7 +95,7 @@ impl Export {
vmctx: *mut VMContext,
global: Global,
) -> Self {
Export::Global {
Self::Global {
definition,
vmctx,
global,

View File

@@ -475,8 +475,8 @@ impl Instance {
} else if let Some(start_export) = self.module.exports.get("_start") {
// As a compatibility measure, if the module doesn't have a start
// function but does have a _start function exported, call that.
match start_export {
&wasmtime_environ::Export::Function(func_index) => {
match *start_export {
wasmtime_environ::Export::Function(func_index) => {
let sig = &self.module.signatures[self.module.functions[func_index]];
// No wasm params or returns; just the vmctx param.
if sig.params.len() == 1 && sig.returns.is_empty() {
@@ -491,8 +491,8 @@ impl Instance {
// As a further compatibility measure, if the module doesn't have a
// start function or a _start function exported, but does have a main
// function exported, call that.
match main_export {
&wasmtime_environ::Export::Function(func_index) => {
match *main_export {
wasmtime_environ::Export::Function(func_index) => {
let sig = &self.module.signatures[self.module.functions[func_index]];
// No wasm params or returns; just the vmctx param.
if sig.params.len() == 1 && sig.returns.is_empty() {

View File

@@ -53,8 +53,8 @@ pub struct GdbJitImageRegistration {
impl GdbJitImageRegistration {
/// Registers JIT image using __jit_debug_register_code
pub fn register(file: Vec<u8>) -> GdbJitImageRegistration {
GdbJitImageRegistration {
pub fn register(file: Vec<u8>) -> Self {
Self {
entry: unsafe { register_gdb_jit_image(&file) },
file,
}
@@ -83,7 +83,7 @@ unsafe fn register_gdb_jit_image(file: &[u8]) -> *mut JITCodeEntry {
symfile_size: file.len() as u64,
}));
// Add it to the linked list in the JIT descriptor.
if __jit_debug_descriptor.first_entry != ptr::null_mut() {
if !__jit_debug_descriptor.first_entry.is_null() {
(*__jit_debug_descriptor.first_entry).prev_entry = entry;
}
__jit_debug_descriptor.first_entry = entry;
@@ -100,12 +100,12 @@ unsafe fn register_gdb_jit_image(file: &[u8]) -> *mut JITCodeEntry {
unsafe fn unregister_gdb_jit_image(entry: *mut JITCodeEntry) {
// Remove the code entry corresponding to the code from the linked list.
if (*entry).prev_entry != ptr::null_mut() {
if !(*entry).prev_entry.is_null() {
(*(*entry).prev_entry).next_entry = (*entry).next_entry;
} else {
__jit_debug_descriptor.first_entry = (*entry).next_entry;
}
if (*entry).next_entry != ptr::null_mut() {
if !(*entry).next_entry.is_null() {
(*(*entry).next_entry).prev_entry = (*entry).prev_entry;
}
// Point the relevant_entry field of the descriptor at the code entry.

View File

@@ -24,13 +24,12 @@ impl Table {
unimplemented!("tables of types other than anyfunc ({})", ty)
}
};
assert!(
plan.table.minimum <= core::u32::MAX,
"Invariant check: vec.len() <= u32::MAX"
);
match plan.style {
TableStyle::CallerChecksSignature => Self {
vec: vec![VMCallerCheckedAnyfunc::default(); plan.table.minimum as usize],
vec: vec![
VMCallerCheckedAnyfunc::default();
usize::try_from(plan.table.minimum).unwrap()
],
maximum: plan.table.maximum,
},
}
@@ -59,10 +58,6 @@ impl Table {
return None;
}
};
assert!(
new_len <= core::u32::MAX,
"Invariant check: vec.len() <= u32::MAX"
);
self.vec.resize(
usize::try_from(new_len).unwrap(),
VMCallerCheckedAnyfunc::default(),

View File

@@ -450,13 +450,13 @@ mod test_vmshared_signature_index {
impl VMSharedSignatureIndex {
/// Create a new `VMSharedSignatureIndex`.
pub fn new(value: u32) -> Self {
VMSharedSignatureIndex(value)
Self(value)
}
}
impl Default for VMSharedSignatureIndex {
fn default() -> Self {
VMSharedSignatureIndex::new(u32::MAX)
Self::new(u32::MAX)
}
}
@@ -573,7 +573,7 @@ mod test_vm_invoke_argument {
impl VMInvokeArgument {
/// Create a new invocation argument filled with zeroes
pub fn new() -> Self {
VMInvokeArgument([0; 16])
Self([0; 16])
}
}