Fix clippy warnings.
This commit fixes the current set of (stable) clippy warnings in the repo.
This commit is contained in:
committed by
Andrew Brown
parent
1176e4f178
commit
9f506692c2
@@ -50,12 +50,12 @@ pub struct Imm64(i64);
|
||||
impl Imm64 {
|
||||
/// Create a new `Imm64` representing the signed number `x`.
|
||||
pub fn new(x: i64) -> Self {
|
||||
Imm64(x)
|
||||
Self(x)
|
||||
}
|
||||
|
||||
/// Return self negated.
|
||||
pub fn wrapping_neg(self) -> Self {
|
||||
Imm64(self.0.wrapping_neg())
|
||||
Self(self.0.wrapping_neg())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ impl IntoBytes for Imm64 {
|
||||
|
||||
impl From<i64> for Imm64 {
|
||||
fn from(x: i64) -> Self {
|
||||
Imm64(x)
|
||||
Self(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ pub struct Uimm64(u64);
|
||||
impl Uimm64 {
|
||||
/// Create a new `Uimm64` representing the unsigned number `x`.
|
||||
pub fn new(x: u64) -> Self {
|
||||
Uimm64(x)
|
||||
Self(x)
|
||||
}
|
||||
|
||||
/// Return self negated.
|
||||
pub fn wrapping_neg(self) -> Self {
|
||||
Uimm64(self.0.wrapping_neg())
|
||||
Self(self.0.wrapping_neg())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ impl Into<u64> for Uimm64 {
|
||||
|
||||
impl From<u64> for Uimm64 {
|
||||
fn from(x: u64) -> Self {
|
||||
Uimm64(x)
|
||||
Self(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ impl Into<i64> for Uimm32 {
|
||||
|
||||
impl From<u32> for Uimm32 {
|
||||
fn from(x: u32) -> Self {
|
||||
Uimm32(x)
|
||||
Self(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ impl FromStr for Uimm32 {
|
||||
fn from_str(s: &str) -> Result<Self, &'static str> {
|
||||
parse_i64(s).and_then(|x| {
|
||||
if 0 <= x && x <= i64::from(u32::MAX) {
|
||||
Ok(Uimm32(x as u32))
|
||||
Ok(Self(x as u32))
|
||||
} else {
|
||||
Err("Uimm32 out of range")
|
||||
}
|
||||
@@ -329,7 +329,7 @@ impl From<&[u8]> for V128Imm {
|
||||
assert_eq!(slice.len(), 16);
|
||||
let mut buffer = [0; 16];
|
||||
buffer.copy_from_slice(slice);
|
||||
V128Imm(buffer)
|
||||
Self(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ pub struct Offset32(i32);
|
||||
impl Offset32 {
|
||||
/// Create a new `Offset32` representing the signed number `x`.
|
||||
pub fn new(x: i32) -> Self {
|
||||
Offset32(x)
|
||||
Self(x)
|
||||
}
|
||||
|
||||
/// Create a new `Offset32` representing the signed number `x` if possible.
|
||||
@@ -381,7 +381,7 @@ impl Into<i64> for Offset32 {
|
||||
|
||||
impl From<i32> for Offset32 {
|
||||
fn from(x: i32) -> Self {
|
||||
Offset32(x)
|
||||
Self(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ fn parse_float(s: &str, w: u8, t: u8) -> Result<u64, &'static str> {
|
||||
impl Ieee32 {
|
||||
/// Create a new `Ieee32` containing the bits of `x`.
|
||||
pub fn with_bits(x: u32) -> Self {
|
||||
Ieee32(x)
|
||||
Self(x)
|
||||
}
|
||||
|
||||
/// Create an `Ieee32` number representing `2.0^n`.
|
||||
@@ -688,7 +688,7 @@ impl Ieee32 {
|
||||
let exponent = (n + bias) as u32;
|
||||
assert!(exponent > 0, "Underflow n={}", n);
|
||||
assert!(exponent < (1 << w) + 1, "Overflow n={}", n);
|
||||
Ieee32(exponent << t)
|
||||
Self(exponent << t)
|
||||
}
|
||||
|
||||
/// Create an `Ieee32` number representing the greatest negative value
|
||||
@@ -702,12 +702,12 @@ impl Ieee32 {
|
||||
|
||||
/// Return self negated.
|
||||
pub fn neg(self) -> Self {
|
||||
Ieee32(self.0 ^ (1 << 31))
|
||||
Self(self.0 ^ (1 << 31))
|
||||
}
|
||||
|
||||
/// Create a new `Ieee32` representing the number `x`.
|
||||
pub fn with_float(x: f32) -> Self {
|
||||
Ieee32(x.to_bits())
|
||||
Self(x.to_bits())
|
||||
}
|
||||
|
||||
/// Get the bitwise representation.
|
||||
@@ -728,7 +728,7 @@ impl FromStr for Ieee32 {
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, &'static str> {
|
||||
match parse_float(s, 8, 23) {
|
||||
Ok(b) => Ok(Ieee32(b as u32)),
|
||||
Ok(b) => Ok(Self(b as u32)),
|
||||
Err(s) => Err(s),
|
||||
}
|
||||
}
|
||||
@@ -736,7 +736,7 @@ impl FromStr for Ieee32 {
|
||||
|
||||
impl From<f32> for Ieee32 {
|
||||
fn from(x: f32) -> Self {
|
||||
Ieee32::with_float(x)
|
||||
Self::with_float(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -749,7 +749,7 @@ impl IntoBytes for Ieee32 {
|
||||
impl Ieee64 {
|
||||
/// Create a new `Ieee64` containing the bits of `x`.
|
||||
pub fn with_bits(x: u64) -> Self {
|
||||
Ieee64(x)
|
||||
Self(x)
|
||||
}
|
||||
|
||||
/// Create an `Ieee64` number representing `2.0^n`.
|
||||
@@ -761,7 +761,7 @@ impl Ieee64 {
|
||||
let exponent = (n + bias) as u64;
|
||||
assert!(exponent > 0, "Underflow n={}", n);
|
||||
assert!(exponent < (1 << w) + 1, "Overflow n={}", n);
|
||||
Ieee64(exponent << t)
|
||||
Self(exponent << t)
|
||||
}
|
||||
|
||||
/// Create an `Ieee64` number representing the greatest negative value
|
||||
@@ -775,12 +775,12 @@ impl Ieee64 {
|
||||
|
||||
/// Return self negated.
|
||||
pub fn neg(self) -> Self {
|
||||
Ieee64(self.0 ^ (1 << 63))
|
||||
Self(self.0 ^ (1 << 63))
|
||||
}
|
||||
|
||||
/// Create a new `Ieee64` representing the number `x`.
|
||||
pub fn with_float(x: f64) -> Self {
|
||||
Ieee64(x.to_bits())
|
||||
Self(x.to_bits())
|
||||
}
|
||||
|
||||
/// Get the bitwise representation.
|
||||
@@ -801,7 +801,7 @@ impl FromStr for Ieee64 {
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, &'static str> {
|
||||
match parse_float(s, 11, 52) {
|
||||
Ok(b) => Ok(Ieee64(b)),
|
||||
Ok(b) => Ok(Self(b)),
|
||||
Err(s) => Err(s),
|
||||
}
|
||||
}
|
||||
@@ -809,13 +809,13 @@ impl FromStr for Ieee64 {
|
||||
|
||||
impl From<f64> for Ieee64 {
|
||||
fn from(x: f64) -> Self {
|
||||
Ieee64::with_float(x)
|
||||
Self::with_float(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for Ieee64 {
|
||||
fn from(x: u64) -> Self {
|
||||
Ieee64::with_float(f64::from_bits(x))
|
||||
Self::with_float(f64::from_bits(x))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user