From f6623a36548cfce02f880a33c6d2f420934c95c5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 19 Apr 2024 20:57:34 -0700 Subject: [PATCH] Ignore cast_precision_loss pedantic clippy lint 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) --- serde/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/serde/src/lib.rs b/serde/src/lib.rs index fefbf8fda..f92210620 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -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,