From c7626dbac286ddf54aa120b3f3e7c9ebb4804af7 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 22 Jan 2025 19:30:32 -0800 Subject: [PATCH 01/18] Remove **/*.rs.bk from project-specific gitignore Cargo stopped generating this in its project template 5 years ago. It would belong in a global gitignore instead. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 165eb22d0..2a8a14e9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ target/ -**/*.rs.bk *.sw[po] Cargo.lock From 4134f119c025afa0f57f6b52b66def5c69db0ae6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 22 Jan 2025 19:37:18 -0800 Subject: [PATCH 02/18] Remove *.sw[po] from gitignore This belongs in someone's global gitignore. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a8a14e9e..2c96eb1b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ target/ -*.sw[po] Cargo.lock From 87f78da0f57a5bc6c875e56357bc9761558a3ef9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 23 Jan 2025 01:40:57 -0800 Subject: [PATCH 03/18] More precise gitignore patterns --- .gitignore | 4 ++-- fuzz/.gitignore | 9 +++++---- tests/crate/.gitignore | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 tests/crate/.gitignore diff --git a/.gitignore b/.gitignore index 2c96eb1b6..e9e21997b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -target/ -Cargo.lock +/target/ +/Cargo.lock diff --git a/fuzz/.gitignore b/fuzz/.gitignore index f83457aec..4bc31dc39 100644 --- a/fuzz/.gitignore +++ b/fuzz/.gitignore @@ -1,4 +1,5 @@ -artifacts/ -corpus/ -coverage/ -target/ +/artifacts/ +/corpus/ +/coverage/ +/target/ +/Cargo.lock diff --git a/tests/crate/.gitignore b/tests/crate/.gitignore new file mode 100644 index 000000000..e9e21997b --- /dev/null +++ b/tests/crate/.gitignore @@ -0,0 +1,2 @@ +/target/ +/Cargo.lock From 65bbd1aa2d0c9aca8347ba5b963e2f8658ab2d42 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Tue, 28 Jan 2025 08:38:17 +0100 Subject: [PATCH 04/18] Fix example of from_reader not applying buffering when it should --- src/de.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/de.rs b/src/de.rs index 5b64138d8..b1f4b84c3 100644 --- a/src/de.rs +++ b/src/de.rs @@ -2568,6 +2568,7 @@ where /// /// use std::error::Error; /// use std::net::{TcpListener, TcpStream}; +/// use std::io::BufReader; /// /// #[derive(Deserialize, Debug)] /// struct User { @@ -2576,7 +2577,8 @@ where /// } /// /// fn read_user_from_stream(tcp_stream: TcpStream) -> Result> { -/// let mut de = serde_json::Deserializer::from_reader(tcp_stream); +/// let buf_tcp_stream = BufReader::new(tcp_stream); +/// let mut de = serde_json::Deserializer::from_reader(buf_tcp_stream); /// let u = User::deserialize(&mut de)?; /// /// Ok(u) From 8c2d8004b2b873772dbeadd5ad3f96a185d329df Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Tue, 28 Jan 2025 08:41:52 +0100 Subject: [PATCH 05/18] Add more warnings to apply buffering on docs of affected functions --- src/de.rs | 6 ++++++ src/read.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/de.rs b/src/de.rs index b1f4b84c3..ec9c74664 100644 --- a/src/de.rs +++ b/src/de.rs @@ -45,11 +45,17 @@ where /// Create a JSON deserializer from one of the possible serde_json input /// sources. /// + /// When reading from a source against which short reads are not efficient, such + /// as a [`File`], you will want to apply your own buffering because serde_json + /// will not buffer the input. See [`std::io::BufReader`]. + /// /// Typically it is more convenient to use one of these methods instead: /// /// - Deserializer::from_str /// - Deserializer::from_slice /// - Deserializer::from_reader + /// + /// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html pub fn new(read: R) -> Self { Deserializer { read, diff --git a/src/read.rs b/src/read.rs index b4128467b..ef97493be 100644 --- a/src/read.rs +++ b/src/read.rs @@ -191,6 +191,12 @@ where R: io::Read, { /// Create a JSON input source to read from a std::io input stream. + /// + /// When reading from a source against which short reads are not efficient, such + /// as a [`File`], you will want to apply your own buffering because serde_json + /// will not buffer the input. See [`std::io::BufReader`]. + /// + /// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html pub fn new(reader: R) -> Self { IoRead { iter: LineColIterator::new(reader.bytes()), From 29122f9ed796712c098a1cd614f207bd9d1b2ccc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 28 Jan 2025 09:18:47 -0800 Subject: [PATCH 06/18] Sort imports from PR 1237 --- src/de.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de.rs b/src/de.rs index ec9c74664..db4b6dd01 100644 --- a/src/de.rs +++ b/src/de.rs @@ -2573,8 +2573,8 @@ where /// use serde::Deserialize; /// /// use std::error::Error; -/// use std::net::{TcpListener, TcpStream}; /// use std::io::BufReader; +/// use std::net::{TcpListener, TcpStream}; /// /// #[derive(Deserialize, Debug)] /// struct User { From dc29e4815d8b99d48f43d73638819b25e7cd19c8 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 28 Jan 2025 09:20:52 -0800 Subject: [PATCH 07/18] Move BufReader to caller The original read_user_from_stream function from PR 1237 is a bad pattern because it results in silently dropping any data left in the buffer on return. If we want to read anything else from the same TcpStream after the JSON object, the buffer needs to go in the caller. --- src/de.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/de.rs b/src/de.rs index db4b6dd01..3448045c4 100644 --- a/src/de.rs +++ b/src/de.rs @@ -2582,9 +2582,8 @@ where /// location: String, /// } /// -/// fn read_user_from_stream(tcp_stream: TcpStream) -> Result> { -/// let buf_tcp_stream = BufReader::new(tcp_stream); -/// let mut de = serde_json::Deserializer::from_reader(buf_tcp_stream); +/// fn read_user_from_stream(stream: &mut BufReader) -> Result> { +/// let mut de = serde_json::Deserializer::from_reader(stream); /// let u = User::deserialize(&mut de)?; /// /// Ok(u) @@ -2595,8 +2594,9 @@ where /// # fn fake_main() { /// let listener = TcpListener::bind("127.0.0.1:4000").unwrap(); /// -/// for stream in listener.incoming() { -/// println!("{:#?}", read_user_from_stream(stream.unwrap())); +/// for tcp_stream in listener.incoming() { +/// let mut buffered = BufReader::new(tcp_stream.unwrap()); +/// println!("{:#?}", read_user_from_stream(&mut buffered)); /// } /// } /// ``` From c916099147f0864c158bfffaf6d74870a64b16ee Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 28 Jan 2025 09:31:20 -0800 Subject: [PATCH 08/18] Release 1.0.138 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 242f05b6c..bb0313838 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_json" -version = "1.0.137" +version = "1.0.138" authors = ["Erick Tryzelaar ", "David Tolnay "] categories = ["encoding", "parser-implementations", "no-std"] description = "A JSON serialization file format" diff --git a/src/lib.rs b/src/lib.rs index 07090dd0c..eaf44d52d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,7 +299,7 @@ //! [macro]: crate::json //! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.137")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.138")] // Ignored clippy lints #![allow( clippy::collapsible_else_if, From 1174c5f57db44c26460951b525c6ede50984b655 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 29 Jan 2025 18:20:13 -0800 Subject: [PATCH 09/18] Resolve unnecessary_semicolon pedantic clippy lint warning: unnecessary semicolon --> src/de.rs:371:10 | 371 | }; | ^ help: remove | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_semicolon = note: `-W clippy::unnecessary-semicolon` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::unnecessary_semicolon)]` --- src/de.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de.rs b/src/de.rs index 3448045c4..cb605217d 100644 --- a/src/de.rs +++ b/src/de.rs @@ -368,7 +368,7 @@ impl<'de, R: Read<'de>> Deserializer { None => { return Err(self.peek_error(ErrorCode::EofWhileParsingValue)); } - }; + } tri!(self.scan_integer128(&mut buf)); From 1d7378e8ee87e9225da28094329e06345b76cd99 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 9 Feb 2025 17:52:36 -0800 Subject: [PATCH 10/18] Unset doc-scrape-examples for lib target False is the default value since Cargo PR 11499. --- Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb0313838..7bf66a7ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,9 +29,6 @@ serde_derive = "1.0.166" serde_stacker = "0.1.8" trybuild = { version = "1.0.81", features = ["diff"] } -[lib] -doc-scrape-examples = false - [package.metadata.docs.rs] features = ["preserve_order", "raw_value", "unbounded_depth"] targets = ["x86_64-unknown-linux-gnu"] From 13591f1dd4baf2d510e56138599906815e9d798a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 19 Feb 2025 17:51:29 -0800 Subject: [PATCH 11/18] Convert html links to intra-doc links --- src/de.rs | 7 ++----- src/map.rs | 11 +++-------- src/raw.rs | 6 +++--- src/read.rs | 2 +- src/value/index.rs | 6 +++--- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/de.rs b/src/de.rs index cb605217d..4080c54ac 100644 --- a/src/de.rs +++ b/src/de.rs @@ -55,7 +55,7 @@ where /// - Deserializer::from_slice /// - Deserializer::from_reader /// - /// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html + /// [`File`]: std::fs::File pub fn new(read: R) -> Self { Deserializer { read, @@ -2523,10 +2523,7 @@ where /// reading a file completely into memory and then applying [`from_str`] /// or [`from_slice`] on it. See [issue #160]. /// -/// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html -/// [`std::io::BufReader`]: https://doc.rust-lang.org/std/io/struct.BufReader.html -/// [`from_str`]: ./fn.from_str.html -/// [`from_slice`]: ./fn.from_slice.html +/// [`File`]: std::fs::File /// [issue #160]: https://github.com/serde-rs/json/issues/160 /// /// # Example diff --git a/src/map.rs b/src/map.rs index 126e8001a..be60f22db 100644 --- a/src/map.rs +++ b/src/map.rs @@ -3,8 +3,8 @@ //! By default the map is backed by a [`BTreeMap`]. Enable the `preserve_order` //! feature of serde_json to use [`IndexMap`] instead. //! -//! [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html -//! [`IndexMap`]: https://docs.rs/indexmap/*/indexmap/map/struct.IndexMap.html +//! [`BTreeMap`]: std::collections::BTreeMap +//! [`IndexMap`]: indexmap::IndexMap use crate::error::Error; use crate::value::Value; @@ -619,8 +619,7 @@ impl<'de> de::IntoDeserializer<'de, Error> for &'de Map { /// A view into a single entry in a map, which may either be vacant or occupied. /// This enum is constructed from the [`entry`] method on [`Map`]. /// -/// [`entry`]: struct.Map.html#method.entry -/// [`Map`]: struct.Map.html +/// [`entry`]: Map::entry pub enum Entry<'a> { /// A vacant Entry. Vacant(VacantEntry<'a>), @@ -629,15 +628,11 @@ pub enum Entry<'a> { } /// A vacant Entry. It is part of the [`Entry`] enum. -/// -/// [`Entry`]: enum.Entry.html pub struct VacantEntry<'a> { vacant: VacantEntryImpl<'a>, } /// An occupied Entry. It is part of the [`Entry`] enum. -/// -/// [`Entry`]: enum.Entry.html pub struct OccupiedEntry<'a> { occupied: OccupiedEntryImpl<'a>, } diff --git a/src/raw.rs b/src/raw.rs index f81d943a5..be4dad44d 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -99,9 +99,9 @@ use serde::ser::{Serialize, SerializeStruct, Serializer}; /// the boxed form of `RawValue` instead. This is almost as efficient but /// involves buffering the raw value from the I/O stream into memory. /// -/// [`serde_json::from_str`]: ../fn.from_str.html -/// [`serde_json::from_slice`]: ../fn.from_slice.html -/// [`serde_json::from_reader`]: ../fn.from_reader.html +/// [`serde_json::from_str`]: crate::from_str +/// [`serde_json::from_slice`]: crate::from_slice +/// [`serde_json::from_reader`]: crate::from_reader /// /// ``` /// # use serde::Deserialize; diff --git a/src/read.rs b/src/read.rs index ef97493be..0748af44c 100644 --- a/src/read.rs +++ b/src/read.rs @@ -196,7 +196,7 @@ where /// as a [`File`], you will want to apply your own buffering because serde_json /// will not buffer the input. See [`std::io::BufReader`]. /// - /// [`File`]: https://doc.rust-lang.org/std/fs/struct.File.html + /// [`File`]: std::fs::File pub fn new(reader: R) -> Self { IoRead { iter: LineColIterator::new(reader.bytes()), diff --git a/src/value/index.rs b/src/value/index.rs index 4e41a39be..7b0011004 100644 --- a/src/value/index.rs +++ b/src/value/index.rs @@ -12,9 +12,9 @@ use core::ops; /// trait is implemented for strings which are used as the index into a JSON /// map, and for `usize` which is used as the index into a JSON array. /// -/// [`get`]: ../enum.Value.html#method.get -/// [`get_mut`]: ../enum.Value.html#method.get_mut -/// [square-bracket indexing operator]: ../enum.Value.html#impl-Index%3CI%3E-for-Value +/// [`get`]: Value::get +/// [`get_mut`]: Value::get_mut +/// [square-bracket indexing operator]: Value#impl-Index%3CI%3E-for-Value /// /// This trait is sealed and cannot be implemented for types outside of /// `serde_json`. From e5bb8bd38fe3b347655429b79d21ed89b366b706 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 19 Feb 2025 17:53:06 -0800 Subject: [PATCH 12/18] Document behavior of write_f32/f64 on non-finite floats --- src/ser.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/ser.rs b/src/ser.rs index 6956671b4..9b14389c8 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -1688,6 +1688,20 @@ pub trait Formatter { } /// Writes a floating point value like `-31.26e+12` to the specified writer. + /// + /// # Special cases + /// + /// This function **does not** check for NaN or infinity. If the input + /// number is not a finite float, the printed representation will be some + /// correctly formatted but unspecified numerical value. + /// + /// Please check [`is_finite`] yourself before calling this function, or + /// check [`is_nan`] and [`is_infinite`] and handle those cases yourself + /// with a different `Formatter` method. + /// + /// [`is_finite`]: f32::is_finite + /// [`is_nan`]: f32::is_nan + /// [`is_infinite`]: f32::is_infinite #[inline] fn write_f32(&mut self, writer: &mut W, value: f32) -> io::Result<()> where @@ -1699,6 +1713,20 @@ pub trait Formatter { } /// Writes a floating point value like `-31.26e+12` to the specified writer. + /// + /// # Special cases + /// + /// This function **does not** check for NaN or infinity. If the input + /// number is not a finite float, the printed representation will be some + /// correctly formatted but unspecified numerical value. + /// + /// Please check [`is_finite`] yourself before calling this function, or + /// check [`is_nan`] and [`is_infinite`] and handle those cases yourself + /// with a different `Formatter` method. + /// + /// [`is_finite`]: f64::is_finite + /// [`is_nan`]: f64::is_nan + /// [`is_infinite`]: f64::is_infinite #[inline] fn write_f64(&mut self, writer: &mut W, value: f64) -> io::Result<()> where From 4d4f53c3b7de3259b6a8a15ef4d5f4edb47af32f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 19 Feb 2025 18:34:59 -0800 Subject: [PATCH 13/18] Release 1.0.139 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7bf66a7ab..d4938615b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_json" -version = "1.0.138" +version = "1.0.139" authors = ["Erick Tryzelaar ", "David Tolnay "] categories = ["encoding", "parser-implementations", "no-std"] description = "A JSON serialization file format" diff --git a/src/lib.rs b/src/lib.rs index eaf44d52d..5aff596db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,7 +299,7 @@ //! [macro]: crate::json //! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.138")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.139")] // Ignored clippy lints #![allow( clippy::collapsible_else_if, From 400eaa977f1f0a1c9ad5e35d634ed2226bf1218c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 20 Feb 2025 05:24:48 -0800 Subject: [PATCH 14/18] Point standard library links to stable --- Cargo.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d4938615b..cf4ee4353 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,12 @@ trybuild = { version = "1.0.81", features = ["diff"] } [package.metadata.docs.rs] features = ["preserve_order", "raw_value", "unbounded_depth"] targets = ["x86_64-unknown-linux-gnu"] -rustdoc-args = ["--generate-link-to-definition"] +rustdoc-args = [ + "--generate-link-to-definition", + "--extern-html-root-url=core=https://doc.rust-lang.org", + "--extern-html-root-url=alloc=https://doc.rust-lang.org", + "--extern-html-root-url=std=https://doc.rust-lang.org", +] [package.metadata.playground] features = ["float_roundtrip", "raw_value", "unbounded_depth"] From 76cd4fb383eab71c22cc89ce270b08f4f77d788f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 3 Mar 2025 00:02:24 -0800 Subject: [PATCH 15/18] Ignore elidable_lifetime_names pedantic clippy lint warning: the following explicit lifetimes could be elided: 'a --> src/de.rs:2189:11 | 2189 | impl<'de, 'a, R> MapKey<'a, R> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names = note: `-W clippy::elidable-lifetime-names` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::elidable_lifetime_names)]` help: elide the lifetimes | 2189 - impl<'de, 'a, R> MapKey<'a, R> 2189 + impl<'de, R> MapKey<'_, R> | warning: the following explicit lifetimes could be elided: 'a --> src/de.rs:2196:11 | 2196 | impl<'de, 'a, R> de::Deserializer<'de> for MapKey<'a, R> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 2196 - impl<'de, 'a, R> de::Deserializer<'de> for MapKey<'a, R> 2196 + impl<'de, R> de::Deserializer<'de> for MapKey<'_, R> | warning: the following explicit lifetimes could be elided: 'a --> src/error.rs:467:6 | 467 | impl<'a> Display for JsonUnexpected<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 467 - impl<'a> Display for JsonUnexpected<'a> { 467 + impl Display for JsonUnexpected<'_> { | warning: the following explicit lifetimes could be elided: 'de --> src/map.rs:601:6 | 601 | impl<'de> de::IntoDeserializer<'de, Error> for Map { | ^^^ ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 601 - impl<'de> de::IntoDeserializer<'de, Error> for Map { 601 + impl de::IntoDeserializer<'_, Error> for Map { | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:31:6 | 31 | impl<'a, W> Serializer> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 31 - impl<'a, W> Serializer> 31 + impl Serializer> | warning: the following explicit lifetimes could be elided: 'ser --> src/ser.rs:420:14 | 420 | impl<'ser, W, F> Write for Adapter<'ser, W, F> | ^^^^ ^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 420 - impl<'ser, W, F> Write for Adapter<'ser, W, F> 420 + impl Write for Adapter<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:480:6 | 480 | impl<'a, W, F> ser::SerializeSeq for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 480 - impl<'a, W, F> ser::SerializeSeq for Compound<'a, W, F> 480 + impl ser::SerializeSeq for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:527:6 | 527 | impl<'a, W, F> ser::SerializeTuple for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 527 - impl<'a, W, F> ser::SerializeTuple for Compound<'a, W, F> 527 + impl ser::SerializeTuple for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:549:6 | 549 | impl<'a, W, F> ser::SerializeTupleStruct for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 549 - impl<'a, W, F> ser::SerializeTupleStruct for Compound<'a, W, F> 549 + impl ser::SerializeTupleStruct for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:571:6 | 571 | impl<'a, W, F> ser::SerializeTupleVariant for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 571 - impl<'a, W, F> ser::SerializeTupleVariant for Compound<'a, W, F> 571 + impl ser::SerializeTupleVariant for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:609:6 | 609 | impl<'a, W, F> ser::SerializeMap for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 609 - impl<'a, W, F> ser::SerializeMap for Compound<'a, W, F> 609 + impl ser::SerializeMap for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:681:6 | 681 | impl<'a, W, F> ser::SerializeStruct for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 681 - impl<'a, W, F> ser::SerializeStruct for Compound<'a, W, F> 681 + impl ser::SerializeStruct for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:727:6 | 727 | impl<'a, W, F> ser::SerializeStructVariant for Compound<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 727 - impl<'a, W, F> ser::SerializeStructVariant for Compound<'a, W, F> 727 + impl ser::SerializeStructVariant for Compound<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:793:6 | 793 | impl<'a, W, F> ser::Serializer for MapKeySerializer<'a, W, F> | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 793 - impl<'a, W, F> ser::Serializer for MapKeySerializer<'a, W, F> 793 + impl ser::Serializer for MapKeySerializer<'_, W, F> | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:1979:6 | 1979 | impl<'a> Default for PrettyFormatter<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 1979 - impl<'a> Default for PrettyFormatter<'a> { 1979 + impl Default for PrettyFormatter<'_> { | warning: the following explicit lifetimes could be elided: 'a --> src/ser.rs:1985:6 | 1985 | impl<'a> Formatter for PrettyFormatter<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 1985 - impl<'a> Formatter for PrettyFormatter<'a> { 1985 + impl Formatter for PrettyFormatter<'_> { | warning: the following explicit lifetimes could be elided: 'a, 'b --> src/value/mod.rs:227:14 | 227 | impl<'a, 'b> io::Write for WriterFormatter<'a, 'b> { | ^^ ^^ ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 227 - impl<'a, 'b> io::Write for WriterFormatter<'a, 'b> { 227 + impl io::Write for WriterFormatter<'_, '_> { | warning: the following explicit lifetimes could be elided: 'de --> src/value/de.rs:526:6 | 526 | impl<'de> IntoDeserializer<'de, Error> for Value { | ^^^ ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 526 - impl<'de> IntoDeserializer<'de, Error> for Value { 526 + impl IntoDeserializer<'_, Error> for Value { | warning: the following explicit lifetimes could be elided: 'de --> src/value/de.rs:1343:6 | 1343 | impl<'de> Visitor<'de> for KeyClassifier { | ^^^ ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 1343 - impl<'de> Visitor<'de> for KeyClassifier { 1343 + impl Visitor<'_> for KeyClassifier { | warning: the following explicit lifetimes could be elided: 'a --> src/value/index.rs:146:6 | 146 | impl<'a> Display for Type<'a> { | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 146 - impl<'a> Display for Type<'a> { 146 + impl Display for Type<'_> { | warning: the following explicit lifetimes could be elided: 'de --> src/number.rs:403:14 | 403 | impl<'de> Visitor<'de> for NumberVisitor { | ^^^ ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 403 - impl<'de> Visitor<'de> for NumberVisitor { 403 + impl Visitor<'_> for NumberVisitor { | warning: the following explicit lifetimes could be elided: 'b, 'c --> src/read.rs:132:6 | 132 | impl<'b, 'c, T> Deref for Reference<'b, 'c, T> | ^^ ^^ ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 132 - impl<'b, 'c, T> Deref for Reference<'b, 'c, T> 132 + impl Deref for Reference<'_, '_, T> | warning: the following explicit lifetimes could be elided: 'a --> src/read.rs:541:6 | 541 | impl<'a> private::Sealed for SliceRead<'a> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 541 - impl<'a> private::Sealed for SliceRead<'a> {} 541 + impl private::Sealed for SliceRead<'_> {} | warning: the following explicit lifetimes could be elided: 'a --> src/read.rs:679:6 | 679 | impl<'a> private::Sealed for StrRead<'a> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 679 - impl<'a> private::Sealed for StrRead<'a> {} 679 + impl private::Sealed for StrRead<'_> {} | warning: the following explicit lifetimes could be elided: 'a --> src/read.rs:833:6 | 833 | impl<'a> Fused for SliceRead<'a> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 833 - impl<'a> Fused for SliceRead<'a> {} 833 + impl Fused for SliceRead<'_> {} | warning: the following explicit lifetimes could be elided: 'a --> src/read.rs:834:6 | 834 | impl<'a> Fused for StrRead<'a> {} | ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names help: elide the lifetimes | 834 - impl<'a> Fused for StrRead<'a> {} 834 + impl Fused for StrRead<'_> {} | warning: the following explicit lifetimes could be elided: 'de --> tests/regression/issue845.rs:12:6 | 12 | impl<'de, T> serde::de::Visitor<'de> for NumberVisitor | ^^^ ^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#elidable_lifetime_names = note: `-W clippy::elidable-lifetime-names` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::elidable_lifetime_names)]` help: elide the lifetimes | 12 - impl<'de, T> serde::de::Visitor<'de> for NumberVisitor 12 + impl serde::de::Visitor<'_> for NumberVisitor | --- src/lib.rs | 1 + tests/regression.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 5aff596db..a8d5e68cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -306,6 +306,7 @@ clippy::comparison_chain, clippy::deprecated_cfg_attr, clippy::doc_markdown, + clippy::elidable_lifetime_names, clippy::excessive_precision, clippy::explicit_auto_deref, clippy::float_cmp, diff --git a/tests/regression.rs b/tests/regression.rs index 22cca8243..315bb1545 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -1,4 +1,4 @@ -#![allow(clippy::needless_lifetimes)] +#![allow(clippy::elidable_lifetime_names, clippy::needless_lifetimes)] mod regression { automod::dir!("tests/regression"); From f7200c3cf66b0c46e19a911a2b9121e27c101fec Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 3 Mar 2025 00:03:59 -0800 Subject: [PATCH 16/18] Ignore unbuffered_bytes clippy lint warning: calling .bytes() is very inefficient when data is not in memory --> src/read.rs:202:40 | 202 | iter: LineColIterator::new(reader.bytes()), | ^^^^^^^^^^^^^^ | = help: consider using `BufReader` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unbuffered_bytes = note: `-W clippy::unbuffered-bytes` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::unbuffered_bytes)]` --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index a8d5e68cd..7edda2659 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -318,6 +318,7 @@ clippy::needless_lifetimes, clippy::return_self_not_must_use, clippy::transmute_ptr_to_ptr, + clippy::unbuffered_bytes, clippy::unconditional_recursion, // https://github.com/rust-lang/rust-clippy/issues/12133 clippy::unnecessary_wraps )] From b34d317089ef43f6d35306be06018b8d87eeb2b5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 3 Mar 2025 00:46:01 -0800 Subject: [PATCH 17/18] Delete unused gcc installation --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 387322431..77d611a09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,10 +106,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@miri - - run: sudo apt-get install gcc-powerpc-linux-gnu - if: matrix.target == 'powerpc64-unknown-linux-gnu' - - run: sudo apt-get install gcc-mips-linux-gnu - if: matrix.target == 'mips-unknown-linux-gnu' - run: cargo miri setup - run: cargo miri test --target ${{matrix.target}} - run: cargo miri test --target ${{matrix.target}} --features preserve_order,float_roundtrip,arbitrary_precision,raw_value From 762783414e6c4f8d670c9d87eb04913efb80d3be Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 3 Mar 2025 01:04:12 -0800 Subject: [PATCH 18/18] Release 1.0.140 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf4ee4353..866c31318 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serde_json" -version = "1.0.139" +version = "1.0.140" authors = ["Erick Tryzelaar ", "David Tolnay "] categories = ["encoding", "parser-implementations", "no-std"] description = "A JSON serialization file format" diff --git a/src/lib.rs b/src/lib.rs index 7edda2659..a9f82f2b3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,7 +299,7 @@ //! [macro]: crate::json //! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.139")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.140")] // Ignored clippy lints #![allow( clippy::collapsible_else_if,