diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 641fe2a89d..e1cc270c60 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -197,7 +197,7 @@ impl<'a> Context<'a> { } // Resolve a reference to a signature. - fn check_sig(&self, sig: SigRef, loc: &Location) -> ParseResult<()> { + fn check_sig(&self, sig: SigRef, loc: Location) -> ParseResult<()> { if !self.map.contains_sig(sig) { err!(loc, "undefined signature {}", sig) } else { @@ -1246,7 +1246,7 @@ impl<'a> Parser<'a> { } Some(sig) => sig, }; - ctx.check_sig(sig, &self.loc)?; + ctx.check_sig(sig, self.loc)?; self.consume(); ExtFuncData { name, @@ -2096,7 +2096,7 @@ impl<'a> Parser<'a> { } InstructionFormat::CallIndirect => { let sig_ref = self.match_sig("expected signature reference")?; - ctx.check_sig(sig_ref, &self.loc)?; + ctx.check_sig(sig_ref, self.loc)?; self.match_token(Token::Comma, "expected ',' between operands")?; let callee = self.match_value("expected SSA value callee operand")?; self.match_token(Token::LPar, "expected '(' before arguments")?; diff --git a/lib/wasm/src/code_translator.rs b/lib/wasm/src/code_translator.rs index e6018a11bb..dc9be39fa5 100644 --- a/lib/wasm/src/code_translator.rs +++ b/lib/wasm/src/code_translator.rs @@ -129,7 +129,7 @@ pub fn translate_operator( ***********************************************************************************/ Operator::Block { ty } => { let next = builder.create_ebb(); - if let Ok(ty_cre) = type_to_type(&ty) { + if let Ok(ty_cre) = type_to_type(ty) { builder.append_ebb_param(next, ty_cre); } state.push_block(next, num_return_values(ty)); @@ -137,7 +137,7 @@ pub fn translate_operator( Operator::Loop { ty } => { let loop_body = builder.create_ebb(); let next = builder.create_ebb(); - if let Ok(ty_cre) = type_to_type(&ty) { + if let Ok(ty_cre) = type_to_type(ty) { builder.append_ebb_param(next, ty_cre); } builder.ins().jump(loop_body, &[]); @@ -155,7 +155,7 @@ pub 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. - if let Ok(ty_cre) = type_to_type(&ty) { + if let Ok(ty_cre) = type_to_type(ty) { builder.append_ebb_param(if_not, ty_cre); } state.push_if(jump_inst, if_not, num_return_values(ty)); diff --git a/lib/wasm/src/sections_translator.rs b/lib/wasm/src/sections_translator.rs index 0c47a3e940..c21dbb0c25 100644 --- a/lib/wasm/src/sections_translator.rs +++ b/lib/wasm/src/sections_translator.rs @@ -36,12 +36,12 @@ pub fn parse_function_signatures( }) => { let mut sig = Signature::new(environ.flags().call_conv()); sig.params.extend(params.iter().map(|ty| { - let cret_arg: ir::Type = type_to_type(ty) + let cret_arg: ir::Type = type_to_type(*ty) .expect("only numeric types are supported in function signatures"); AbiParam::new(cret_arg) })); sig.returns.extend(returns.iter().map(|ty| { - let cret_arg: ir::Type = type_to_type(ty) + let cret_arg: ir::Type = type_to_type(*ty) .expect("only numeric types are supported in function signatures"); AbiParam::new(cret_arg) })); @@ -92,7 +92,7 @@ pub fn parse_import_section<'data>( .. } => { environ.declare_global(Global { - ty: type_to_type(&ty.content_type).unwrap(), + ty: type_to_type(ty.content_type).unwrap(), mutability: ty.mutable, initializer: GlobalInit::Import(), }); @@ -101,7 +101,7 @@ pub fn parse_import_section<'data>( ty: ImportSectionEntryType::Table(ref tab), .. } => environ.declare_table(Table { - ty: match type_to_type(&tab.element_type) { + ty: match type_to_type(tab.element_type) { Ok(t) => TableElementType::Val(t), Err(()) => TableElementType::Func(), }, @@ -245,7 +245,7 @@ pub fn parse_global_section( ref s => panic!("unexpected section content: {:?}", s), } let global = Global { - ty: type_to_type(&content_type).unwrap(), + ty: type_to_type(content_type).unwrap(), mutability, initializer, }; @@ -329,7 +329,7 @@ pub fn parse_table_section(parser: &mut Parser, environ: &mut ModuleEnvironment) loop { match *parser.read() { ParserState::TableSectionEntry(ref table) => environ.declare_table(Table { - ty: match type_to_type(&table.element_type) { + ty: match type_to_type(table.element_type) { Ok(t) => TableElementType::Val(t), Err(()) => TableElementType::Func(), }, diff --git a/lib/wasm/src/translation_utils.rs b/lib/wasm/src/translation_utils.rs index 3ed13899e6..16b5737b80 100644 --- a/lib/wasm/src/translation_utils.rs +++ b/lib/wasm/src/translation_utils.rs @@ -72,8 +72,8 @@ pub struct Memory { } /// Helper function translating wasmparser types to Cretonne types when possible. -pub fn type_to_type(ty: &wasmparser::Type) -> Result { - match *ty { +pub fn type_to_type(ty: wasmparser::Type) -> Result { + match ty { wasmparser::Type::I32 => Ok(ir::types::I32), wasmparser::Type::I64 => Ok(ir::types::I64), wasmparser::Type::F32 => Ok(ir::types::F32),