Avoid unnecessary '&' in matches.

https://github.com/rust-lang-nursery/rust-clippy/wiki#match_ref_pats
This commit is contained in:
Dan Gohman
2017-08-31 11:46:05 -07:00
parent acf4f1009b
commit 9a8f01b832
4 changed files with 16 additions and 16 deletions

View File

@@ -10,8 +10,8 @@ use ir::{self, InstBuilder};
/// Expand a `global_addr` instruction according to the definition of the global variable. /// Expand a `global_addr` instruction according to the definition of the global variable.
pub fn expand_global_addr(inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph) { pub fn expand_global_addr(inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph) {
// Unpack the instruction. // Unpack the instruction.
let gv = match &func.dfg[inst] { let gv = match func.dfg[inst] {
&ir::InstructionData::UnaryGlobalVar { opcode, global_var } => { ir::InstructionData::UnaryGlobalVar { opcode, global_var } => {
assert_eq!(opcode, ir::Opcode::GlobalAddr); assert_eq!(opcode, ir::Opcode::GlobalAddr);
global_var global_var
} }

View File

@@ -11,8 +11,8 @@ use ir::condcodes::IntCC;
/// Expand a `heap_addr` instruction according to the definition of the heap. /// Expand a `heap_addr` instruction according to the definition of the heap.
pub fn expand_heap_addr(inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph) { pub fn expand_heap_addr(inst: ir::Inst, func: &mut ir::Function, _cfg: &mut ControlFlowGraph) {
// Unpack the instruction. // Unpack the instruction.
let (heap, offset, size) = match &func.dfg[inst] { let (heap, offset, size) = match func.dfg[inst] {
&ir::InstructionData::HeapAddr { ir::InstructionData::HeapAddr {
opcode, opcode,
heap, heap,
arg, arg,

View File

@@ -169,7 +169,7 @@ impl<'a> Verifier<'a> {
seen.insert(gv); seen.insert(gv);
let mut cur = gv; let mut cur = gv;
while let &ir::GlobalVarData::Deref { base, .. } = &self.func.global_vars[cur] { while let ir::GlobalVarData::Deref { base, .. } = self.func.global_vars[cur] {
if seen.insert(base).is_some() { if seen.insert(base).is_some() {
return err!(gv, "deref cycle: {}", DisplayList(seen.as_slice())); return err!(gv, "deref cycle: {}", DisplayList(seen.as_slice()));
} }

View File

@@ -420,8 +420,8 @@ fn translate_operator(
// and push a new control frame with a new ebb for the code after the if/then/else // and push a new control frame with a new ebb for the code after the if/then/else
// At the end of the then clause we jump to the destination // At the end of the then clause we jump to the destination
let i = control_stack.len() - 1; let i = control_stack.len() - 1;
let (destination, return_values, branch_inst) = match &control_stack[i] { let (destination, return_values, branch_inst) = match control_stack[i] {
&ControlStackFrame::If { ControlStackFrame::If {
destination, destination,
ref return_values, ref return_values,
branch_inst, branch_inst,
@@ -1276,15 +1276,15 @@ fn translate_unreachable_operator(
} else { } else {
// Encountering an real else means that the code in the else // Encountering an real else means that the code in the else
// clause is reachable again // clause is reachable again
let (branch_inst, original_stack_size) = let (branch_inst, original_stack_size) = match control_stack[control_stack.len() -
match &control_stack[control_stack.len() - 1] { 1] {
&ControlStackFrame::If { ControlStackFrame::If {
branch_inst, branch_inst,
original_stack_size, original_stack_size,
.. ..
} => (branch_inst, original_stack_size), } => (branch_inst, original_stack_size),
_ => panic!("should not happen"), _ => panic!("should not happen"),
}; };
// We change the target of the branch instruction // We change the target of the branch instruction
let else_ebb = builder.create_ebb(); let else_ebb = builder.create_ebb();
builder.change_jump_destination(branch_inst, else_ebb); builder.change_jump_destination(branch_inst, else_ebb);