Use if let instead of match.
https://github.com/rust-lang-nursery/rust-clippy/wiki#single_match
This commit is contained in:
@@ -147,10 +147,9 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
|
||||
}
|
||||
None => {
|
||||
// branch_destination() doesn't detect jump_tables
|
||||
match data {
|
||||
// If jump table we declare all entries successor
|
||||
// TODO: not collect with vector?
|
||||
InstructionData::BranchTable { table, .. } => {
|
||||
if let InstructionData::BranchTable { table, .. } = data {
|
||||
// Unlike all other jumps/branches, jump tables are
|
||||
// capable of having the same successor appear
|
||||
// multiple times. Use a HashSet to deduplicate.
|
||||
@@ -167,9 +166,6 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short
|
||||
self.builder.declare_successor(dest_ebb, inst)
|
||||
}
|
||||
}
|
||||
// If not we do nothing
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,13 +169,9 @@ pub fn translate_function_body(
|
||||
let mut func = Function::new();
|
||||
let args_num: usize = sig.argument_types.len();
|
||||
func.signature = sig.clone();
|
||||
match exports {
|
||||
&None => (),
|
||||
&Some(ref exports) => {
|
||||
match exports.get(&function_index) {
|
||||
None => (),
|
||||
Some(name) => func.name = FunctionName::new(name.clone()),
|
||||
}
|
||||
if let Some(ref exports) = *exports {
|
||||
if let Some(name) = exports.get(&function_index) {
|
||||
func.name = FunctionName::new(name.clone());
|
||||
}
|
||||
}
|
||||
let mut func_imports = FunctionImports::new();
|
||||
@@ -359,12 +355,9 @@ fn translate_operator(
|
||||
***********************************************************************************/
|
||||
Operator::Block { ty } => {
|
||||
let next = builder.create_ebb();
|
||||
match type_to_type(&ty) {
|
||||
Ok(ty_cre) => {
|
||||
if let Ok(ty_cre) = type_to_type(&ty) {
|
||||
builder.append_ebb_arg(next, ty_cre);
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
control_stack.push(ControlStackFrame::Block {
|
||||
destination: next,
|
||||
return_values: translate_type(ty).unwrap(),
|
||||
@@ -375,12 +368,9 @@ fn translate_operator(
|
||||
Operator::Loop { ty } => {
|
||||
let loop_body = builder.create_ebb();
|
||||
let next = builder.create_ebb();
|
||||
match type_to_type(&ty) {
|
||||
Ok(ty_cre) => {
|
||||
if let Ok(ty_cre) = type_to_type(&ty) {
|
||||
builder.append_ebb_arg(next, ty_cre);
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
builder.ins().jump(loop_body, &[]);
|
||||
control_stack.push(ControlStackFrame::Loop {
|
||||
destination: next,
|
||||
@@ -401,12 +391,9 @@ fn translate_operator(
|
||||
// and we add nothing;
|
||||
// - either the If have an Else clause, in that case the destination of this jump
|
||||
// instruction will be changed later when we translate the Else operator.
|
||||
match type_to_type(&ty) {
|
||||
Ok(ty_cre) => {
|
||||
if let Ok(ty_cre) = type_to_type(&ty) {
|
||||
builder.append_ebb_arg(if_not, ty_cre);
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
control_stack.push(ControlStackFrame::If {
|
||||
destination: if_not,
|
||||
branch_inst: jump_inst,
|
||||
@@ -1320,14 +1307,12 @@ fn find_function_import(
|
||||
exports: &Option<HashMap<FunctionIndex, String>>,
|
||||
signatures: &[Signature],
|
||||
) -> FuncRef {
|
||||
match func_imports.functions.get(&index) {
|
||||
Some(local_index) => return *local_index,
|
||||
None => {}
|
||||
if let Some(local_index) = func_imports.functions.get(&index) {
|
||||
return *local_index;
|
||||
}
|
||||
// We have to import the function
|
||||
let sig_index = functions[index];
|
||||
match func_imports.signatures.get(&(sig_index as usize)) {
|
||||
Some(local_sig_index) => {
|
||||
if let Some(local_sig_index) = func_imports.signatures.get(&(sig_index as usize)) {
|
||||
let local_func_index = builder.import_function(ExtFuncData {
|
||||
name: match exports {
|
||||
&None => FunctionName::new(""),
|
||||
@@ -1343,8 +1328,6 @@ fn find_function_import(
|
||||
func_imports.functions.insert(index, local_func_index);
|
||||
return local_func_index;
|
||||
}
|
||||
None => {}
|
||||
};
|
||||
// We have to import the signature
|
||||
let sig_local_index = builder.import_signature(signatures[sig_index as usize].clone());
|
||||
func_imports.signatures.insert(
|
||||
@@ -1373,9 +1356,8 @@ fn find_signature_import(
|
||||
func_imports: &mut FunctionImports,
|
||||
signatures: &[Signature],
|
||||
) -> SigRef {
|
||||
match func_imports.signatures.get(&(sig_index as usize)) {
|
||||
Some(local_sig_index) => return *local_sig_index,
|
||||
None => {}
|
||||
if let Some(local_sig_index) = func_imports.signatures.get(&(sig_index as usize)) {
|
||||
return *local_sig_index;
|
||||
}
|
||||
let sig_local_index = builder.import_signature(signatures[sig_index as usize].clone());
|
||||
func_imports.signatures.insert(
|
||||
|
||||
Reference in New Issue
Block a user