Fix all clippy warnings (#564)
* Fix all clippy warnings * Revert usage of inclusive ranges * Remove redundant function argument * Revert use of unavailable pointer methods * Introduce ContiguousCaseRange
This commit is contained in:
committed by
Dan Gohman
parent
586a8835e9
commit
b288c6001a
@@ -161,8 +161,8 @@ pub enum LaneType {
|
||||
|
||||
impl LaneType {
|
||||
/// Return a string containing the documentation comment for this lane type.
|
||||
pub fn doc(&self) -> String {
|
||||
match *self {
|
||||
pub fn doc(self) -> String {
|
||||
match self {
|
||||
LaneType::BoolType(_) => format!("A boolean type with {} bits.", self.lane_bits()),
|
||||
LaneType::FloatType(base_types::Float::F32) => String::from(
|
||||
"A 32-bit floating point type represented in the IEEE 754-2008
|
||||
@@ -185,8 +185,8 @@ impl LaneType {
|
||||
}
|
||||
|
||||
/// Return the number of bits in a lane.
|
||||
pub fn lane_bits(&self) -> u64 {
|
||||
match *self {
|
||||
pub fn lane_bits(self) -> u64 {
|
||||
match self {
|
||||
LaneType::BoolType(ref b) => *b as u64,
|
||||
LaneType::FloatType(ref f) => *f as u64,
|
||||
LaneType::IntType(ref i) => *i as u64,
|
||||
@@ -194,8 +194,8 @@ impl LaneType {
|
||||
}
|
||||
|
||||
/// Get the name of this lane type.
|
||||
pub fn name(&self) -> String {
|
||||
match *self {
|
||||
pub fn name(self) -> String {
|
||||
match self {
|
||||
LaneType::BoolType(_) => format!("b{}", self.lane_bits()),
|
||||
LaneType::FloatType(_) => format!("f{}", self.lane_bits()),
|
||||
LaneType::IntType(_) => format!("i{}", self.lane_bits()),
|
||||
@@ -203,8 +203,8 @@ impl LaneType {
|
||||
}
|
||||
|
||||
/// Find the unique number associated with this lane type.
|
||||
pub fn number(&self) -> u8 {
|
||||
LANE_BASE + match *self {
|
||||
pub fn number(self) -> u8 {
|
||||
LANE_BASE + match self {
|
||||
LaneType::BoolType(base_types::Bool::B1) => 0,
|
||||
LaneType::BoolType(base_types::Bool::B8) => 1,
|
||||
LaneType::BoolType(base_types::Bool::B16) => 2,
|
||||
@@ -394,8 +394,8 @@ pub enum SpecialType {
|
||||
|
||||
impl SpecialType {
|
||||
/// Return a string containing the documentation comment for this special type.
|
||||
pub fn doc(&self) -> String {
|
||||
match *self {
|
||||
pub fn doc(self) -> String {
|
||||
match self {
|
||||
SpecialType::Flag(base_types::Flag::IFlags) => String::from(
|
||||
"CPU flags representing the result of an integer comparison. These flags
|
||||
can be tested with an :type:`intcc` condition code.",
|
||||
@@ -408,23 +408,23 @@ impl SpecialType {
|
||||
}
|
||||
|
||||
/// Return the number of bits in a lane.
|
||||
pub fn lane_bits(&self) -> u64 {
|
||||
match *self {
|
||||
pub fn lane_bits(self) -> u64 {
|
||||
match self {
|
||||
SpecialType::Flag(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the name of this special type.
|
||||
pub fn name(&self) -> String {
|
||||
match *self {
|
||||
pub fn name(self) -> String {
|
||||
match self {
|
||||
SpecialType::Flag(base_types::Flag::IFlags) => "iflags".to_string(),
|
||||
SpecialType::Flag(base_types::Flag::FFlags) => "fflags".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Find the unique number associated with this special type.
|
||||
pub fn number(&self) -> u8 {
|
||||
match *self {
|
||||
pub fn number(self) -> u8 {
|
||||
match self {
|
||||
SpecialType::Flag(base_types::Flag::IFlags) => 1,
|
||||
SpecialType::Flag(base_types::Flag::FFlags) => 2,
|
||||
}
|
||||
|
||||
@@ -47,8 +47,7 @@ fn emit_vectors(bits: u64, fmt: &mut srcgen::Formatter) -> Result<(), error::Err
|
||||
/// Emit types using the given formatter object.
|
||||
fn emit_types(fmt: &mut srcgen::Formatter) -> Result<(), error::Error> {
|
||||
// Emit all of the special types, such as types for CPU flags.
|
||||
for spec in cdsl_types::ValueType::all_special_types().map(|ty| cdsl_types::ValueType::from(ty))
|
||||
{
|
||||
for spec in cdsl_types::ValueType::all_special_types().map(cdsl_types::ValueType::from) {
|
||||
emit_type(&spec, fmt)?;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ fn maybe_resolve_aliases(values: &PrimaryMap<Value, ValueData>, value: Value) ->
|
||||
let mut v = value;
|
||||
|
||||
// Note that values may be empty here.
|
||||
for _ in 0..1 + values.len() {
|
||||
for _ in 0..values.len() + 1 {
|
||||
if let ValueData::Alias { original, .. } = values[v] {
|
||||
v = original;
|
||||
} else {
|
||||
@@ -174,8 +174,7 @@ impl<'a> Iterator for Values<'a> {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.inner
|
||||
.by_ref()
|
||||
.filter(|kv| valid_valuedata(kv.1))
|
||||
.next()
|
||||
.find(|kv| valid_valuedata(kv.1))
|
||||
.map(|kv| kv.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,19 +178,14 @@ impl Function {
|
||||
///
|
||||
/// This function can only be used after the code layout has been computed by the
|
||||
/// `binemit::relax_branches()` function.
|
||||
pub fn inst_offsets<'a>(
|
||||
&'a self,
|
||||
func: &'a Function,
|
||||
ebb: Ebb,
|
||||
encinfo: &EncInfo,
|
||||
) -> InstOffsetIter<'a> {
|
||||
pub fn inst_offsets<'a>(&'a self, ebb: Ebb, encinfo: &EncInfo) -> InstOffsetIter<'a> {
|
||||
assert!(
|
||||
!self.offsets.is_empty(),
|
||||
"Code layout must be computed first"
|
||||
);
|
||||
InstOffsetIter {
|
||||
encinfo: encinfo.clone(),
|
||||
func,
|
||||
func: self,
|
||||
divert: RegDiversions::new(),
|
||||
encodings: &self.encodings,
|
||||
offset: self.offsets[ebb],
|
||||
|
||||
@@ -85,7 +85,7 @@ type SizeCalculatorFn = fn(&RecipeSizing, Inst, &RegDiversions, &Function) -> u8
|
||||
/// Returns the base size of the Recipe, assuming it's fixed. This is the default for most
|
||||
/// encodings; others can be variable and longer than this base size, depending on the registers
|
||||
/// they're using and use a different function, specific per platform.
|
||||
pub fn base_size(sizing: &RecipeSizing, _: Inst, _2: &RegDiversions, _3: &Function) -> u8 {
|
||||
pub fn base_size(sizing: &RecipeSizing, _: Inst, _: &RegDiversions, _: &Function) -> u8 {
|
||||
sizing.base_size
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ pub fn pretty_verifier_error<'a>(
|
||||
let mut w = String::new();
|
||||
|
||||
decorate_function(
|
||||
&mut PrettyVerifierError(func_w.unwrap_or(Box::new(PlainWriter)), &mut errors),
|
||||
&mut PrettyVerifierError(func_w.unwrap_or_else(|| Box::new(PlainWriter)), &mut errors),
|
||||
&mut w,
|
||||
func,
|
||||
isa,
|
||||
|
||||
@@ -234,7 +234,8 @@ pub fn verify_function<'a, FOI: Into<FlagsOrIsa<'a>>>(
|
||||
let verifier = Verifier::new(func, fisa.into());
|
||||
let result = verifier.run(&mut errors);
|
||||
if errors.is_empty() {
|
||||
Ok(result.unwrap())
|
||||
result.unwrap();
|
||||
Ok(())
|
||||
} else {
|
||||
Err(errors)
|
||||
}
|
||||
@@ -392,30 +393,22 @@ impl<'a> Verifier<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
match heap_data.style {
|
||||
ir::HeapStyle::Dynamic { bound_gv, .. } => {
|
||||
if !self.func.global_values.is_valid(bound_gv) {
|
||||
return nonfatal!(
|
||||
errors,
|
||||
heap,
|
||||
"invalid bound global value {}",
|
||||
bound_gv
|
||||
);
|
||||
}
|
||||
|
||||
let index_type = heap_data.index_type;
|
||||
let bound_type = self.func.global_values[bound_gv].global_type(isa);
|
||||
if index_type != bound_type {
|
||||
report!(
|
||||
errors,
|
||||
heap,
|
||||
"heap index type {} differs from the type of its bound, {}",
|
||||
index_type,
|
||||
bound_type
|
||||
);
|
||||
}
|
||||
if let ir::HeapStyle::Dynamic { bound_gv, .. } = heap_data.style {
|
||||
if !self.func.global_values.is_valid(bound_gv) {
|
||||
return nonfatal!(errors, heap, "invalid bound global value {}", bound_gv);
|
||||
}
|
||||
|
||||
let index_type = heap_data.index_type;
|
||||
let bound_type = self.func.global_values[bound_gv].global_type(isa);
|
||||
if index_type != bound_type {
|
||||
report!(
|
||||
errors,
|
||||
heap,
|
||||
"heap index type {} differs from the type of its bound, {}",
|
||||
index_type,
|
||||
bound_type
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user