From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- third_party/rust/serde_json/tests/regression/issue1004.rs | 12 ++++++++++++ third_party/rust/serde_json/tests/regression/issue520.rs | 2 +- third_party/rust/serde_json/tests/regression/issue795.rs | 5 ++++- third_party/rust/serde_json/tests/regression/issue845.rs | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 third_party/rust/serde_json/tests/regression/issue1004.rs (limited to 'third_party/rust/serde_json/tests/regression') diff --git a/third_party/rust/serde_json/tests/regression/issue1004.rs b/third_party/rust/serde_json/tests/regression/issue1004.rs new file mode 100644 index 0000000000..c09fb96108 --- /dev/null +++ b/third_party/rust/serde_json/tests/regression/issue1004.rs @@ -0,0 +1,12 @@ +#![cfg(feature = "arbitrary_precision")] + +#[test] +fn test() { + let float = 5.55f32; + let value = serde_json::to_value(float).unwrap(); + let json = serde_json::to_string(&value).unwrap(); + + // If the f32 were cast to f64 by Value before serialization, then this + // would incorrectly serialize as 5.550000190734863. + assert_eq!(json, "5.55"); +} diff --git a/third_party/rust/serde_json/tests/regression/issue520.rs b/third_party/rust/serde_json/tests/regression/issue520.rs index 9ed367731b..730ecc60a8 100644 --- a/third_party/rust/serde_json/tests/regression/issue520.rs +++ b/third_party/rust/serde_json/tests/regression/issue520.rs @@ -1,6 +1,6 @@ #![allow(clippy::float_cmp)] -use serde_derive::{Serialize, Deserialize}; +use serde_derive::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] #[serde(tag = "type", content = "data")] diff --git a/third_party/rust/serde_json/tests/regression/issue795.rs b/third_party/rust/serde_json/tests/regression/issue795.rs index bb82852c54..411e8af5d3 100644 --- a/third_party/rust/serde_json/tests/regression/issue795.rs +++ b/third_party/rust/serde_json/tests/regression/issue795.rs @@ -8,7 +8,10 @@ use std::fmt; #[derive(Debug)] pub enum Enum { - Variant { x: u8 }, + Variant { + #[allow(dead_code)] + x: u8, + }, } impl<'de> Deserialize<'de> for Enum { diff --git a/third_party/rust/serde_json/tests/regression/issue845.rs b/third_party/rust/serde_json/tests/regression/issue845.rs index 56037ae669..7b6564dadb 100644 --- a/third_party/rust/serde_json/tests/regression/issue845.rs +++ b/third_party/rust/serde_json/tests/regression/issue845.rs @@ -1,7 +1,6 @@ #![allow(clippy::trait_duplication_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/8757 use serde::{Deserialize, Deserializer}; -use std::convert::TryFrom; use std::fmt::{self, Display}; use std::marker::PhantomData; use std::str::FromStr; @@ -61,6 +60,7 @@ where #[derive(Deserialize, Debug)] pub struct Struct { #[serde(deserialize_with = "deserialize_integer_or_string")] + #[allow(dead_code)] pub i: i64, } -- cgit v1.2.3