From 93509279039fde4cabc054870d24e7467f34c3d4 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 27 Jul 2023 22:27:52 -0700 Subject: [PATCH 01/12] Delete support for compilers without std::collections::Bound --- serde/build.rs | 3 --- serde/src/de/impls.rs | 2 +- serde/src/lib.rs | 2 +- serde/src/ser/impls.rs | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index 929d8e172..0f363c954 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -21,9 +21,6 @@ fn main() { // https://doc.rust-lang.org/core/ops/enum.Bound.html if minor < 26 { println!("cargo:rustc-cfg=no_ops_bound"); - if minor < 17 { - println!("cargo:rustc-cfg=no_collections_bound"); - } } // core::cmp::Reverse stabilized in Rust 1.19: diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 12fbdfdb3..44fa36691 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -2709,7 +2709,7 @@ mod range_to { //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))] +#[cfg(any(not(no_ops_bound), feature = "std"))] impl<'de, T> Deserialize<'de> for Bound where T: Deserialize<'de>, diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 30c5e4d60..66fba92b8 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -249,7 +249,7 @@ mod lib { #[cfg(feature = "std")] pub use std::time::{SystemTime, UNIX_EPOCH}; - #[cfg(all(feature = "std", not(no_collections_bound), no_ops_bound))] + #[cfg(all(feature = "std", no_ops_bound))] pub use std::collections::Bound; #[cfg(not(no_core_reverse))] diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 9cafb3264..5eb8f3deb 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -310,7 +310,7 @@ where //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(not(no_ops_bound), all(feature = "std", not(no_collections_bound))))] +#[cfg(any(not(no_ops_bound), feature = "std"))] impl Serialize for Bound where T: Serialize, From 9a0e14922580de424e2de37974a004cb936a1f74 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 27 Jul 2023 22:35:08 -0700 Subject: [PATCH 02/12] Sort version checks in build.rs --- serde/build.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index 0f363c954..112281583 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,13 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // std::collections::Bound was stabilized in Rust 1.17 - // but it was moved to core::ops later in Rust 1.26: - // https://doc.rust-lang.org/core/ops/enum.Bound.html - if minor < 26 { - println!("cargo:rustc-cfg=no_ops_bound"); - } - // core::cmp::Reverse stabilized in Rust 1.19: // https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html if minor < 19 { @@ -50,6 +43,13 @@ fn main() { println!("cargo:rustc-cfg=no_core_duration"); } + // std::collections::Bound was stabilized in Rust 1.17 + // but it was moved to core::ops later in Rust 1.26: + // https://doc.rust-lang.org/core/ops/enum.Bound.html + if minor < 26 { + println!("cargo:rustc-cfg=no_ops_bound"); + } + // 128-bit integers stabilized in Rust 1.26: // https://blog.rust-lang.org/2018/05/10/Rust-1.26.html // From a100719bc6c9fd3c823f0914a928e0bef19fb3ae Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 27 Jul 2023 22:30:30 -0700 Subject: [PATCH 03/12] Delete support for compilers without core::cmp::Reverse --- serde/build.rs | 6 ------ serde/src/de/impls.rs | 1 - serde/src/lib.rs | 4 +--- serde/src/ser/impls.rs | 1 - 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index 112281583..66f3b6edb 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,12 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // core::cmp::Reverse stabilized in Rust 1.19: - // https://doc.rust-lang.org/stable/core/cmp/struct.Reverse.html - if minor < 19 { - println!("cargo:rustc-cfg=no_core_reverse"); - } - // CString::into_boxed_c_str and PathBuf::into_boxed_path stabilized in Rust 1.20: // https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str // https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 44fa36691..5dba42b26 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -753,7 +753,6 @@ macro_rules! forwarded_impl { ))] forwarded_impl!((), Box, CString::into_boxed_c_str); -#[cfg(not(no_core_reverse))] forwarded_impl!((T), Reverse, Reverse); //////////////////////////////////////////////////////////////////////////////// diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 66fba92b8..a8e568832 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -177,6 +177,7 @@ mod lib { pub use self::core::cell::{Cell, RefCell}; pub use self::core::clone::{self, Clone}; + pub use self::core::cmp::Reverse; pub use self::core::convert::{self, From, Into}; pub use self::core::default::{self, Default}; pub use self::core::fmt::{self, Debug, Display}; @@ -252,9 +253,6 @@ mod lib { #[cfg(all(feature = "std", no_ops_bound))] pub use std::collections::Bound; - #[cfg(not(no_core_reverse))] - pub use self::core::cmp::Reverse; - #[cfg(not(no_ops_bound))] pub use self::core::ops::Bound; diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 5eb8f3deb..541acf2d6 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -963,7 +963,6 @@ where } } -#[cfg(not(no_core_reverse))] impl Serialize for Reverse where T: Serialize, From c91737fef1e107c7041c568cfe8e4d4eb65ca6ff Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 27 Jul 2023 22:32:00 -0700 Subject: [PATCH 04/12] Delete support for compilers without CString::into_boxed_c_str --- .github/workflows/ci.yml | 2 +- README.md | 6 +++--- serde/Cargo.toml | 2 +- serde/build.rs | 4 +--- serde/src/de/impls.rs | 5 +---- 5 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3450b7705..a3dea2e2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [1.19.0, 1.20.0, 1.21.0, 1.25.0, 1.26.0, 1.34.0] + rust: [1.20.0, 1.21.0, 1.25.0, 1.26.0, 1.34.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index a049250b6..387a218d0 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.19+]][Rust 1.19] [![serde_derive: rustc 1.56+]][Rust 1.56] +# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.20+]][Rust 1.20] [![serde_derive: rustc 1.56+]][Rust 1.56] [Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master [actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster [Latest Version]: https://img.shields.io/crates/v/serde.svg [crates.io]: https://crates.io/crates/serde -[serde: rustc 1.19+]: https://img.shields.io/badge/serde-rustc_1.19+-lightgray.svg +[serde: rustc 1.20+]: https://img.shields.io/badge/serde-rustc_1.20+-lightgray.svg [serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg -[Rust 1.19]: https://blog.rust-lang.org/2017/07/20/Rust-1.19.html +[Rust 1.20]: https://blog.rust-lang.org/2017/08/31/Rust-1.20.html [Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** diff --git a/serde/Cargo.toml b/serde/Cargo.toml index b9959cf02..b752f4075 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std"] license = "MIT OR Apache-2.0" readme = "crates-io.md" repository = "https://github.com/serde-rs/serde" -rust-version = "1.19" +rust-version = "1.20" [dependencies] serde_derive = { version = "=1.0.179", optional = true, path = "../serde_derive" } diff --git a/serde/build.rs b/serde/build.rs index 66f3b6edb..7a5ce83af 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,11 +16,9 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // CString::into_boxed_c_str and PathBuf::into_boxed_path stabilized in Rust 1.20: - // https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_boxed_c_str + // PathBuf::into_boxed_path stabilized in Rust 1.20: // https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path if minor < 20 { - println!("cargo:rustc-cfg=no_de_boxed_c_str"); println!("cargo:rustc-cfg=no_de_boxed_path"); } diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 5dba42b26..b362a216a 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -747,10 +747,7 @@ macro_rules! forwarded_impl { } } -#[cfg(all( - any(feature = "std", all(not(no_core_cstr), feature = "alloc")), - not(no_de_boxed_c_str) -))] +#[cfg(any(feature = "std", all(not(no_core_cstr), feature = "alloc")))] forwarded_impl!((), Box, CString::into_boxed_c_str); forwarded_impl!((T), Reverse, Reverse); From 89976c2712c5e60a6da0d6e094a0977f111bc6dd Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 27 Jul 2023 22:36:48 -0700 Subject: [PATCH 05/12] Delete support for compilers without PathBuf::into_boxed_path --- serde/build.rs | 6 ------ serde/src/de/impls.rs | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index 7a5ce83af..da960fd8b 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,12 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // PathBuf::into_boxed_path stabilized in Rust 1.20: - // https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.into_boxed_path - if minor < 20 { - println!("cargo:rustc-cfg=no_de_boxed_path"); - } - // From> for Rc / Arc stabilized in Rust 1.21: // https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From> // https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From> diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index b362a216a..959295d1d 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1710,7 +1710,7 @@ impl<'de> Deserialize<'de> for PathBuf { } } -#[cfg(all(feature = "std", not(no_de_boxed_path)))] +#[cfg(feature = "std")] forwarded_impl!((), Box, PathBuf::into_boxed_path); //////////////////////////////////////////////////////////////////////////////// From 27c8b2d66a7d6e92f48abea257dc6d451ea533f9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 27 Jul 2023 22:38:04 -0700 Subject: [PATCH 06/12] Delete support for compilers without dynamically sized Rc construction --- .github/workflows/ci.yml | 2 +- README.md | 6 +++--- serde/Cargo.toml | 2 +- serde/build.rs | 7 ------- serde/src/de/impls.rs | 42 +++------------------------------------- 5 files changed, 8 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3dea2e2b..c5946877a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [1.20.0, 1.21.0, 1.25.0, 1.26.0, 1.34.0] + rust: [1.21.0, 1.25.0, 1.26.0, 1.34.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 387a218d0..234481b65 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.20+]][Rust 1.20] [![serde_derive: rustc 1.56+]][Rust 1.56] +# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.21+]][Rust 1.21] [![serde_derive: rustc 1.56+]][Rust 1.56] [Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master [actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster [Latest Version]: https://img.shields.io/crates/v/serde.svg [crates.io]: https://crates.io/crates/serde -[serde: rustc 1.20+]: https://img.shields.io/badge/serde-rustc_1.20+-lightgray.svg +[serde: rustc 1.21+]: https://img.shields.io/badge/serde-rustc_1.21+-lightgray.svg [serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg -[Rust 1.20]: https://blog.rust-lang.org/2017/08/31/Rust-1.20.html +[Rust 1.21]: https://blog.rust-lang.org/2017/10/12/Rust-1.21.html [Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** diff --git a/serde/Cargo.toml b/serde/Cargo.toml index b752f4075..2fd979204 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std"] license = "MIT OR Apache-2.0" readme = "crates-io.md" repository = "https://github.com/serde-rs/serde" -rust-version = "1.20" +rust-version = "1.21" [dependencies] serde_derive = { version = "=1.0.179", optional = true, path = "../serde_derive" } diff --git a/serde/build.rs b/serde/build.rs index da960fd8b..9c7748008 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,13 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // From> for Rc / Arc stabilized in Rust 1.21: - // https://doc.rust-lang.org/std/rc/struct.Rc.html#impl-From> - // https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-From> - if minor < 21 { - println!("cargo:rustc-cfg=no_de_rc_dst"); - } - // Duration available in core since Rust 1.25: // https://blog.rust-lang.org/2018/03/29/Rust-1.25.html#library-stabilizations if minor < 25 { diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 959295d1d..cfac35185 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1791,30 +1791,6 @@ forwarded_impl!((T), Box<[T]>, Vec::into_boxed_slice); #[cfg(any(feature = "std", feature = "alloc"))] forwarded_impl!((), Box, String::into_boxed_str); -#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] -forwarded_impl! { - /// This impl requires the [`"rc"`] Cargo feature of Serde. - /// - /// Deserializing a data structure containing `Arc` will not attempt to - /// deduplicate `Arc` references to the same data. Every deserialized `Arc` - /// will end up with a strong count of 1. - /// - /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc - (T), Arc, Arc::new -} - -#[cfg(all(no_de_rc_dst, feature = "rc", any(feature = "std", feature = "alloc")))] -forwarded_impl! { - /// This impl requires the [`"rc"`] Cargo feature of Serde. - /// - /// Deserializing a data structure containing `Rc` will not attempt to - /// deduplicate `Rc` references to the same data. Every deserialized `Rc` - /// will end up with a strong count of 1. - /// - /// [`"rc"`]: https://serde.rs/feature-flags.html#-features-rc - (T), Rc, Rc::new -} - #[cfg(any(feature = "std", feature = "alloc"))] impl<'de, 'a, T: ?Sized> Deserialize<'de> for Cow<'a, T> where @@ -1870,11 +1846,7 @@ where //////////////////////////////////////////////////////////////////////////////// -#[cfg(all( - not(no_de_rc_dst), - feature = "rc", - any(feature = "std", feature = "alloc") -))] +#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] macro_rules! box_forwarded_impl { ( $(#[doc = $doc:tt])* @@ -1895,11 +1867,7 @@ macro_rules! box_forwarded_impl { }; } -#[cfg(all( - not(no_de_rc_dst), - feature = "rc", - any(feature = "std", feature = "alloc") -))] +#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] box_forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// @@ -1911,11 +1879,7 @@ box_forwarded_impl! { Rc } -#[cfg(all( - not(no_de_rc_dst), - feature = "rc", - any(feature = "std", feature = "alloc") -))] +#[cfg(all(feature = "rc", any(feature = "std", feature = "alloc")))] box_forwarded_impl! { /// This impl requires the [`"rc"`] Cargo feature of Serde. /// From 4f59cd217a13311916cbcdee99cea7e34a509d75 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 30 Jul 2023 20:51:55 -0700 Subject: [PATCH 07/12] Delete support for compilers without core::time --- .github/workflows/ci.yml | 2 +- README.md | 6 +++--- serde/Cargo.toml | 2 +- serde/build.rs | 6 ------ serde/src/de/impls.rs | 7 ++----- serde/src/lib.rs | 4 +--- serde/src/ser/impls.rs | 1 - 7 files changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5946877a..0275ea878 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [1.21.0, 1.25.0, 1.26.0, 1.34.0] + rust: [1.25.0, 1.26.0, 1.34.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 234481b65..74e0ee988 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.21+]][Rust 1.21] [![serde_derive: rustc 1.56+]][Rust 1.56] +# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.25+]][Rust 1.25] [![serde_derive: rustc 1.56+]][Rust 1.56] [Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master [actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster [Latest Version]: https://img.shields.io/crates/v/serde.svg [crates.io]: https://crates.io/crates/serde -[serde: rustc 1.21+]: https://img.shields.io/badge/serde-rustc_1.21+-lightgray.svg +[serde: rustc 1.25+]: https://img.shields.io/badge/serde-rustc_1.25+-lightgray.svg [serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg -[Rust 1.21]: https://blog.rust-lang.org/2017/10/12/Rust-1.21.html +[Rust 1.25]: https://blog.rust-lang.org/2018/03/29/Rust-1.25.html [Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 2fd979204..53e4d414d 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std"] license = "MIT OR Apache-2.0" readme = "crates-io.md" repository = "https://github.com/serde-rs/serde" -rust-version = "1.21" +rust-version = "1.25" [dependencies] serde_derive = { version = "=1.0.179", optional = true, path = "../serde_derive" } diff --git a/serde/build.rs b/serde/build.rs index 9c7748008..fd03d042b 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,12 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // Duration available in core since Rust 1.25: - // https://blog.rust-lang.org/2018/03/29/Rust-1.25.html#library-stabilizations - if minor < 25 { - println!("cargo:rustc-cfg=no_core_duration"); - } - // std::collections::Bound was stabilized in Rust 1.17 // but it was moved to core::ops later in Rust 1.26: // https://doc.rust-lang.org/core/ops/enum.Bound.html diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index cfac35185..0102a7ab9 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1,12 +1,10 @@ use lib::*; use de::{ - Deserialize, Deserializer, EnumAccess, Error, SeqAccess, Unexpected, VariantAccess, Visitor, + Deserialize, Deserializer, EnumAccess, Error, MapAccess, SeqAccess, Unexpected, VariantAccess, + Visitor, }; -#[cfg(any(feature = "std", feature = "alloc", not(no_core_duration)))] -use de::MapAccess; - use seed::InPlaceSeed; #[cfg(any(feature = "std", feature = "alloc"))] @@ -1923,7 +1921,6 @@ forwarded_impl!((T), RwLock, RwLock::new); // secs: u64, // nanos: u32, // } -#[cfg(any(feature = "std", not(no_core_duration)))] impl<'de> Deserialize<'de> for Duration { fn deserialize(deserializer: D) -> Result where diff --git a/serde/src/lib.rs b/serde/src/lib.rs index a8e568832..0ef1b6c59 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -186,6 +186,7 @@ mod lib { pub use self::core::ops::{Range, RangeFrom, RangeTo}; pub use self::core::option::{self, Option}; pub use self::core::result::{self, Result}; + pub use self::core::time::Duration; #[cfg(all(feature = "alloc", not(feature = "std")))] pub use alloc::borrow::{Cow, ToOwned}; @@ -279,9 +280,6 @@ mod lib { pub use std::sync::atomic::{AtomicI64, AtomicU64}; #[cfg(all(feature = "std", not(no_target_has_atomic), target_has_atomic = "ptr"))] pub use std::sync::atomic::{AtomicIsize, AtomicUsize}; - - #[cfg(any(feature = "std", not(no_core_duration)))] - pub use self::core::time::Duration; } // None of this crate's error handling needs the `From::from` error conversion diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 541acf2d6..9469e7145 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -662,7 +662,6 @@ where //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(feature = "std", not(no_core_duration)))] impl Serialize for Duration { fn serialize(&self, serializer: S) -> Result where From 1b14cadf20fb85d5689fe8046a5356e2f7979055 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 30 Jul 2023 20:55:29 -0700 Subject: [PATCH 08/12] Delete support for compilers without core::ops::Bound --- .github/workflows/ci.yml | 2 +- README.md | 6 +++--- serde/Cargo.toml | 2 +- serde/build.rs | 7 ------- serde/src/de/impls.rs | 1 - serde/src/lib.rs | 8 +------- serde/src/ser/impls.rs | 1 - 7 files changed, 6 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0275ea878..6b67dbe30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -77,7 +77,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [1.25.0, 1.26.0, 1.34.0] + rust: [1.26.0, 1.34.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 74e0ee988..0ad018e3e 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.25+]][Rust 1.25] [![serde_derive: rustc 1.56+]][Rust 1.56] +# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.26+]][Rust 1.26] [![serde_derive: rustc 1.56+]][Rust 1.56] [Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master [actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster [Latest Version]: https://img.shields.io/crates/v/serde.svg [crates.io]: https://crates.io/crates/serde -[serde: rustc 1.25+]: https://img.shields.io/badge/serde-rustc_1.25+-lightgray.svg +[serde: rustc 1.26+]: https://img.shields.io/badge/serde-rustc_1.26+-lightgray.svg [serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg -[Rust 1.25]: https://blog.rust-lang.org/2018/03/29/Rust-1.25.html +[Rust 1.26]: https://blog.rust-lang.org/2018/05/10/Rust-1.26.html [Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 53e4d414d..65d59b497 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std"] license = "MIT OR Apache-2.0" readme = "crates-io.md" repository = "https://github.com/serde-rs/serde" -rust-version = "1.25" +rust-version = "1.26" [dependencies] serde_derive = { version = "=1.0.179", optional = true, path = "../serde_derive" } diff --git a/serde/build.rs b/serde/build.rs index fd03d042b..1eab424f8 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,13 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // std::collections::Bound was stabilized in Rust 1.17 - // but it was moved to core::ops later in Rust 1.26: - // https://doc.rust-lang.org/core/ops/enum.Bound.html - if minor < 26 { - println!("cargo:rustc-cfg=no_ops_bound"); - } - // 128-bit integers stabilized in Rust 1.26: // https://blog.rust-lang.org/2018/05/10/Rust-1.26.html // diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 0102a7ab9..acb251f7e 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -2666,7 +2666,6 @@ mod range_to { //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(not(no_ops_bound), feature = "std"))] impl<'de, T> Deserialize<'de> for Bound where T: Deserialize<'de>, diff --git a/serde/src/lib.rs b/serde/src/lib.rs index 0ef1b6c59..ec4e1ba12 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -183,7 +183,7 @@ mod lib { pub use self::core::fmt::{self, Debug, Display}; pub use self::core::marker::{self, PhantomData}; pub use self::core::num::Wrapping; - pub use self::core::ops::{Range, RangeFrom, RangeTo}; + pub use self::core::ops::{Bound, Range, RangeFrom, RangeTo}; pub use self::core::option::{self, Option}; pub use self::core::result::{self, Result}; pub use self::core::time::Duration; @@ -251,12 +251,6 @@ mod lib { #[cfg(feature = "std")] pub use std::time::{SystemTime, UNIX_EPOCH}; - #[cfg(all(feature = "std", no_ops_bound))] - pub use std::collections::Bound; - - #[cfg(not(no_ops_bound))] - pub use self::core::ops::Bound; - #[cfg(not(no_range_inclusive))] pub use self::core::ops::RangeInclusive; diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 9469e7145..c2f9e78b8 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -310,7 +310,6 @@ where //////////////////////////////////////////////////////////////////////////////// -#[cfg(any(not(no_ops_bound), feature = "std"))] impl Serialize for Bound where T: Serialize, From e77900fb94211b4372dd7bd2ac979ff660a7ff53 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 30 Jul 2023 20:58:16 -0700 Subject: [PATCH 09/12] Update integer128 case in build script --- serde/build.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index 1eab424f8..48e52893f 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,16 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // 128-bit integers stabilized in Rust 1.26: - // https://blog.rust-lang.org/2018/05/10/Rust-1.26.html - // - // Disabled on Emscripten targets before Rust 1.40 since - // Emscripten did not support 128-bit integers until Rust 1.40 - // (https://github.com/rust-lang/rust/pull/65251) - if minor < 26 || emscripten && minor < 40 { - println!("cargo:rustc-cfg=no_integer128"); - } - // Inclusive ranges methods stabilized in Rust 1.27: // https://github.com/rust-lang/rust/pull/50758 // Also Iterator::try_for_each: @@ -52,6 +42,13 @@ fn main() { println!("cargo:rustc-cfg=no_relaxed_trait_bounds"); } + // Disabled on Emscripten targets before Rust 1.40 since + // Emscripten did not support 128-bit integers until Rust 1.40 + // (https://github.com/rust-lang/rust/pull/65251) + if emscripten && minor < 40 { + println!("cargo:rustc-cfg=no_integer128"); + } + // Current minimum supported version of serde_derive crate is Rust 1.56. if minor < 56 { println!("cargo:rustc-cfg=no_serde_derive"); From 4dcf7917067d53d7b9b6a3846bfca90e8eec9fec Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 30 Jul 2023 20:59:38 -0700 Subject: [PATCH 10/12] Delete support for compilers without inclusive range accessors --- .github/workflows/ci.yml | 10 ++-------- README.md | 6 +++--- serde/Cargo.toml | 2 +- serde/build.rs | 5 +---- serde/src/de/impls.rs | 1 - serde/src/lib.rs | 5 +---- serde/src/ser/impls.rs | 1 - 7 files changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b67dbe30..cc9a693ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,18 +72,12 @@ jobs: if: matrix.os != 'windows' build: - name: Rust ${{matrix.rust}} + name: Rust 1.34.0 runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - rust: [1.26.0, 1.34.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{matrix.rust}} + - uses: dtolnay/rust-toolchain@1.34.0 - run: cd serde && cargo build --features rc - run: cd serde && cargo build --no-default-features - run: cd serde && cargo build diff --git a/README.md b/README.md index 0ad018e3e..6109fdf70 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.26+]][Rust 1.26] [![serde_derive: rustc 1.56+]][Rust 1.56] +# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.27+]][Rust 1.27] [![serde_derive: rustc 1.56+]][Rust 1.56] [Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master [actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster [Latest Version]: https://img.shields.io/crates/v/serde.svg [crates.io]: https://crates.io/crates/serde -[serde: rustc 1.26+]: https://img.shields.io/badge/serde-rustc_1.26+-lightgray.svg +[serde: rustc 1.27+]: https://img.shields.io/badge/serde-rustc_1.27+-lightgray.svg [serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg -[Rust 1.26]: https://blog.rust-lang.org/2018/05/10/Rust-1.26.html +[Rust 1.27]: https://blog.rust-lang.org/2018/06/21/Rust-1.27.html [Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 65d59b497..6d7a849e7 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std"] license = "MIT OR Apache-2.0" readme = "crates-io.md" repository = "https://github.com/serde-rs/serde" -rust-version = "1.26" +rust-version = "1.27" [dependencies] serde_derive = { version = "=1.0.179", optional = true, path = "../serde_derive" } diff --git a/serde/build.rs b/serde/build.rs index 48e52893f..ecbb96a6f 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,12 +16,9 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // Inclusive ranges methods stabilized in Rust 1.27: - // https://github.com/rust-lang/rust/pull/50758 - // Also Iterator::try_for_each: + // Iterator::try_for_each stabilized in Rust 1.27: // https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations if minor < 27 { - println!("cargo:rustc-cfg=no_range_inclusive"); println!("cargo:rustc-cfg=no_iterator_try_fold"); } diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index acb251f7e..124251def 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -2238,7 +2238,6 @@ where } } -#[cfg(not(no_range_inclusive))] impl<'de, Idx> Deserialize<'de> for RangeInclusive where Idx: Deserialize<'de>, diff --git a/serde/src/lib.rs b/serde/src/lib.rs index ec4e1ba12..ea0fa4726 100644 --- a/serde/src/lib.rs +++ b/serde/src/lib.rs @@ -183,7 +183,7 @@ mod lib { pub use self::core::fmt::{self, Debug, Display}; pub use self::core::marker::{self, PhantomData}; pub use self::core::num::Wrapping; - pub use self::core::ops::{Bound, Range, RangeFrom, RangeTo}; + pub use self::core::ops::{Bound, Range, RangeFrom, RangeInclusive, RangeTo}; pub use self::core::option::{self, Option}; pub use self::core::result::{self, Result}; pub use self::core::time::Duration; @@ -251,9 +251,6 @@ mod lib { #[cfg(feature = "std")] pub use std::time::{SystemTime, UNIX_EPOCH}; - #[cfg(not(no_range_inclusive))] - pub use self::core::ops::RangeInclusive; - #[cfg(all(feature = "std", no_target_has_atomic, not(no_std_atomic)))] pub use std::sync::atomic::{ AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicU16, AtomicU32, AtomicU8, diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index c2f9e78b8..f856b6c0a 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -274,7 +274,6 @@ where //////////////////////////////////////////////////////////////////////////////// -#[cfg(not(no_range_inclusive))] impl Serialize for RangeInclusive where Idx: Serialize, From 92e91b35578780a30fcec0feabc7dafc7e2a2dbc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 30 Jul 2023 21:03:28 -0700 Subject: [PATCH 11/12] Delete support for compilers without Iterator::try_for_each --- serde/build.rs | 6 ------ serde/src/ser/mod.rs | 34 ++++------------------------------ 2 files changed, 4 insertions(+), 36 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index ecbb96a6f..e76ac2368 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,12 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // Iterator::try_for_each stabilized in Rust 1.27: - // https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#library-stabilizations - if minor < 27 { - println!("cargo:rustc-cfg=no_iterator_try_fold"); - } - // Non-zero integers stabilized in Rust 1.28: // https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations if minor < 28 { diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index 1aaa7570f..d1a70ddb0 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -1279,22 +1279,9 @@ pub trait Serializer: Sized { I: IntoIterator, ::Item: Serialize, { - let iter = iter.into_iter(); + let mut iter = iter.into_iter(); let mut serializer = try!(self.serialize_seq(iterator_len_hint(&iter))); - - #[cfg(not(no_iterator_try_fold))] - { - let mut iter = iter; - try!(iter.try_for_each(|item| serializer.serialize_element(&item))); - } - - #[cfg(no_iterator_try_fold)] - { - for item in iter { - try!(serializer.serialize_element(&item)); - } - } - + try!(iter.try_for_each(|item| serializer.serialize_element(&item))); serializer.end() } @@ -1330,22 +1317,9 @@ pub trait Serializer: Sized { V: Serialize, I: IntoIterator, { - let iter = iter.into_iter(); + let mut iter = iter.into_iter(); let mut serializer = try!(self.serialize_map(iterator_len_hint(&iter))); - - #[cfg(not(no_iterator_try_fold))] - { - let mut iter = iter; - try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value))); - } - - #[cfg(no_iterator_try_fold)] - { - for (key, value) in iter { - try!(serializer.serialize_entry(&key, &value)); - } - } - + try!(iter.try_for_each(|(key, value)| serializer.serialize_entry(&key, &value))); serializer.end() } From a57a324d7254c282f6032f9a65044bb5da34c4e1 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 30 Jul 2023 21:05:06 -0700 Subject: [PATCH 12/12] Delete support for compilers without NonZero integer types --- .github/workflows/ci.yml | 10 ++-------- README.md | 6 +++--- serde/Cargo.toml | 2 +- serde/build.rs | 6 ------ serde/src/de/impls.rs | 2 +- serde/src/ser/impls.rs | 1 - 6 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc9a693ff..568b4d641 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,18 +83,12 @@ jobs: - run: cd serde && cargo build more: - name: Rust ${{matrix.rust}} + name: Rust 1.28.0 runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - rust: [1.27.0, 1.28.0] timeout-minutes: 45 steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{matrix.rust}} + - uses: dtolnay/rust-toolchain@1.28.0 # Work around failing to parse manifest because editions are unstable. - run: sed -i /test_suite/d Cargo.toml - run: cd serde && cargo build --no-default-features diff --git a/README.md b/README.md index 6109fdf70..19f0d3c43 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.27+]][Rust 1.27] [![serde_derive: rustc 1.56+]][Rust 1.56] +# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde: rustc 1.28+]][Rust 1.28] [![serde_derive: rustc 1.56+]][Rust 1.56] [Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master [actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster [Latest Version]: https://img.shields.io/crates/v/serde.svg [crates.io]: https://crates.io/crates/serde -[serde: rustc 1.27+]: https://img.shields.io/badge/serde-rustc_1.27+-lightgray.svg +[serde: rustc 1.28+]: https://img.shields.io/badge/serde-rustc_1.28+-lightgray.svg [serde_derive: rustc 1.56+]: https://img.shields.io/badge/serde_derive-rustc_1.56+-lightgray.svg -[Rust 1.27]: https://blog.rust-lang.org/2018/06/21/Rust-1.27.html +[Rust 1.28]: https://blog.rust-lang.org/2018/08/02/Rust-1.28.html [Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.** diff --git a/serde/Cargo.toml b/serde/Cargo.toml index 6d7a849e7..eba6c5b74 100644 --- a/serde/Cargo.toml +++ b/serde/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["serde", "serialization", "no_std"] license = "MIT OR Apache-2.0" readme = "crates-io.md" repository = "https://github.com/serde-rs/serde" -rust-version = "1.27" +rust-version = "1.28" [dependencies] serde_derive = { version = "=1.0.179", optional = true, path = "../serde_derive" } diff --git a/serde/build.rs b/serde/build.rs index e76ac2368..fb1cfa6d1 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -16,12 +16,6 @@ fn main() { let target = env::var("TARGET").unwrap(); let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten"; - // Non-zero integers stabilized in Rust 1.28: - // https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#library-stabilizations - if minor < 28 { - println!("cargo:rustc-cfg=no_num_nonzero"); - } - // TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add // stabilized in Rust 1.34: // https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 124251def..0dd039b3c 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -82,7 +82,7 @@ macro_rules! impl_deserialize_num { ($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => { impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*); - #[cfg(all(not(no_num_nonzero), $($($cfg)*)*))] + $(#[cfg($($cfg)*)])* impl<'de> Deserialize<'de> for num::$nonzero { fn deserialize(deserializer: D) -> Result where diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index f856b6c0a..72933909f 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -536,7 +536,6 @@ where macro_rules! nonzero_integers { ($($T:ident,)+) => { $( - #[cfg(not(no_num_nonzero))] impl Serialize for num::$T { fn serialize(&self, serializer: S) -> Result where