Upgrade rust/crates/serde_json to 1.0.59
Test: make
Change-Id: I4bea1b55837c5667419f03ff562973006381e613
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 3b3e218..cef5ea9 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "4354fc3eb2232ee0ba9a9a23acce107a980a6dc0"
+ "sha1": "64bb3962bd70ae74d6e8a9daa496504c64033760"
}
}
diff --git a/Android.bp b/Android.bp
index 5aaafbe..e4d06af 100644
--- a/Android.bp
+++ b/Android.bp
@@ -22,10 +22,10 @@
// dependent_library ["feature_list"]
// itoa-0.4.6
-// proc-macro2-1.0.19 "default,proc-macro"
+// proc-macro2-1.0.24 "default,proc-macro"
// quote-1.0.7 "default,proc-macro"
// ryu-1.0.5
-// serde-1.0.115 "default,derive,serde_derive,std"
-// serde_derive-1.0.115 "default"
-// syn-1.0.38 "clone-impls,default,derive,full,parsing,printing,proc-macro,quote,visit"
+// serde-1.0.117 "default,derive,serde_derive,std"
+// serde_derive-1.0.117 "default"
+// syn-1.0.48 "clone-impls,default,derive,parsing,printing,proc-macro,quote,visit"
// unicode-xid-0.2.1 "default"
diff --git a/Cargo.toml b/Cargo.toml
index b517dab..832b95c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "serde_json"
-version = "1.0.57"
+version = "1.0.59"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
include = ["build.rs", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
description = "A JSON serialization file format"
@@ -30,7 +30,7 @@
[package.metadata.playground]
features = ["raw_value"]
[dependencies.indexmap]
-version = "1.2"
+version = "1.5"
optional = true
[dependencies.itoa]
@@ -44,7 +44,7 @@
version = "1.0.100"
default-features = false
[dev-dependencies.automod]
-version = "0.1"
+version = "1.0"
[dev-dependencies.rustversion]
version = "1.0"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 43509c9..03e6fb9 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "serde_json"
-version = "1.0.57" # remember to update html_root_url
+version = "1.0.59" # remember to update html_root_url
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
license = "MIT OR Apache-2.0"
description = "A JSON serialization file format"
@@ -14,12 +14,12 @@
[dependencies]
serde = { version = "1.0.100", default-features = false }
-indexmap = { version = "1.2", optional = true }
+indexmap = { version = "1.5", optional = true }
itoa = { version = "0.4.3", default-features = false }
ryu = "1.0"
[dev-dependencies]
-automod = "0.1"
+automod = "1.0"
rustversion = "1.0"
serde_bytes = "0.11"
serde_derive = "1.0"
diff --git a/METADATA b/METADATA
index de371b6..015e8d4 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/serde_json/serde_json-1.0.57.crate"
+ value: "https://static.crates.io/crates/serde_json/serde_json-1.0.59.crate"
}
- version: "1.0.57"
+ version: "1.0.59"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 8
- day: 21
+ month: 10
+ day: 26
}
}
diff --git a/build.rs b/build.rs
index 46e0f17..04ff4a0 100644
--- a/build.rs
+++ b/build.rs
@@ -1,4 +1,6 @@
use std::env;
+use std::process::Command;
+use std::str::{self, FromStr};
fn main() {
// Decide ideal limb width for arithmetic in the float parser. Refer to
@@ -12,4 +14,33 @@
println!("cargo:rustc-cfg=limb_width_32");
}
}
+
+ let minor = match rustc_minor_version() {
+ Some(minor) => minor,
+ None => return,
+ };
+
+ // BTreeMap::get_key_value
+ // https://blog.rust-lang.org/2019/12/19/Rust-1.40.0.html#additions-to-the-standard-library
+ if minor < 40 {
+ println!("cargo:rustc-cfg=no_btreemap_get_key_value");
+ }
+
+ // BTreeMap::remove_entry
+ // https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#library-changes
+ if minor < 45 {
+ println!("cargo:rustc-cfg=no_btreemap_remove_entry");
+ }
+}
+
+fn rustc_minor_version() -> Option<u32> {
+ let rustc = env::var_os("RUSTC")?;
+ let output = Command::new(rustc).arg("--version").output().ok()?;
+ let version = str::from_utf8(&output.stdout).ok()?;
+ let mut pieces = version.split('.');
+ if pieces.next() != Some("rustc 1") {
+ return None;
+ }
+ let next = pieces.next()?;
+ u32::from_str(next).ok()
}
diff --git a/src/lib.rs b/src/lib.rs
index 537ba02..4b782a0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -300,7 +300,7 @@
//! [macro]: https://docs.serde.rs/serde_json/macro.json.html
//! [`serde-json-core`]: https://japaric.github.io/serde-json-core/serde_json_core/
-#![doc(html_root_url = "https://docs.rs/serde_json/1.0.57")]
+#![doc(html_root_url = "https://docs.rs/serde_json/1.0.59")]
#![deny(clippy::all, clippy::pedantic)]
// Ignored clippy lints
#![allow(
@@ -329,6 +329,7 @@
clippy::enum_glob_use,
clippy::if_not_else,
clippy::integer_division,
+ clippy::map_err_ignore,
clippy::match_same_arms,
clippy::similar_names,
clippy::unused_self,
@@ -378,6 +379,7 @@
pub use self::core::hash::{self, Hash};
pub use self::core::iter::FusedIterator;
pub use self::core::marker::{self, PhantomData};
+ pub use self::core::ops::{Bound, RangeBounds};
pub use self::core::result::{self, Result};
pub use self::core::{borrow, char, cmp, iter, mem, num, ops, slice, str};
diff --git a/src/map.rs b/src/map.rs
index a8defa7..f09d840 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -122,11 +122,59 @@
return self.map.remove(key);
}
+ /// Removes a key from the map, returning the stored key and value if the
+ /// key was previously in the map.
+ ///
+ /// The key may be any borrowed form of the map's key type, but the ordering
+ /// on the borrowed form *must* match the ordering on the key type.
+ pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(String, Value)>
+ where
+ String: Borrow<Q>,
+ Q: ?Sized + Ord + Eq + Hash,
+ {
+ #[cfg(any(feature = "preserve_order", not(no_btreemap_remove_entry)))]
+ return self.map.remove_entry(key);
+ #[cfg(all(
+ not(feature = "preserve_order"),
+ no_btreemap_remove_entry,
+ not(no_btreemap_get_key_value),
+ ))]
+ {
+ let (key, _value) = self.map.get_key_value(key)?;
+ let key = key.clone();
+ let value = self.map.remove::<String>(&key)?;
+ Some((key, value))
+ }
+ #[cfg(all(
+ not(feature = "preserve_order"),
+ no_btreemap_remove_entry,
+ no_btreemap_get_key_value,
+ ))]
+ {
+ struct Key<'a, Q: ?Sized>(&'a Q);
+
+ impl<'a, Q: ?Sized> RangeBounds<Q> for Key<'a, Q> {
+ fn start_bound(&self) -> Bound<&Q> {
+ Bound::Included(self.0)
+ }
+ fn end_bound(&self) -> Bound<&Q> {
+ Bound::Included(self.0)
+ }
+ }
+
+ let mut range = self.map.range(Key(key));
+ let (key, _value) = range.next()?;
+ let key = key.clone();
+ let value = self.map.remove::<String>(&key)?;
+ Some((key, value))
+ }
+ }
+
/// Moves all elements from other into Self, leaving other empty.
#[inline]
pub fn append(&mut self, other: &mut Self) {
#[cfg(feature = "preserve_order")]
- for (k, v) in std::mem::replace(&mut other.map, MapImpl::default()) {
+ for (k, v) in mem::replace(&mut other.map, MapImpl::default()) {
self.map.insert(k, v);
}
#[cfg(not(feature = "preserve_order"))]
diff --git a/src/number.rs b/src/number.rs
index 04a5602..c147618 100644
--- a/src/number.rs
+++ b/src/number.rs
@@ -211,7 +211,7 @@
N::Float(n) => Some(n),
}
#[cfg(feature = "arbitrary_precision")]
- self.n.parse().ok()
+ self.n.parse::<f64>().ok().filter(|float| float.is_finite())
}
/// Converts a finite `f64` to a `Number`. Infinite or NaN values are not JSON