Avoid matching with reference patterns.

https://github.com/rust-lang-nursery/rust-clippy/wiki#match_ref_pats
This commit is contained in:
Dan Gohman
2017-08-31 11:59:26 -07:00
parent 5a8d1a9fda
commit 9726bb7367
6 changed files with 54 additions and 54 deletions

View File

@@ -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()),

View File

@@ -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()),

View File

@@ -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(()) => (),