Skip to content

Commit

Permalink
Ignore cast_precision_loss pedantic clippy lint
Browse files Browse the repository at this point in the history
    warning: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
       --> serde/src/de/impls.rs:197:16
        |
    197 |               Ok(v as Self::Value)
        |                  ^^^^^^^^^^^^^^^^
    ...
    457 | / impl_deserialize_num! {
    458 | |     f32, deserialize_f32
    459 | |     num_self!(f32:visit_f32);
    460 | |     num_as_copysign_self!(f64:visit_f64);
    461 | |     num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
    462 | |     num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
    463 | | }
        | |_- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
        = note: `-W clippy::cast-precision-loss` implied by `-W clippy::pedantic`
        = help: to override `-W clippy::pedantic` add `#[allow(clippy::cast_precision_loss)]`
        = note: this warning originates in the macro `num_as_self` which comes from the expansion of the macro `impl_deserialize_num` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: casting `i64` to `f32` causes a loss of precision (`i64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
       --> serde/src/de/impls.rs:197:16
        |
    197 |               Ok(v as Self::Value)
        |                  ^^^^^^^^^^^^^^^^
    ...
    457 | / impl_deserialize_num! {
    458 | |     f32, deserialize_f32
    459 | |     num_self!(f32:visit_f32);
    460 | |     num_as_copysign_self!(f64:visit_f64);
    461 | |     num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
    462 | |     num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
    463 | | }
        | |_- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
        = note: this warning originates in the macro `num_as_self` which comes from the expansion of the macro `impl_deserialize_num` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: casting `u32` to `f32` causes a loss of precision (`u32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
       --> serde/src/de/impls.rs:197:16
        |
    197 |               Ok(v as Self::Value)
        |                  ^^^^^^^^^^^^^^^^
    ...
    457 | / impl_deserialize_num! {
    458 | |     f32, deserialize_f32
    459 | |     num_self!(f32:visit_f32);
    460 | |     num_as_copysign_self!(f64:visit_f64);
    461 | |     num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
    462 | |     num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
    463 | | }
        | |_- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
        = note: this warning originates in the macro `num_as_self` which comes from the expansion of the macro `impl_deserialize_num` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: casting `u64` to `f32` causes a loss of precision (`u64` is 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
       --> serde/src/de/impls.rs:197:16
        |
    197 |               Ok(v as Self::Value)
        |                  ^^^^^^^^^^^^^^^^
    ...
    457 | / impl_deserialize_num! {
    458 | |     f32, deserialize_f32
    459 | |     num_self!(f32:visit_f32);
    460 | |     num_as_copysign_self!(f64:visit_f64);
    461 | |     num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
    462 | |     num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
    463 | | }
        | |_- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
        = note: this warning originates in the macro `num_as_self` which comes from the expansion of the macro `impl_deserialize_num` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: casting `i64` to `f64` causes a loss of precision (`i64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
       --> serde/src/de/impls.rs:197:16
        |
    197 |               Ok(v as Self::Value)
        |                  ^^^^^^^^^^^^^^^^
    ...
    465 | / impl_deserialize_num! {
    466 | |     f64, deserialize_f64
    467 | |     num_self!(f64:visit_f64);
    468 | |     num_as_copysign_self!(f32:visit_f32);
    469 | |     num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
    470 | |     num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
    471 | | }
        | |_- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
        = note: this warning originates in the macro `num_as_self` which comes from the expansion of the macro `impl_deserialize_num` (in Nightly builds, run with -Z macro-backtrace for more info)

    warning: casting `u64` to `f64` causes a loss of precision (`u64` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
       --> serde/src/de/impls.rs:197:16
        |
    197 |               Ok(v as Self::Value)
        |                  ^^^^^^^^^^^^^^^^
    ...
    465 | / impl_deserialize_num! {
    466 | |     f64, deserialize_f64
    467 | |     num_self!(f64:visit_f64);
    468 | |     num_as_copysign_self!(f32:visit_f32);
    469 | |     num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
    470 | |     num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
    471 | | }
        | |_- in this macro invocation
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_precision_loss
        = note: this warning originates in the macro `num_as_self` which comes from the expansion of the macro `impl_deserialize_num` (in Nightly builds, run with -Z macro-backtrace for more info)
  • Loading branch information
dtolnay committed Apr 20, 2024
1 parent c4fb923 commit f6623a3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions serde/src/lib.rs
Expand Up @@ -118,6 +118,7 @@
// integer and float ser/de requires these sorts of casts
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast_sign_loss,
// things are often more readable this way
clippy::cast_lossless,
Expand Down

0 comments on commit f6623a3

Please sign in to comment.