Skip to content

Commit

Permalink
MY clippy lints - there are a bunch of "transmute" lints that are sti…
Browse files Browse the repository at this point in the history
…ll reported.
  • Loading branch information
Martin Bartlett authored and Licenser committed Oct 22, 2024
1 parent fd0dda8 commit c994bdf
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ impl<'de> Deserializer<'de> {
#[allow(clippy::cast_possible_wrap, clippy::cast_precision_loss)]
fn parse_double(&mut self) -> Result<f64> {
match unsafe { self.next_() } {
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Node::Static(StaticNode::F64(n)) => Ok(n.into()),
Node::Static(StaticNode::I64(n)) => Ok(n as f64),
Node::Static(StaticNode::U64(n)) => Ok(n as f64),
Expand Down Expand Up @@ -384,6 +385,7 @@ impl TryInto<serde_json::Value> for OwnedValue {
.into(),
),
Self::Static(StaticNode::F64(n)) => {
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
if let Some(n) = serde_json::Number::from_f64(n.into()) {
Value::Number(n)
} else {
Expand Down Expand Up @@ -450,6 +452,7 @@ impl<'value> TryInto<serde_json::Value> for BorrowedValue<'value> {
.into(),
),
BorrowedValue::Static(StaticNode::F64(n)) => {
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
if let Some(n) = serde_json::Number::from_f64(n.into()) {
Value::Number(n)
} else {
Expand Down
1 change: 1 addition & 0 deletions src/serde/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ where
Node::String(s) => visitor.visit_borrowed_str(s),
Node::Static(StaticNode::Null) => visitor.visit_unit(),
Node::Static(StaticNode::Bool(b)) => visitor.visit_bool(b),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Node::Static(StaticNode::F64(n)) => visitor.visit_f64(n.into()),
Node::Static(StaticNode::I64(n)) => visitor.visit_i64(n),
#[cfg(feature = "128bit")]
Expand Down
2 changes: 2 additions & 0 deletions src/serde/value/borrowed/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl<'de> de::Deserializer<'de> for Value<'de> {
Value::Static(StaticNode::U64(n)) => visitor.visit_u64(n),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(n)) => visitor.visit_u128(n),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(n)) => visitor.visit_f64(n.into()),
#[cfg(feature = "beef")]
Value::String(s) => {
Expand Down Expand Up @@ -621,6 +622,7 @@ impl<'de> de::Deserializer<'de> for &'de Value<'de> {
Value::Static(StaticNode::U64(n)) => visitor.visit_u64(*n),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(n)) => visitor.visit_u128(*n),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(n)) => visitor.visit_f64((*n).into()),
Value::String(s) => visitor.visit_borrowed_str(s),
Value::Array(a) => visitor.visit_seq(ArrayRef(a.as_slice().iter())),
Expand Down
1 change: 1 addition & 0 deletions src/serde/value/borrowed/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl<'value> Serialize for Value<'value> {
match self {
Value::Static(StaticNode::Null) => serializer.serialize_unit(),
Value::Static(StaticNode::Bool(b)) => serializer.serialize_bool(*b),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(f)) => serializer.serialize_f64((*f).into()),
Value::Static(StaticNode::U64(i)) => serializer.serialize_u64(*i),
#[cfg(feature = "128bit")]
Expand Down
2 changes: 2 additions & 0 deletions src/serde/value/owned/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl<'de> de::Deserializer<'de> for Value {
Value::Static(StaticNode::U64(n)) => visitor.visit_u64(n),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(n)) => visitor.visit_u128(n),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(n)) => visitor.visit_f64(n.into()),
Value::String(s) => visitor.visit_string(s),
Value::Array(a) => visitor.visit_seq(Array(a.into_iter())),
Expand Down Expand Up @@ -608,6 +609,7 @@ impl<'de> de::Deserializer<'de> for &'de Value {
Value::Static(StaticNode::U64(n)) => visitor.visit_u64(*n),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(n)) => visitor.visit_u128(*n),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(n)) => visitor.visit_f64((*n).into()),
Value::String(s) => visitor.visit_borrowed_str(s),
Value::Array(a) => visitor.visit_seq(ArrayRef(a.as_slice().iter())),
Expand Down
1 change: 1 addition & 0 deletions src/serde/value/owned/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl Serialize for Value {
match self {
Value::Static(StaticNode::Null) => serializer.serialize_unit(),
Value::Static(StaticNode::Bool(b)) => serializer.serialize_bool(*b),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(f)) => serializer.serialize_f64((*f).into()),
Value::Static(StaticNode::U64(i)) => serializer.serialize_u64(*i),
#[cfg(feature = "128bit")]
Expand Down
2 changes: 2 additions & 0 deletions src/value/borrowed/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ trait Generator: BaseGenerator {
Value::Static(StaticNode::U64(number)) => self.write_int(number),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(number)) => self.write_int(number),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(number)) => self.write_float(number.into()),
Value::Static(StaticNode::Bool(true)) => self.write(b"true"),
Value::Static(StaticNode::Bool(false)) => self.write(b"false"),
Expand Down Expand Up @@ -175,6 +176,7 @@ trait FastGenerator: BaseGenerator {
Value::Static(StaticNode::U64(number)) => self.write_int(number),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(number)) => self.write_int(number),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(number)) => self.write_float(number.into()),
Value::Static(StaticNode::Bool(true)) => self.write(b"true"),
Value::Static(StaticNode::Bool(false)) => self.write(b"false"),
Expand Down
2 changes: 2 additions & 0 deletions src/value/owned/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ trait Generator: BaseGenerator {
Value::Static(StaticNode::U64(number)) => self.write_int(number),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(number)) => self.write_int(number),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(number)) => self.write_float(number.into()),
Value::Static(StaticNode::Bool(true)) => self.write(b"true"),
Value::Static(StaticNode::Bool(false)) => self.write(b"false"),
Expand Down Expand Up @@ -177,6 +178,7 @@ trait FastGenerator: BaseGenerator {
Value::Static(StaticNode::U64(number)) => self.write_int(number),
#[cfg(feature = "128bit")]
Value::Static(StaticNode::U128(number)) => self.write_int(number),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Value::Static(StaticNode::F64(number)) => self.write_float(number.into()),
Value::Static(StaticNode::Bool(true)) => self.write(b"true"),
Value::Static(StaticNode::Bool(false)) => self.write(b"false"),
Expand Down
2 changes: 2 additions & 0 deletions src/value/tape/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ trait Generator: BaseGenerator {
Node::Static(StaticNode::U64(number)) => self.write_int(number),
#[cfg(feature = "128bit")]
Node::Static(StaticNode::U128(number)) => self.write_int(number),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Node::Static(StaticNode::F64(number)) => self.write_float(number.into()),
Node::Static(StaticNode::Bool(true)) => self.write(b"true"),
Node::Static(StaticNode::Bool(false)) => self.write(b"false"),
Expand Down Expand Up @@ -819,6 +820,7 @@ trait FastGenerator: BaseGenerator {
Node::Static(StaticNode::U64(number)) => self.write_int(number),
#[cfg(feature = "128bit")]
Node::Static(StaticNode::U128(number)) => self.write_int(number),
#[allow(clippy::useless_conversion)] // .into() required by ordered-float
Node::Static(StaticNode::F64(number)) => self.write_float(number.into()),
Node::Static(StaticNode::Bool(true)) => self.write(b"true"),
Node::Static(StaticNode::Bool(false)) => self.write(b"false"),
Expand Down

0 comments on commit c994bdf

Please sign in to comment.