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

@@ -95,8 +95,8 @@ enum BlockData {
impl BlockData {
fn add_predecessor(&mut self, pred: Block, inst: Inst) {
match *self {
BlockData::EbbBody { .. } => panic!("you can't add a predecessor to a body block"),
BlockData::EbbHeader(ref mut data) => {
Self::EbbBody { .. } => panic!("you can't add a predecessor to a body block"),
Self::EbbHeader(ref mut data) => {
debug_assert!(!data.sealed, "sealed blocks cannot accept new predecessors");
data.predecessors.push(PredBlock::new(pred, inst));
}
@@ -104,8 +104,8 @@ impl BlockData {
}
fn remove_predecessor(&mut self, inst: Inst) -> Block {
match *self {
BlockData::EbbBody { .. } => panic!("should not happen"),
BlockData::EbbHeader(ref mut data) => {
Self::EbbBody { .. } => panic!("should not happen"),
Self::EbbHeader(ref mut data) => {
// This a linear complexity operation but the number of predecessors is low
// in all non-pathological cases
let pred: usize = data
@@ -149,7 +149,7 @@ pub struct Block(u32);
impl EntityRef for Block {
fn new(index: usize) -> Self {
debug_assert!(index < (u32::MAX as usize));
Block(index as u32)
Self(index as u32)
}
fn index(self) -> usize {
@@ -159,7 +159,7 @@ impl EntityRef for Block {
impl ReservedValue for Block {
fn reserved_value() -> Self {
Block(u32::MAX)
Self(u32::MAX)
}
}

View File

@@ -16,14 +16,14 @@ impl Variable {
/// Create a new Variable with the given index.
pub fn with_u32(index: u32) -> Self {
debug_assert!(index < u32::MAX);
Variable(index)
Self(index)
}
}
impl EntityRef for Variable {
fn new(index: usize) -> Self {
debug_assert!(index < (u32::MAX as usize));
Variable(index as u32)
Self(index as u32)
}
fn index(self) -> usize {