aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-08-12 21:22:38 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-08-12 21:22:38 +0000
commit5b903a9856e41ceb2a8a91ce6c6a31de98ff00dd (patch)
treef57d25447b80ff53d9487d7c1ac72bb9c4dad1d6
parent8887e4904621d90701e8b9a1ad9ad7410c4a0074 (diff)
parent3b1e4baf92773dbd3d76b10e17f38bc7589105b4 (diff)
downloadserde_json-5b903a9856e41ceb2a8a91ce6c6a31de98ff00dd.tar.gz
Upgrade rust/crates/serde_json to 1.0.66 am: d1eaeafe62 am: 1c3e96b020 am: a1e37ad29a am: 051bc95acb am: 3b1e4baf92
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/serde_json/+/1791036 Change-Id: Icff922e30c702e7d8aae0bf3c47cc961b7a60460
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp8
-rw-r--r--Cargo.toml12
-rw-r--r--Cargo.toml.orig3
-rw-r--r--METADATA8
-rw-r--r--README.md22
-rw-r--r--src/de.rs11
-rw-r--r--src/error.rs2
-rw-r--r--src/iter.rs2
-rw-r--r--src/lib.rs6
-rw-r--r--src/map.rs2
-rw-r--r--src/raw.rs2
-rw-r--r--src/read.rs5
-rw-r--r--src/ser.rs27
-rw-r--r--src/value/mod.rs53
15 files changed, 77 insertions, 88 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index dd6bf24..53f9a19 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "d0d80783d31161c869922fad933b3623715506d2"
+ "sha1": "6346bb30037f31ea69b9a4eb029875e23521681c"
}
}
diff --git a/Android.bp b/Android.bp
index 60fe7bf..33f4c5a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -62,10 +62,10 @@ rust_library {
// dependent_library ["feature_list"]
// itoa-0.4.7
-// proc-macro2-1.0.26 "default,proc-macro"
+// proc-macro2-1.0.28 "default,proc-macro"
// quote-1.0.9 "default,proc-macro"
// ryu-1.0.5
-// serde-1.0.126 "default,derive,serde_derive,std"
-// serde_derive-1.0.126 "default"
-// syn-1.0.72 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
+// serde-1.0.127 "default,derive,serde_derive,std"
+// serde_derive-1.0.127 "default"
+// syn-1.0.74 "clone-impls,default,derive,parsing,printing,proc-macro,quote"
// unicode-xid-0.2.2 "default"
diff --git a/Cargo.toml b/Cargo.toml
index fe399a8..a6e056b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,17 +3,16 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "serde_json"
-version = "1.0.64"
+version = "1.0.66"
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"
@@ -25,6 +24,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/serde-rs/json"
[package.metadata.docs.rs]
features = ["raw_value", "unbounded_depth"]
+rustdoc-args = ["--cfg", "docsrs"]
targets = ["x86_64-unknown-linux-gnu"]
[package.metadata.playground]
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 6ecb159..a664e75 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "serde_json"
-version = "1.0.64" # remember to update html_root_url
+version = "1.0.66" # 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"
@@ -32,6 +32,7 @@ members = ["tests/crate"]
[package.metadata.docs.rs]
features = ["raw_value", "unbounded_depth"]
targets = ["x86_64-unknown-linux-gnu"]
+rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.playground]
features = ["raw_value"]
diff --git a/METADATA b/METADATA
index 46bb276..dfec5e7 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/serde_json/serde_json-1.0.64.crate"
+ value: "https://static.crates.io/crates/serde_json/serde_json-1.0.66.crate"
}
- version: "1.0.64"
+ version: "1.0.66"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 5
- day: 19
+ month: 8
+ day: 9
}
}
diff --git a/README.md b/README.md
index f2db0de..96587a0 100644
--- a/README.md
+++ b/README.md
@@ -81,9 +81,11 @@ A string of JSON data can be parsed into a `serde_json::Value` by the
[`from_reader`][from_reader] for parsing from any `io::Read` like a File or
a TCP stream.
+<div align="right">
<a href="https://play.rust-lang.org/?edition=2018&gist=d69d8e3156d4bb81c4461b60b772ab72" target="_blank">
-<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
+<img align="center" width="85" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/runtab.png">
</a>
+</div>
```rust
use serde_json::{Result, Value};
@@ -139,9 +141,11 @@ in one of the dozens of places it is used in your code.
Serde provides a powerful way of mapping JSON data into Rust data structures
largely automatically.
+<div align="right">
<a href="https://play.rust-lang.org/?edition=2018&gist=15cfab66d38ff8a15a9cf1d8d897ac68" target="_blank">
-<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
+<img align="center" width="85" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/runtab.png">
</a>
+</div>
```rust
use serde::{Deserialize, Serialize};
@@ -206,9 +210,11 @@ derive]* page of the Serde site.
Serde JSON provides a [`json!` macro][macro] to build `serde_json::Value`
objects with very natural JSON syntax.
+<div align="right">
<a href="https://play.rust-lang.org/?edition=2018&gist=6ccafad431d72b62e77cc34c8e879b24" target="_blank">
-<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
+<img align="center" width="85" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/runtab.png">
</a>
+</div>
```rust
use serde_json::json;
@@ -239,9 +245,11 @@ be interpolated directly into the JSON value as you are building it. Serde
will check at compile time that the value you are interpolating is able to
be represented as JSON.
+<div align="right">
<a href="https://play.rust-lang.org/?edition=2018&gist=f9101a6e61dfc9e02c6a67f315ed24f2" target="_blank">
-<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
+<img align="center" width="85" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/runtab.png">
</a>
+</div>
```rust
let full_name = "John Doe";
@@ -270,9 +278,11 @@ A data structure can be converted to a JSON string by
[`serde_json::to_writer`][to_writer] which serializes to any `io::Write`
such as a File or a TCP stream.
+<div align="right">
<a href="https://play.rust-lang.org/?edition=2018&gist=3472242a08ed2ff88a944f2a2283b0ee" target="_blank">
-<img align="right" width="50" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/run.png">
+<img align="center" width="85" src="https://raw.githubusercontent.com/serde-rs/serde-rs.github.io/master/img/runtab.png">
</a>
+</div>
```rust
use serde::{Deserialize, Serialize};
@@ -350,7 +360,7 @@ serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
For JSON support in Serde without a memory allocator, please see the
[`serde-json-core`] crate.
-[`serde-json-core`]: https://japaric.github.io/serde-json-core/serde_json_core/
+[`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core
[value]: https://docs.serde.rs/serde_json/value/enum.Value.html
[from_str]: https://docs.serde.rs/serde_json/de/fn.from_str.html
diff --git a/src/de.rs b/src/de.rs
index 15c8236..7cc9f9b 100644
--- a/src/de.rs
+++ b/src/de.rs
@@ -196,6 +196,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
/// }
/// ```
#[cfg(feature = "unbounded_depth")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "unbounded_depth")))]
pub fn disable_recursion_limit(&mut self) {
self.disable_recursion_limit = true;
}
@@ -898,7 +899,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
fn scan_number(&mut self, buf: &mut String) -> Result<()> {
match tri!(self.peek_or_null()) {
b'.' => self.scan_decimal(buf),
- b'e' | b'E' => self.scan_exponent(buf),
+ e @ b'e' | e @ b'E' => self.scan_exponent(e as char, buf),
_ => Ok(()),
}
}
@@ -923,19 +924,20 @@ impl<'de, R: Read<'de>> Deserializer<R> {
}
match tri!(self.peek_or_null()) {
- b'e' | b'E' => self.scan_exponent(buf),
+ e @ b'e' | e @ b'E' => self.scan_exponent(e as char, buf),
_ => Ok(()),
}
}
#[cfg(feature = "arbitrary_precision")]
- fn scan_exponent(&mut self, buf: &mut String) -> Result<()> {
+ fn scan_exponent(&mut self, e: char, buf: &mut String) -> Result<()> {
self.eat_char();
- buf.push('e');
+ buf.push(e);
match tri!(self.peek_or_null()) {
b'+' => {
self.eat_char();
+ buf.push('+');
}
b'-' => {
self.eat_char();
@@ -2494,6 +2496,7 @@ where
/// the JSON map or some number is too big to fit in the expected primitive
/// type.
#[cfg(feature = "std")]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn from_reader<R, T>(rdr: R) -> Result<T>
where
R: crate::io::Read,
diff --git a/src/error.rs b/src/error.rs
index 7dcdd81..4219d32 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -234,7 +234,7 @@ pub(crate) enum ErrorCode {
/// JSON has non-whitespace trailing characters after the value.
TrailingCharacters,
- /// Unexpected end of hex excape.
+ /// Unexpected end of hex escape.
UnexpectedEndOfHexEscape,
/// Encountered nesting of JSON maps and arrays more than 128 layers deep.
diff --git a/src/iter.rs b/src/iter.rs
index c14026f..9792916 100644
--- a/src/iter.rs
+++ b/src/iter.rs
@@ -12,7 +12,7 @@ pub struct LineColIterator<I> {
/// The column is 0 immediately after a newline character has been read.
col: usize,
- /// Byte offset of the start of the current line. This is the sum of lenghts
+ /// Byte offset of the start of the current line. This is the sum of lengths
/// of all previous lines. Keeping track of things this way allows efficient
/// computation of the current line, column, and byte offset while only
/// updating one of the counters in `next()` in the common case.
diff --git a/src/lib.rs b/src/lib.rs
index 1d75083..a7b781b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -298,9 +298,9 @@
//! [to_vec]: https://docs.serde.rs/serde_json/ser/fn.to_vec.html
//! [to_writer]: https://docs.serde.rs/serde_json/ser/fn.to_writer.html
//! [macro]: https://docs.serde.rs/serde_json/macro.json.html
-//! [`serde-json-core`]: https://japaric.github.io/serde-json-core/serde_json_core/
+//! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core
-#![doc(html_root_url = "https://docs.rs/serde_json/1.0.64")]
+#![doc(html_root_url = "https://docs.rs/serde_json/1.0.66")]
#![deny(clippy::all, clippy::pedantic)]
// Ignored clippy lints
#![allow(
@@ -357,6 +357,7 @@
#![allow(non_upper_case_globals)]
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
+#![cfg_attr(docsrs, feature(doc_cfg))]
////////////////////////////////////////////////////////////////////////////////
@@ -453,6 +454,7 @@ pub mod de;
pub mod error;
pub mod map;
#[cfg(feature = "std")]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub mod ser;
#[cfg(not(feature = "std"))]
mod ser;
diff --git a/src/map.rs b/src/map.rs
index b564446..c8fb503 100644
--- a/src/map.rs
+++ b/src/map.rs
@@ -52,7 +52,7 @@ impl Map<String, Value> {
/// Clears the map, removing all values.
#[inline]
pub fn clear(&mut self) {
- self.map.clear()
+ self.map.clear();
}
/// Returns a reference to the value corresponding to the key.
diff --git a/src/raw.rs b/src/raw.rs
index c373b4d..b8d04ee 100644
--- a/src/raw.rs
+++ b/src/raw.rs
@@ -109,6 +109,7 @@ use serde::ser::{Serialize, SerializeStruct, Serializer};
/// }
/// ```
#[repr(C)]
+#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))]
pub struct RawValue {
json: str,
}
@@ -267,6 +268,7 @@ impl RawValue {
///
/// println!("{}", serde_json::value::to_raw_value(&map).unwrap_err());
/// ```
+#[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))]
pub fn to_raw_value<T>(value: &T) -> Result<Box<RawValue>, Error>
where
T: Serialize,
diff --git a/src/read.rs b/src/read.rs
index d247c30..8ed3d7d 100644
--- a/src/read.rs
+++ b/src/read.rs
@@ -140,6 +140,7 @@ where
/// JSON input source that reads from a std::io input stream.
#[cfg(feature = "std")]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub struct IoRead<R>
where
R: io::Read,
@@ -716,7 +717,7 @@ where
}
fn discard(&mut self) {
- R::discard(self)
+ R::discard(self);
}
fn position(&self) -> Position {
@@ -766,7 +767,7 @@ where
const should_early_return_if_failed: bool = R::should_early_return_if_failed;
fn set_failed(&mut self, failed: &mut bool) {
- R::set_failed(self, failed)
+ R::set_failed(self, failed);
}
}
diff --git a/src/ser.rs b/src/ser.rs
index b9b83cd..54b0bf2 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -8,6 +8,7 @@ use serde::ser::{self, Impossible, Serialize};
use serde::serde_if_integer128;
/// A structure for serializing Rust values into JSON.
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub struct Serializer<W, F = CompactFormatter> {
writer: W,
formatter: F,
@@ -316,13 +317,13 @@ where
#[inline]
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq> {
+ tri!(self
+ .formatter
+ .begin_array(&mut self.writer)
+ .map_err(Error::io));
if len == Some(0) {
tri!(self
.formatter
- .begin_array(&mut self.writer)
- .map_err(Error::io));
- tri!(self
- .formatter
.end_array(&mut self.writer)
.map_err(Error::io));
Ok(Compound::Map {
@@ -330,10 +331,6 @@ where
state: State::Empty,
})
} else {
- tri!(self
- .formatter
- .begin_array(&mut self.writer)
- .map_err(Error::io));
Ok(Compound::Map {
ser: self,
state: State::First,
@@ -385,13 +382,13 @@ where
#[inline]
fn serialize_map(self, len: Option<usize>) -> Result<Self::SerializeMap> {
+ tri!(self
+ .formatter
+ .begin_object(&mut self.writer)
+ .map_err(Error::io));
if len == Some(0) {
tri!(self
.formatter
- .begin_object(&mut self.writer)
- .map_err(Error::io));
- tri!(self
- .formatter
.end_object(&mut self.writer)
.map_err(Error::io));
Ok(Compound::Map {
@@ -399,10 +396,6 @@ where
state: State::Empty,
})
} else {
- tri!(self
- .formatter
- .begin_object(&mut self.writer)
- .map_err(Error::io));
Ok(Compound::Map {
ser: self,
state: State::First,
@@ -2149,6 +2142,7 @@ static ESCAPE: [u8; 256] = [
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// fail, or if `T` contains a map with non-string keys.
#[inline]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn to_writer<W, T>(writer: W, value: &T) -> Result<()>
where
W: io::Write,
@@ -2167,6 +2161,7 @@ where
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// fail, or if `T` contains a map with non-string keys.
#[inline]
+#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
pub fn to_writer_pretty<W, T>(writer: W, value: &T) -> Result<()>
where
W: io::Write,
diff --git a/src/value/mod.rs b/src/value/mod.rs
index 88d2ef6..a28da66 100644
--- a/src/value/mod.rs
+++ b/src/value/mod.rs
@@ -758,25 +758,15 @@ impl Value {
if !pointer.starts_with('/') {
return None;
}
- let tokens = pointer
+ pointer
.split('/')
.skip(1)
- .map(|x| x.replace("~1", "/").replace("~0", "~"));
- let mut target = self;
-
- for token in tokens {
- let target_opt = match *target {
- Value::Object(ref map) => map.get(&token),
- Value::Array(ref list) => parse_index(&token).and_then(|x| list.get(x)),
- _ => return None,
- };
- if let Some(t) = target_opt {
- target = t;
- } else {
- return None;
- }
- }
- Some(target)
+ .map(|x| x.replace("~1", "/").replace("~0", "~"))
+ .try_fold(self, |target, token| match target {
+ Value::Object(map) => map.get(&token),
+ Value::Array(list) => parse_index(&token).and_then(|x| list.get(x)),
+ _ => None,
+ })
}
/// Looks up a value by a JSON Pointer and returns a mutable reference to
@@ -823,30 +813,15 @@ impl Value {
if !pointer.starts_with('/') {
return None;
}
- let tokens = pointer
+ pointer
.split('/')
.skip(1)
- .map(|x| x.replace("~1", "/").replace("~0", "~"));
- let mut target = self;
-
- for token in tokens {
- // borrow checker gets confused about `target` being mutably borrowed too many times because of the loop
- // this once-per-loop binding makes the scope clearer and circumvents the error
- let target_once = target;
- let target_opt = match *target_once {
- Value::Object(ref mut map) => map.get_mut(&token),
- Value::Array(ref mut list) => {
- parse_index(&token).and_then(move |x| list.get_mut(x))
- }
- _ => return None,
- };
- if let Some(t) = target_opt {
- target = t;
- } else {
- return None;
- }
- }
- Some(target)
+ .map(|x| x.replace("~1", "/").replace("~0", "~"))
+ .try_fold(self, |target, token| match target {
+ Value::Object(map) => map.get_mut(&token),
+ Value::Array(list) => parse_index(&token).and_then(move |x| list.get_mut(x)),
+ _ => None,
+ })
}
/// Takes the value out of the `Value`, leaving a `Null` in its place.