Avoid matching with reference patterns.
https://github.com/rust-lang-nursery/rust-clippy/wiki#match_ref_pats
This commit is contained in:
@@ -149,9 +149,9 @@ fn handle_module(
|
||||
vprint!(flag_verbose, "Checking... ");
|
||||
terminal.reset().unwrap();
|
||||
for func in translation.functions.iter() {
|
||||
let il = match func {
|
||||
&FunctionTranslation::Import() => continue,
|
||||
&FunctionTranslation::Code { ref il, .. } => il.clone(),
|
||||
let il = match *func {
|
||||
FunctionTranslation::Import() => continue,
|
||||
FunctionTranslation::Code { ref il, .. } => il.clone(),
|
||||
};
|
||||
match verifier::verify_function(&il, None) {
|
||||
Ok(()) => (),
|
||||
@@ -167,9 +167,9 @@ fn handle_module(
|
||||
vprint!(flag_verbose, "Optimizing... ");
|
||||
terminal.reset().unwrap();
|
||||
for func in translation.functions.iter() {
|
||||
let mut il = match func {
|
||||
&FunctionTranslation::Import() => continue,
|
||||
&FunctionTranslation::Code { ref il, .. } => il.clone(),
|
||||
let mut il = match *func {
|
||||
FunctionTranslation::Import() => continue,
|
||||
FunctionTranslation::Code { ref il, .. } => il.clone(),
|
||||
};
|
||||
let mut loop_analysis = LoopAnalysis::new();
|
||||
let mut cfg = ControlFlowGraph::new();
|
||||
|
||||
@@ -29,9 +29,9 @@ pub enum GlobalVarData {
|
||||
|
||||
impl fmt::Display for GlobalVarData {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
&GlobalVarData::VmCtx { offset } => write!(f, "vmctx{}", offset),
|
||||
&GlobalVarData::Deref { base, offset } => write!(f, "deref({}){}", base, offset),
|
||||
match *self {
|
||||
GlobalVarData::VmCtx { offset } => write!(f, "vmctx{}", offset),
|
||||
GlobalVarData::Deref { base, offset } => write!(f, "deref({}){}", base, offset),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,17 +78,17 @@ enum BlockData<Variable> {
|
||||
|
||||
impl<Variable> BlockData<Variable> {
|
||||
fn add_predecessor(&mut self, pred: Block, inst: Inst) {
|
||||
match self {
|
||||
&mut BlockData::EbbBody { .. } => panic!("you can't add a predecessor to a body block"),
|
||||
&mut BlockData::EbbHeader(ref mut data) => {
|
||||
match *self {
|
||||
BlockData::EbbBody { .. } => panic!("you can't add a predecessor to a body block"),
|
||||
BlockData::EbbHeader(ref mut data) => {
|
||||
data.predecessors.push((pred, inst));
|
||||
}
|
||||
}
|
||||
}
|
||||
fn remove_predecessor(&mut self, inst: Inst) -> Block {
|
||||
match self {
|
||||
&mut BlockData::EbbBody { .. } => panic!("should not happen"),
|
||||
&mut BlockData::EbbHeader(ref mut data) => {
|
||||
match *self {
|
||||
BlockData::EbbBody { .. } => panic!("should not happen"),
|
||||
BlockData::EbbHeader(ref mut data) => {
|
||||
// This a linear complexity operation but the number of predecessors is low
|
||||
// in all non-pathological cases
|
||||
let pred: usize =
|
||||
|
||||
@@ -72,54 +72,54 @@ enum ControlStackFrame {
|
||||
/// Helper methods for the control stack objects.
|
||||
impl ControlStackFrame {
|
||||
fn return_values(&self) -> &[Type] {
|
||||
match self {
|
||||
&ControlStackFrame::If { ref return_values, .. } |
|
||||
&ControlStackFrame::Block { ref return_values, .. } |
|
||||
&ControlStackFrame::Loop { ref return_values, .. } => return_values.as_slice(),
|
||||
match *self {
|
||||
ControlStackFrame::If { ref return_values, .. } |
|
||||
ControlStackFrame::Block { ref return_values, .. } |
|
||||
ControlStackFrame::Loop { ref return_values, .. } => return_values.as_slice(),
|
||||
}
|
||||
}
|
||||
fn following_code(&self) -> Ebb {
|
||||
match self {
|
||||
&ControlStackFrame::If { destination, .. } |
|
||||
&ControlStackFrame::Block { destination, .. } |
|
||||
&ControlStackFrame::Loop { destination, .. } => destination,
|
||||
match *self {
|
||||
ControlStackFrame::If { destination, .. } |
|
||||
ControlStackFrame::Block { destination, .. } |
|
||||
ControlStackFrame::Loop { destination, .. } => destination,
|
||||
}
|
||||
}
|
||||
fn br_destination(&self) -> Ebb {
|
||||
match self {
|
||||
&ControlStackFrame::If { destination, .. } |
|
||||
&ControlStackFrame::Block { destination, .. } => destination,
|
||||
&ControlStackFrame::Loop { header, .. } => header,
|
||||
match *self {
|
||||
ControlStackFrame::If { destination, .. } |
|
||||
ControlStackFrame::Block { destination, .. } => destination,
|
||||
ControlStackFrame::Loop { header, .. } => header,
|
||||
}
|
||||
}
|
||||
fn original_stack_size(&self) -> usize {
|
||||
match self {
|
||||
&ControlStackFrame::If { original_stack_size, .. } |
|
||||
&ControlStackFrame::Block { original_stack_size, .. } |
|
||||
&ControlStackFrame::Loop { original_stack_size, .. } => original_stack_size,
|
||||
match *self {
|
||||
ControlStackFrame::If { original_stack_size, .. } |
|
||||
ControlStackFrame::Block { original_stack_size, .. } |
|
||||
ControlStackFrame::Loop { original_stack_size, .. } => original_stack_size,
|
||||
}
|
||||
}
|
||||
fn is_loop(&self) -> bool {
|
||||
match self {
|
||||
&ControlStackFrame::If { .. } |
|
||||
&ControlStackFrame::Block { .. } => false,
|
||||
&ControlStackFrame::Loop { .. } => true,
|
||||
match *self {
|
||||
ControlStackFrame::If { .. } |
|
||||
ControlStackFrame::Block { .. } => false,
|
||||
ControlStackFrame::Loop { .. } => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_reachable(&self) -> bool {
|
||||
match self {
|
||||
&ControlStackFrame::If { reachable, .. } |
|
||||
&ControlStackFrame::Block { reachable, .. } |
|
||||
&ControlStackFrame::Loop { reachable, .. } => reachable,
|
||||
match *self {
|
||||
ControlStackFrame::If { reachable, .. } |
|
||||
ControlStackFrame::Block { reachable, .. } |
|
||||
ControlStackFrame::Loop { reachable, .. } => reachable,
|
||||
}
|
||||
}
|
||||
|
||||
fn set_reachable(&mut self) {
|
||||
match self {
|
||||
&mut ControlStackFrame::If { ref mut reachable, .. } |
|
||||
&mut ControlStackFrame::Block { ref mut reachable, .. } |
|
||||
&mut ControlStackFrame::Loop { ref mut reachable, .. } => *reachable = true,
|
||||
match *self {
|
||||
ControlStackFrame::If { ref mut reachable, .. } |
|
||||
ControlStackFrame::Block { ref mut reachable, .. } |
|
||||
ControlStackFrame::Loop { ref mut reachable, .. } => *reachable = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1314,9 +1314,9 @@ fn find_function_import(
|
||||
let sig_index = functions[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(""),
|
||||
&Some(ref exports) => {
|
||||
name: match *exports {
|
||||
None => FunctionName::new(""),
|
||||
Some(ref exports) => {
|
||||
match exports.get(&index) {
|
||||
None => FunctionName::new(""),
|
||||
Some(name) => FunctionName::new(name.clone()),
|
||||
@@ -1335,9 +1335,9 @@ fn find_function_import(
|
||||
sig_local_index,
|
||||
);
|
||||
let local_func_index = builder.import_function(ExtFuncData {
|
||||
name: match exports {
|
||||
&None => FunctionName::new(""),
|
||||
&Some(ref exports) => {
|
||||
name: match *exports {
|
||||
None => FunctionName::new(""),
|
||||
Some(ref exports) => {
|
||||
match exports.get(&index) {
|
||||
None => FunctionName::new(""),
|
||||
Some(name) => FunctionName::new(name.clone()),
|
||||
|
||||
@@ -132,8 +132,8 @@ pub fn parse_export_section(
|
||||
ref kind,
|
||||
index,
|
||||
} => {
|
||||
match kind {
|
||||
&ExternalKind::Function => {
|
||||
match *kind {
|
||||
ExternalKind::Function => {
|
||||
exports.insert(
|
||||
index as FunctionIndex,
|
||||
String::from(from_utf8(field).unwrap()),
|
||||
|
||||
@@ -70,9 +70,9 @@ fn handle_module(path: PathBuf) -> Result<(), String> {
|
||||
}
|
||||
};
|
||||
for func in translation.functions.iter() {
|
||||
let il = match func {
|
||||
&FunctionTranslation::Import() => continue,
|
||||
&FunctionTranslation::Code { ref il, .. } => il.clone(),
|
||||
let il = match *func {
|
||||
FunctionTranslation::Import() => continue,
|
||||
FunctionTranslation::Code { ref il, .. } => il.clone(),
|
||||
};
|
||||
match verifier::verify_function(&il, None) {
|
||||
Ok(()) => (),
|
||||
|
||||
Reference in New Issue
Block a user