mirror of
https://github.com/openharmony/third_party_rust_ryu.git
synced 2026-07-18 17:14:35 -04:00
Resolve unnecessary_cast clippy lint
error: casting to the same type is unnecessary (`u32` -> `u32`)
--> src/pretty/mantissa.rs:46:17
|
46 | let c = (output - 10_000 * (output / 10_000)) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(output - 10_000 * (output / 10_000))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
= note: `-D clippy::unnecessary-cast` implied by `-D clippy::all`
error: casting to the same type is unnecessary (`u32` -> `u32`)
--> src/pretty/mantissa.rs:63:17
|
63 | let c = ((output % 100) << 1) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `((output % 100) << 1)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
error: casting to the same type is unnecessary (`u32` -> `u32`)
--> src/pretty/mantissa.rs:73:17
|
73 | let c = (output << 1) as u32;
| ^^^^^^^^^^^^^^^^^^^^ help: try: `(output << 1)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
error: casting to the same type is unnecessary (`u32` -> `u32`)
--> src/pretty/mod.rs:164:9
|
164 | ((bits >> FLOAT_MANTISSA_BITS) & ((1u32 << FLOAT_EXPONENT_BITS) - 1)) as u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `((bits >> FLOAT_MANTISSA_BITS) & ((1u32 << FLOAT_EXPONENT_BITS) - 1))`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
error: casting to the same type is unnecessary (`u32` -> `u32`)
--> src/s2f.rs:223:68
|
223 | let ieee = ((((signed_m as u32) << f2s::FLOAT_EXPONENT_BITS) | ieee_e2 as u32)
| ^^^^^^^^^^^^^^ help: try: `ieee_e2`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
= note: `-D clippy::unnecessary-cast` implied by `-D clippy::all`
This commit is contained in:
@@ -43,7 +43,7 @@ pub unsafe fn write_mantissa_long(mut output: u64, mut result: *mut u8) {
|
||||
#[cfg_attr(feature = "no-panic", inline)]
|
||||
pub unsafe fn write_mantissa(mut output: u32, mut result: *mut u8) {
|
||||
while output >= 10_000 {
|
||||
let c = (output - 10_000 * (output / 10_000)) as u32;
|
||||
let c = output - 10_000 * (output / 10_000);
|
||||
output /= 10_000;
|
||||
let c0 = (c % 100) << 1;
|
||||
let c1 = (c / 100) << 1;
|
||||
@@ -60,7 +60,7 @@ pub unsafe fn write_mantissa(mut output: u32, mut result: *mut u8) {
|
||||
result = result.offset(-4);
|
||||
}
|
||||
if output >= 100 {
|
||||
let c = ((output % 100) << 1) as u32;
|
||||
let c = (output % 100) << 1;
|
||||
output /= 100;
|
||||
ptr::copy_nonoverlapping(
|
||||
DIGIT_TABLE.as_ptr().offset(c as isize),
|
||||
@@ -70,7 +70,7 @@ pub unsafe fn write_mantissa(mut output: u32, mut result: *mut u8) {
|
||||
result = result.offset(-2);
|
||||
}
|
||||
if output >= 10 {
|
||||
let c = (output << 1) as u32;
|
||||
let c = output << 1;
|
||||
ptr::copy_nonoverlapping(
|
||||
DIGIT_TABLE.as_ptr().offset(c as isize),
|
||||
result.offset(-2),
|
||||
|
||||
+1
-2
@@ -160,8 +160,7 @@ pub unsafe fn format32(f: f32, result: *mut u8) -> usize {
|
||||
let bits = f.to_bits();
|
||||
let sign = ((bits >> (FLOAT_MANTISSA_BITS + FLOAT_EXPONENT_BITS)) & 1) != 0;
|
||||
let ieee_mantissa = bits & ((1u32 << FLOAT_MANTISSA_BITS) - 1);
|
||||
let ieee_exponent =
|
||||
((bits >> FLOAT_MANTISSA_BITS) & ((1u32 << FLOAT_EXPONENT_BITS) - 1)) as u32;
|
||||
let ieee_exponent = (bits >> FLOAT_MANTISSA_BITS) & ((1u32 << FLOAT_EXPONENT_BITS) - 1);
|
||||
|
||||
let mut index = 0isize;
|
||||
if sign {
|
||||
|
||||
+1
-1
@@ -220,7 +220,7 @@ pub fn s2f(buffer: &[u8]) -> Result<f32, Error> {
|
||||
// for overflow here.
|
||||
ieee_e2 += 1;
|
||||
}
|
||||
let ieee = ((((signed_m as u32) << f2s::FLOAT_EXPONENT_BITS) | ieee_e2 as u32)
|
||||
let ieee = ((((signed_m as u32) << f2s::FLOAT_EXPONENT_BITS) | ieee_e2)
|
||||
<< f2s::FLOAT_MANTISSA_BITS)
|
||||
| ieee_m2;
|
||||
Ok(f32::from_bits(ieee))
|
||||
|
||||
Reference in New Issue
Block a user