mirror of
https://github.com/serde-rs/serde.git
synced 2025-09-27 13:00:49 +00:00
Bump MSRV to 1.56
This is the first cargo version that actually enforces the rust-version field in Cargo.toml
This commit is contained in:
parent
49d098debd
commit
13a33b3c33
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
@ -84,7 +84,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
rust: [1.31.0, 1.34.0]
|
||||
rust: [1.56.0, 1.60.0]
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -94,6 +94,7 @@ jobs:
|
||||
- run: sed -i '/"test_suite"/d' Cargo.toml
|
||||
- run: cd serde && cargo build --features rc
|
||||
- run: cd serde && cargo build --no-default-features
|
||||
- run: cd serde && cargo build --no-default-features --features alloc
|
||||
- run: cd serde && cargo build
|
||||
|
||||
derive:
|
||||
@ -111,16 +112,6 @@ jobs:
|
||||
- run: cd serde && cargo check
|
||||
- run: cd serde_derive && cargo check
|
||||
|
||||
alloc:
|
||||
name: Rust 1.36.0
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.36.0
|
||||
- run: sed -i '/"test_suite"/d' Cargo.toml
|
||||
- run: cd serde && cargo build --no-default-features --features alloc
|
||||
|
||||
minimal:
|
||||
name: Minimal versions
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.31] [![serde_derive msrv]][Rust 1.61]
|
||||
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.56] [![serde_derive msrv]][Rust 1.61]
|
||||
|
||||
[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
|
||||
@ -6,7 +6,7 @@
|
||||
[crates.io]: https://crates.io/crates/serde
|
||||
[serde msrv]: https://img.shields.io/crates/msrv/serde.svg?label=serde%20msrv&color=lightgray
|
||||
[serde_derive msrv]: https://img.shields.io/crates/msrv/serde_derive.svg?label=serde_derive%20msrv&color=lightgray
|
||||
[Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
|
||||
[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
|
||||
[Rust 1.61]: https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html
|
||||
|
||||
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
|
||||
|
@ -12,7 +12,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.31"
|
||||
rust-version = "1.56"
|
||||
|
||||
[dependencies]
|
||||
serde_derive = { version = "1", optional = true, path = "../serde_derive" }
|
||||
|
@ -18,38 +18,17 @@ fn main() {
|
||||
println!("cargo:rustc-check-cfg=cfg(no_core_error)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_core_net)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_core_try_from)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_float_copysign)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_num_nonzero_signed)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_relaxed_trait_bounds)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_serde_derive)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_std_atomic)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)");
|
||||
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
|
||||
}
|
||||
|
||||
let target = env::var("TARGET").unwrap();
|
||||
let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten";
|
||||
|
||||
// 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
|
||||
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations
|
||||
if minor < 34 {
|
||||
println!("cargo:rustc-cfg=no_core_try_from");
|
||||
println!("cargo:rustc-cfg=no_num_nonzero_signed");
|
||||
println!("cargo:rustc-cfg=no_systemtime_checked_add");
|
||||
println!("cargo:rustc-cfg=no_relaxed_trait_bounds");
|
||||
}
|
||||
|
||||
// f32::copysign and f64::copysign stabilized in Rust 1.35.
|
||||
// https://blog.rust-lang.org/2019/05/23/Rust-1.35.0.html#copy-the-sign-of-a-floating-point-number-onto-another
|
||||
if minor < 35 {
|
||||
println!("cargo:rustc-cfg=no_float_copysign");
|
||||
}
|
||||
|
||||
// Support for #[cfg(target_has_atomic = "...")] stabilized in Rust 1.60.
|
||||
if minor < 60 {
|
||||
println!("cargo:rustc-cfg=no_target_has_atomic");
|
||||
|
@ -80,10 +80,9 @@ impl<'de> Deserialize<'de> for bool {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
macro_rules! impl_deserialize_num {
|
||||
($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
|
||||
($primitive:ident, $nonzero:ident, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
|
||||
impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*);
|
||||
|
||||
$(#[cfg($($cfg)*)])*
|
||||
impl<'de> Deserialize<'de> for num::$nonzero {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
@ -228,12 +227,12 @@ macro_rules! num_as_copysign_self {
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
#[cfg(any(no_float_copysign, not(feature = "std")))]
|
||||
#[cfg(not(feature = "std"))]
|
||||
{
|
||||
Ok(v as Self::Value)
|
||||
}
|
||||
|
||||
#[cfg(all(not(no_float_copysign), feature = "std"))]
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
// Preserve sign of NaN. The `as` produces a nondeterministic sign.
|
||||
let sign = if v.is_sign_positive() { 1.0 } else { -1.0 };
|
||||
@ -381,14 +380,14 @@ macro_rules! uint_to_self {
|
||||
}
|
||||
|
||||
impl_deserialize_num! {
|
||||
i8, NonZeroI8 cfg(not(no_num_nonzero_signed)), deserialize_i8
|
||||
i8, NonZeroI8, deserialize_i8
|
||||
num_self!(i8:visit_i8);
|
||||
int_to_int!(i16:visit_i16 i32:visit_i32 i64:visit_i64);
|
||||
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
|
||||
}
|
||||
|
||||
impl_deserialize_num! {
|
||||
i16, NonZeroI16 cfg(not(no_num_nonzero_signed)), deserialize_i16
|
||||
i16, NonZeroI16, deserialize_i16
|
||||
num_self!(i16:visit_i16);
|
||||
num_as_self!(i8:visit_i8);
|
||||
int_to_int!(i32:visit_i32 i64:visit_i64);
|
||||
@ -396,7 +395,7 @@ impl_deserialize_num! {
|
||||
}
|
||||
|
||||
impl_deserialize_num! {
|
||||
i32, NonZeroI32 cfg(not(no_num_nonzero_signed)), deserialize_i32
|
||||
i32, NonZeroI32, deserialize_i32
|
||||
num_self!(i32:visit_i32);
|
||||
num_as_self!(i8:visit_i8 i16:visit_i16);
|
||||
int_to_int!(i64:visit_i64);
|
||||
@ -404,14 +403,14 @@ impl_deserialize_num! {
|
||||
}
|
||||
|
||||
impl_deserialize_num! {
|
||||
i64, NonZeroI64 cfg(not(no_num_nonzero_signed)), deserialize_i64
|
||||
i64, NonZeroI64, deserialize_i64
|
||||
num_self!(i64:visit_i64);
|
||||
num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32);
|
||||
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
|
||||
}
|
||||
|
||||
impl_deserialize_num! {
|
||||
isize, NonZeroIsize cfg(not(no_num_nonzero_signed)), deserialize_i64
|
||||
isize, NonZeroIsize, deserialize_i64
|
||||
num_as_self!(i8:visit_i8 i16:visit_i16);
|
||||
int_to_int!(i32:visit_i32 i64:visit_i64);
|
||||
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
|
||||
@ -528,7 +527,7 @@ macro_rules! num_128 {
|
||||
}
|
||||
|
||||
impl_deserialize_num! {
|
||||
i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128
|
||||
i128, NonZeroI128, deserialize_i128
|
||||
num_self!(i128:visit_i128);
|
||||
num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
|
||||
num_as_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
|
||||
@ -2415,13 +2414,9 @@ impl<'de> Deserialize<'de> for SystemTime {
|
||||
|
||||
const FIELDS: &[&str] = &["secs_since_epoch", "nanos_since_epoch"];
|
||||
let duration = tri!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
|
||||
#[cfg(not(no_systemtime_checked_add))]
|
||||
let ret = UNIX_EPOCH
|
||||
UNIX_EPOCH
|
||||
.checked_add(duration)
|
||||
.ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"));
|
||||
#[cfg(no_systemtime_checked_add)]
|
||||
let ret = Ok(UNIX_EPOCH + duration);
|
||||
ret
|
||||
.ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ pub use self::string::from_utf8_lossy;
|
||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||
pub use crate::lib::{ToString, Vec};
|
||||
|
||||
#[cfg(not(no_core_try_from))]
|
||||
pub use crate::lib::convert::TryFrom;
|
||||
|
||||
mod string {
|
||||
|
@ -185,11 +185,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(no_relaxed_trait_bounds))]
|
||||
macro_rules! seq_impl {
|
||||
(
|
||||
$(#[$attr:meta])*
|
||||
$ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)*>
|
||||
$ty:ident <T $(, $typaram:ident : $bound:ident)*>
|
||||
) => {
|
||||
$(#[$attr])*
|
||||
impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
|
||||
@ -207,45 +206,22 @@ macro_rules! seq_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(no_relaxed_trait_bounds)]
|
||||
macro_rules! seq_impl {
|
||||
(
|
||||
$(#[$attr:meta])*
|
||||
$ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)*>
|
||||
) => {
|
||||
$(#[$attr])*
|
||||
impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
|
||||
where
|
||||
T: Serialize $(+ $tbound1 $(+ $tbound2)*)*,
|
||||
$($typaram: $bound,)*
|
||||
{
|
||||
#[inline]
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.collect_seq(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
seq_impl! {
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
|
||||
BinaryHeap<T>
|
||||
}
|
||||
|
||||
seq_impl! {
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
|
||||
BinaryHeap<T: Ord>
|
||||
}
|
||||
|
||||
seq_impl! {
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
|
||||
BTreeSet<T: Ord>
|
||||
BTreeSet<T>
|
||||
}
|
||||
|
||||
seq_impl! {
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||
HashSet<T: Eq + Hash, H: BuildHasher>
|
||||
HashSet<T, H: BuildHasher>
|
||||
}
|
||||
|
||||
seq_impl! {
|
||||
@ -445,7 +421,6 @@ tuple_impls! {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(not(no_relaxed_trait_bounds))]
|
||||
macro_rules! map_impl {
|
||||
(
|
||||
$(#[$attr:meta])*
|
||||
@ -468,30 +443,6 @@ macro_rules! map_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(no_relaxed_trait_bounds)]
|
||||
macro_rules! map_impl {
|
||||
(
|
||||
$(#[$attr:meta])*
|
||||
$ty:ident <K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)*>
|
||||
) => {
|
||||
$(#[$attr])*
|
||||
impl<K, V $(, $typaram)*> Serialize for $ty<K, V $(, $typaram)*>
|
||||
where
|
||||
K: Serialize $(+ $kbound1 $(+ $kbound2)*)*,
|
||||
V: Serialize,
|
||||
$($typaram: $bound,)*
|
||||
{
|
||||
#[inline]
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
serializer.collect_map(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
map_impl! {
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
|
||||
@ -640,7 +591,6 @@ nonzero_integers! {
|
||||
NonZeroUsize,
|
||||
}
|
||||
|
||||
#[cfg(not(no_num_nonzero_signed))]
|
||||
nonzero_integers! {
|
||||
NonZeroI8,
|
||||
NonZeroI16,
|
||||
|
@ -42,7 +42,7 @@ use crate::lib::{Debug, Display};
|
||||
/// ```
|
||||
pub trait Error: Debug + Display {
|
||||
/// The underlying cause of this error, if any.
|
||||
fn source(&self) -> Option<&(Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user