[clippy] Pass more types by value;
wasmparser::Type is an enum, and there was one Location I missed.
This commit is contained in:
committed by
Dan Gohman
parent
bea843519c
commit
25508ac66e
@@ -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")?;
|
||||
|
||||
@@ -129,7 +129,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
||||
***********************************************************************************/
|
||||
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<FE: FuncEnvironment + ?Sized>(
|
||||
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<FE: FuncEnvironment + ?Sized>(
|
||||
// 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));
|
||||
|
||||
@@ -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(),
|
||||
},
|
||||
|
||||
@@ -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<ir::Type, ()> {
|
||||
match *ty {
|
||||
pub fn type_to_type(ty: wasmparser::Type) -> Result<ir::Type, ()> {
|
||||
match ty {
|
||||
wasmparser::Type::I32 => Ok(ir::types::I32),
|
||||
wasmparser::Type::I64 => Ok(ir::types::I64),
|
||||
wasmparser::Type::F32 => Ok(ir::types::F32),
|
||||
|
||||
Reference in New Issue
Block a user