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