From 1174c5f57db44c26460951b525c6ede50984b655 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 29 Jan 2025 18:20:13 -0800 Subject: [PATCH 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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,