Fix clippy::cast_losless
This commit is contained in:
parent
12806b7050
commit
6c93b47c01
5 changed files with 13 additions and 13 deletions
|
@ -39,8 +39,8 @@ impl Fingerprint {
|
|||
// you want.
|
||||
#[inline]
|
||||
pub fn combine_commutative(self, other: Fingerprint) -> Fingerprint {
|
||||
let a = (self.1 as u128) << 64 | self.0 as u128;
|
||||
let b = (other.1 as u128) << 64 | other.0 as u128;
|
||||
let a = u128::from(self.1) << 64 | u128::from(self.0);
|
||||
let b = u128::from(other.1) << 64 | u128::from(other.0);
|
||||
|
||||
let c = a.wrapping_add(b);
|
||||
|
||||
|
|
|
@ -70,15 +70,15 @@ unsafe fn u8to64_le(buf: &[u8], start: usize, len: usize) -> u64 {
|
|||
let mut i = 0; // current byte index (from LSB) in the output u64
|
||||
let mut out = 0;
|
||||
if i + 3 < len {
|
||||
out = load_int_le!(buf, start + i, u32) as u64;
|
||||
out = u64::from(load_int_le!(buf, start + i, u32));
|
||||
i += 4;
|
||||
}
|
||||
if i + 1 < len {
|
||||
out |= (load_int_le!(buf, start + i, u16) as u64) << (i * 8);
|
||||
out |= u64::from(load_int_le!(buf, start + i, u16)) << (i * 8);
|
||||
i += 2
|
||||
}
|
||||
if i < len {
|
||||
out |= (*buf.get_unchecked(start + i) as u64) << (i * 8);
|
||||
out |= u64::from(*buf.get_unchecked(start + i)) << (i * 8);
|
||||
i += 1;
|
||||
}
|
||||
debug_assert_eq!(i, len);
|
||||
|
|
|
@ -44,7 +44,7 @@ impl<W: StableHasherResult> StableHasher<W> {
|
|||
impl StableHasherResult for u128 {
|
||||
fn finish(hasher: StableHasher<Self>) -> Self {
|
||||
let (_0, _1) = hasher.finalize();
|
||||
(_0 as u128) | ((_1 as u128) << 64)
|
||||
u128::from(_0) | (u128::from(_1) << 64)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -513,7 +513,7 @@ impl<'a> crate::Encoder for Encoder<'a> {
|
|||
emit_enquoted_if_mapkey!(self, fmt_number_or_null(v))
|
||||
}
|
||||
fn emit_f32(&mut self, v: f32) -> EncodeResult {
|
||||
self.emit_f64(v as f64)
|
||||
self.emit_f64(f64::from(v))
|
||||
}
|
||||
|
||||
fn emit_char(&mut self, v: char) -> EncodeResult {
|
||||
|
@ -763,7 +763,7 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> {
|
|||
emit_enquoted_if_mapkey!(self, fmt_number_or_null(v))
|
||||
}
|
||||
fn emit_f32(&mut self, v: f32) -> EncodeResult {
|
||||
self.emit_f64(v as f64)
|
||||
self.emit_f64(f64::from(v))
|
||||
}
|
||||
|
||||
fn emit_char(&mut self, v: char) -> EncodeResult {
|
||||
|
@ -1698,12 +1698,12 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
|||
if n2 < 0xDC00 || n2 > 0xDFFF {
|
||||
return self.error(LoneLeadingSurrogateInHexEscape)
|
||||
}
|
||||
let c = (((n1 - 0xD800) as u32) << 10 |
|
||||
(n2 - 0xDC00) as u32) + 0x1_0000;
|
||||
let c = (u32::from(n1 - 0xD800) << 10 |
|
||||
u32::from(n2 - 0xDC00)) + 0x1_0000;
|
||||
res.push(char::from_u32(c).unwrap());
|
||||
}
|
||||
|
||||
n => match char::from_u32(n as u32) {
|
||||
n => match char::from_u32(u32::from(n)) {
|
||||
Some(c) => res.push(c),
|
||||
None => return self.error(InvalidUnicodeCodePoint),
|
||||
},
|
||||
|
@ -2405,7 +2405,7 @@ impl ToJson for Json {
|
|||
}
|
||||
|
||||
impl ToJson for f32 {
|
||||
fn to_json(&self) -> Json { (*self as f64).to_json() }
|
||||
fn to_json(&self) -> Json { f64::from(*self).to_json() }
|
||||
}
|
||||
|
||||
impl ToJson for f64 {
|
||||
|
|
|
@ -123,7 +123,7 @@ pub fn read_signed_leb128(data: &[u8], start_position: usize) -> (i128, usize) {
|
|||
loop {
|
||||
byte = data[position];
|
||||
position += 1;
|
||||
result |= ((byte & 0x7F) as i128) << shift;
|
||||
result |= i128::from(byte & 0x7F) << shift;
|
||||
shift += 7;
|
||||
|
||||
if (byte & 0x80) == 0 {
|
||||
|
|
Loading…
Add table
Reference in a new issue