Fix clippy warnings.

This commit fixes the current set of (stable) clippy warnings in the repo.
This commit is contained in:
Peter Huene
2019-10-23 23:15:42 -07:00
committed by Andrew Brown
parent 1176e4f178
commit 9f506692c2
93 changed files with 667 additions and 662 deletions

View File

@@ -30,7 +30,7 @@ pub enum Affinity {
impl Default for Affinity {
fn default() -> Self {
Affinity::Unassigned
Self::Unassigned
}
}
@@ -41,25 +41,25 @@ impl Affinity {
/// Use the `Default` implementation for that.
pub fn new(constraint: &OperandConstraint) -> Self {
if constraint.kind == ConstraintKind::Stack {
Affinity::Stack
Self::Stack
} else {
Affinity::Reg(constraint.regclass.into())
Self::Reg(constraint.regclass.into())
}
}
/// Create an affinity that matches an ABI argument for `isa`.
pub fn abi(arg: &AbiParam, isa: &dyn TargetIsa) -> Self {
match arg.location {
ArgumentLoc::Unassigned => Affinity::Unassigned,
ArgumentLoc::Reg(_) => Affinity::Reg(isa.regclass_for_abi_type(arg.value_type).into()),
ArgumentLoc::Stack(_) => Affinity::Stack,
ArgumentLoc::Unassigned => Self::Unassigned,
ArgumentLoc::Reg(_) => Self::Reg(isa.regclass_for_abi_type(arg.value_type).into()),
ArgumentLoc::Stack(_) => Self::Stack,
}
}
/// Is this the `Unassigned` affinity?
pub fn is_unassigned(self) -> bool {
match self {
Affinity::Unassigned => true,
Self::Unassigned => true,
_ => false,
}
}
@@ -67,7 +67,7 @@ impl Affinity {
/// Is this the `Reg` affinity?
pub fn is_reg(self) -> bool {
match self {
Affinity::Reg(_) => true,
Self::Reg(_) => true,
_ => false,
}
}
@@ -75,7 +75,7 @@ impl Affinity {
/// Is this the `Stack` affinity?
pub fn is_stack(self) -> bool {
match self {
Affinity::Stack => true,
Self::Stack => true,
_ => false,
}
}
@@ -86,8 +86,8 @@ impl Affinity {
/// satisfies the constraint.
pub fn merge(&mut self, constraint: &OperandConstraint, reginfo: &RegInfo) {
match *self {
Affinity::Unassigned => *self = Self::new(constraint),
Affinity::Reg(rc) => {
Self::Unassigned => *self = Self::new(constraint),
Self::Reg(rc) => {
// If the preferred register class is a subclass of the constraint, there's no need
// to change anything.
if constraint.kind != ConstraintKind::Stack && !constraint.regclass.has_subclass(rc)
@@ -96,11 +96,11 @@ impl Affinity {
// we just keep our previous affinity.
if let Some(subclass) = constraint.regclass.intersect_index(reginfo.rc(rc)) {
// This constraint shrinks our preferred register class.
*self = Affinity::Reg(subclass);
*self = Self::Reg(subclass);
}
}
}
Affinity::Stack => {}
Self::Stack => {}
}
}

View File

@@ -96,7 +96,7 @@ impl<'a> Context<'a> {
let dfg = &mut self.cur.func.dfg;
let old_args: Vec<_> = {
let args = dfg[branch].take_value_list().expect("ebb parameters");
args.as_slice(&dfg.value_lists).iter().map(|x| *x).collect()
args.as_slice(&dfg.value_lists).iter().copied().collect()
};
let (branch_args, ebb_params) = old_args.split_at(num_fixed);
@@ -159,16 +159,13 @@ impl<'a> Context<'a> {
/// Returns whether we should introduce a new branch.
fn should_split_edge(&self, target: Ebb) -> bool {
// We should split the edge if the target has any parameters.
if self.cur.func.dfg.ebb_params(target).len() > 0 {
if !self.cur.func.dfg.ebb_params(target).is_empty() {
return true;
};
// Or, if the target has more than one block reaching it.
debug_assert!(self.cfg.pred_iter(target).next() != None);
if let Some(_) = self.cfg.pred_iter(target).skip(1).next() {
return true;
};
false
self.cfg.pred_iter(target).nth(1).is_some()
}
}

View File

@@ -551,7 +551,7 @@ impl<'a> Context<'a> {
let is_reload = match &self.cur.func.dfg[inst] {
InstructionData::Unary {
opcode: Opcode::Fill,
arg: _,
..
} => true,
_ => false,
};

View File

@@ -200,7 +200,7 @@ impl RegDiversions {
}
debug_assert!(!entry_diversions.map.contains_key(target));
let iter = self.current.iter();
let mut entry_divert = RegDiversions::new();
let mut entry_divert = Self::new();
entry_divert.current.extend(iter);
entry_diversions.map.insert(EntryRegDiversionsValue {
key: target,
@@ -225,7 +225,7 @@ impl RegDiversions {
return false;
}
}
return true;
true
}
/// Return an object that can display the diversions.
@@ -237,7 +237,7 @@ impl RegDiversions {
impl EntryRegDiversions {
/// Create a new empty entry diversion, to associate diversions to each EBB entry.
pub fn new() -> Self {
EntryRegDiversions {
Self {
map: SparseMap::new(),
}
}

View File

@@ -259,9 +259,9 @@ impl UFEntry {
/// Decode a table entry.
fn decode(x: i32) -> Self {
if x < 0 {
UFEntry::Link(Value::from_u32((!x) as u32))
Self::Link(Value::from_u32((!x) as u32))
} else {
UFEntry::Rank(x as u32)
Self::Rank(x as u32)
}
}