diff --git a/lib/frontend/src/frontend.rs b/lib/frontend/src/frontend.rs index 20c660a1f0..008610f62e 100644 --- a/lib/frontend/src/frontend.rs +++ b/lib/frontend/src/frontend.rs @@ -147,15 +147,14 @@ 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. - let mut unique = HashSet::new(); - for dest_ebb in self.builder + let mut unique = HashSet::new(); + for dest_ebb in self.builder .func .jump_tables .get(table) @@ -166,9 +165,6 @@ impl<'short, 'long, Variable> InstBuilderBase<'short> for FuncInstBuilder<'short .collect::>() { self.builder.declare_successor(dest_ebb, inst) } - } -// If not we do nothing - _ => {} } } } diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index a4ad9f7445..8fb90aa179 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -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,11 +355,8 @@ fn translate_operator( ***********************************************************************************/ Operator::Block { ty } => { let next = builder.create_ebb(); - match type_to_type(&ty) { - Ok(ty_cre) => { - builder.append_ebb_arg(next, ty_cre); - } - Err(_) => {} + if let Ok(ty_cre) = type_to_type(&ty) { + builder.append_ebb_arg(next, ty_cre); } control_stack.push(ControlStackFrame::Block { destination: next, @@ -375,11 +368,8 @@ 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) => { - builder.append_ebb_arg(next, ty_cre); - } - Err(_) => {} + if let Ok(ty_cre) = type_to_type(&ty) { + builder.append_ebb_arg(next, ty_cre); } builder.ins().jump(loop_body, &[]); control_stack.push(ControlStackFrame::Loop { @@ -401,11 +391,8 @@ 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) => { - builder.append_ebb_arg(if_not, ty_cre); - } - Err(_) => {} + if let Ok(ty_cre) = type_to_type(&ty) { + builder.append_ebb_arg(if_not, ty_cre); } control_stack.push(ControlStackFrame::If { destination: if_not, @@ -1320,31 +1307,27 @@ fn find_function_import( exports: &Option>, 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) => { - let local_func_index = builder.import_function(ExtFuncData { - name: match exports { - &None => FunctionName::new(""), - &Some(ref exports) => { - match exports.get(&index) { - None => FunctionName::new(""), - Some(name) => FunctionName::new(name.clone()), - } + 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(""), + &Some(ref exports) => { + match exports.get(&index) { + None => FunctionName::new(""), + Some(name) => FunctionName::new(name.clone()), } - }, - signature: *local_sig_index, - }); - func_imports.functions.insert(index, local_func_index); - return local_func_index; - } - None => {} - }; + } + }, + signature: *local_sig_index, + }); + func_imports.functions.insert(index, local_func_index); + return local_func_index; + } // 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(