Skip to content

Commit 13a33b3

Browse files
committed
Bump MSRV to 1.56
This is the first cargo version that actually enforces the rust-version field in Cargo.toml
1 parent 49d098d commit 13a33b3

File tree

8 files changed

+21
-107
lines changed

8 files changed

+21
-107
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
strategy:
8585
fail-fast: false
8686
matrix:
87-
rust: [1.31.0, 1.34.0]
87+
rust: [1.56.0, 1.60.0]
8888
timeout-minutes: 45
8989
steps:
9090
- uses: actions/checkout@v4
@@ -94,6 +94,7 @@ jobs:
9494
- run: sed -i '/"test_suite"/d' Cargo.toml
9595
- run: cd serde && cargo build --features rc
9696
- run: cd serde && cargo build --no-default-features
97+
- run: cd serde && cargo build --no-default-features --features alloc
9798
- run: cd serde && cargo build
9899

99100
derive:
@@ -111,16 +112,6 @@ jobs:
111112
- run: cd serde && cargo check
112113
- run: cd serde_derive && cargo check
113114

114-
alloc:
115-
name: Rust 1.36.0
116-
runs-on: ubuntu-latest
117-
timeout-minutes: 45
118-
steps:
119-
- uses: actions/checkout@v4
120-
- uses: dtolnay/[email protected]
121-
- run: sed -i '/"test_suite"/d' Cargo.toml
122-
- run: cd serde && cargo build --no-default-features --features alloc
123-
124115
minimal:
125116
name: Minimal versions
126117
runs-on: ubuntu-latest

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.31] [![serde_derive msrv]][Rust 1.61]
1+
# Serde   [![Build Status]][actions] [![Latest Version]][crates.io] [![serde msrv]][Rust 1.56] [![serde_derive msrv]][Rust 1.61]
22

33
[Build Status]: https://img.shields.io/github/actions/workflow/status/serde-rs/serde/ci.yml?branch=master
44
[actions]: https://github.com/serde-rs/serde/actions?query=branch%3Amaster
55
[Latest Version]: https://img.shields.io/crates/v/serde.svg
66
[crates.io]: https://crates.io/crates/serde
77
[serde msrv]: https://img.shields.io/crates/msrv/serde.svg?label=serde%20msrv&color=lightgray
88
[serde_derive msrv]: https://img.shields.io/crates/msrv/serde_derive.svg?label=serde_derive%20msrv&color=lightgray
9-
[Rust 1.31]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
9+
[Rust 1.56]: https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html
1010
[Rust 1.61]: https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html
1111

1212
**Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**

serde/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ keywords = ["serde", "serialization", "no_std"]
1212
license = "MIT OR Apache-2.0"
1313
readme = "crates-io.md"
1414
repository = "https://github.com/serde-rs/serde"
15-
rust-version = "1.31"
15+
rust-version = "1.56"
1616

1717
[dependencies]
1818
serde_derive = { version = "1", optional = true, path = "../serde_derive" }

serde/build.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,17 @@ fn main() {
1818
println!("cargo:rustc-check-cfg=cfg(no_core_error)");
1919
println!("cargo:rustc-check-cfg=cfg(no_core_net)");
2020
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
21-
println!("cargo:rustc-check-cfg=cfg(no_core_try_from)");
2221
println!("cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)");
2322
println!("cargo:rustc-check-cfg=cfg(no_float_copysign)");
24-
println!("cargo:rustc-check-cfg=cfg(no_num_nonzero_signed)");
25-
println!("cargo:rustc-check-cfg=cfg(no_relaxed_trait_bounds)");
2623
println!("cargo:rustc-check-cfg=cfg(no_serde_derive)");
2724
println!("cargo:rustc-check-cfg=cfg(no_std_atomic)");
2825
println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)");
29-
println!("cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)");
3026
println!("cargo:rustc-check-cfg=cfg(no_target_has_atomic)");
3127
}
3228

3329
let target = env::var("TARGET").unwrap();
3430
let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten";
3531

36-
// TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add
37-
// stabilized in Rust 1.34:
38-
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto
39-
// https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations
40-
if minor < 34 {
41-
println!("cargo:rustc-cfg=no_core_try_from");
42-
println!("cargo:rustc-cfg=no_num_nonzero_signed");
43-
println!("cargo:rustc-cfg=no_systemtime_checked_add");
44-
println!("cargo:rustc-cfg=no_relaxed_trait_bounds");
45-
}
46-
47-
// f32::copysign and f64::copysign stabilized in Rust 1.35.
48-
// https://blog.rust-lang.org/2019/05/23/Rust-1.35.0.html#copy-the-sign-of-a-floating-point-number-onto-another
49-
if minor < 35 {
50-
println!("cargo:rustc-cfg=no_float_copysign");
51-
}
52-
5332
// Support for #[cfg(target_has_atomic = "...")] stabilized in Rust 1.60.
5433
if minor < 60 {
5534
println!("cargo:rustc-cfg=no_target_has_atomic");

serde/src/de/impls.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ impl<'de> Deserialize<'de> for bool {
8080
////////////////////////////////////////////////////////////////////////////////
8181

8282
macro_rules! impl_deserialize_num {
83-
($primitive:ident, $nonzero:ident $(cfg($($cfg:tt)*))*, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
83+
($primitive:ident, $nonzero:ident, $deserialize:ident $($method:ident!($($val:ident : $visit:ident)*);)*) => {
8484
impl_deserialize_num!($primitive, $deserialize $($method!($($val : $visit)*);)*);
8585

86-
$(#[cfg($($cfg)*)])*
8786
impl<'de> Deserialize<'de> for num::$nonzero {
8887
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
8988
where
@@ -228,12 +227,12 @@ macro_rules! num_as_copysign_self {
228227
where
229228
E: Error,
230229
{
231-
#[cfg(any(no_float_copysign, not(feature = "std")))]
230+
#[cfg(not(feature = "std"))]
232231
{
233232
Ok(v as Self::Value)
234233
}
235234

236-
#[cfg(all(not(no_float_copysign), feature = "std"))]
235+
#[cfg(feature = "std")]
237236
{
238237
// Preserve sign of NaN. The `as` produces a nondeterministic sign.
239238
let sign = if v.is_sign_positive() { 1.0 } else { -1.0 };
@@ -381,37 +380,37 @@ macro_rules! uint_to_self {
381380
}
382381

383382
impl_deserialize_num! {
384-
i8, NonZeroI8 cfg(not(no_num_nonzero_signed)), deserialize_i8
383+
i8, NonZeroI8, deserialize_i8
385384
num_self!(i8:visit_i8);
386385
int_to_int!(i16:visit_i16 i32:visit_i32 i64:visit_i64);
387386
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
388387
}
389388

390389
impl_deserialize_num! {
391-
i16, NonZeroI16 cfg(not(no_num_nonzero_signed)), deserialize_i16
390+
i16, NonZeroI16, deserialize_i16
392391
num_self!(i16:visit_i16);
393392
num_as_self!(i8:visit_i8);
394393
int_to_int!(i32:visit_i32 i64:visit_i64);
395394
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
396395
}
397396

398397
impl_deserialize_num! {
399-
i32, NonZeroI32 cfg(not(no_num_nonzero_signed)), deserialize_i32
398+
i32, NonZeroI32, deserialize_i32
400399
num_self!(i32:visit_i32);
401400
num_as_self!(i8:visit_i8 i16:visit_i16);
402401
int_to_int!(i64:visit_i64);
403402
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
404403
}
405404

406405
impl_deserialize_num! {
407-
i64, NonZeroI64 cfg(not(no_num_nonzero_signed)), deserialize_i64
406+
i64, NonZeroI64, deserialize_i64
408407
num_self!(i64:visit_i64);
409408
num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32);
410409
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
411410
}
412411

413412
impl_deserialize_num! {
414-
isize, NonZeroIsize cfg(not(no_num_nonzero_signed)), deserialize_i64
413+
isize, NonZeroIsize, deserialize_i64
415414
num_as_self!(i8:visit_i8 i16:visit_i16);
416415
int_to_int!(i32:visit_i32 i64:visit_i64);
417416
uint_to_self!(u8:visit_u8 u16:visit_u16 u32:visit_u32 u64:visit_u64);
@@ -528,7 +527,7 @@ macro_rules! num_128 {
528527
}
529528

530529
impl_deserialize_num! {
531-
i128, NonZeroI128 cfg(not(no_num_nonzero_signed)), deserialize_i128
530+
i128, NonZeroI128, deserialize_i128
532531
num_self!(i128:visit_i128);
533532
num_as_self!(i8:visit_i8 i16:visit_i16 i32:visit_i32 i64:visit_i64);
534533
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 {
24152414

24162415
const FIELDS: &[&str] = &["secs_since_epoch", "nanos_since_epoch"];
24172416
let duration = tri!(deserializer.deserialize_struct("SystemTime", FIELDS, DurationVisitor));
2418-
#[cfg(not(no_systemtime_checked_add))]
2419-
let ret = UNIX_EPOCH
2417+
UNIX_EPOCH
24202418
.checked_add(duration)
2421-
.ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"));
2422-
#[cfg(no_systemtime_checked_add)]
2423-
let ret = Ok(UNIX_EPOCH + duration);
2424-
ret
2419+
.ok_or_else(|| D::Error::custom("overflow deserializing SystemTime"))
24252420
}
24262421
}
24272422

serde/src/private/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub use self::string::from_utf8_lossy;
2020
#[cfg(any(feature = "alloc", feature = "std"))]
2121
pub use crate::lib::{ToString, Vec};
2222

23-
#[cfg(not(no_core_try_from))]
2423
pub use crate::lib::convert::TryFrom;
2524

2625
mod string {

serde/src/ser/impls.rs

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,10 @@ where
185185
}
186186
}
187187

188-
#[cfg(not(no_relaxed_trait_bounds))]
189188
macro_rules! seq_impl {
190189
(
191190
$(#[$attr:meta])*
192-
$ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)*>
191+
$ty:ident <T $(, $typaram:ident : $bound:ident)*>
193192
) => {
194193
$(#[$attr])*
195194
impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
@@ -207,45 +206,22 @@ macro_rules! seq_impl {
207206
}
208207
}
209208

210-
#[cfg(no_relaxed_trait_bounds)]
211-
macro_rules! seq_impl {
212-
(
213-
$(#[$attr:meta])*
214-
$ty:ident <T $(: $tbound1:ident $(+ $tbound2:ident)*)* $(, $typaram:ident : $bound:ident)*>
215-
) => {
216-
$(#[$attr])*
217-
impl<T $(, $typaram)*> Serialize for $ty<T $(, $typaram)*>
218-
where
219-
T: Serialize $(+ $tbound1 $(+ $tbound2)*)*,
220-
$($typaram: $bound,)*
221-
{
222-
#[inline]
223-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
224-
where
225-
S: Serializer,
226-
{
227-
serializer.collect_seq(self)
228-
}
229-
}
230-
}
231-
}
232-
233209
seq_impl! {
234210
#[cfg(any(feature = "std", feature = "alloc"))]
235211
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
236-
BinaryHeap<T: Ord>
212+
BinaryHeap<T>
237213
}
238214

239215
seq_impl! {
240216
#[cfg(any(feature = "std", feature = "alloc"))]
241217
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
242-
BTreeSet<T: Ord>
218+
BTreeSet<T>
243219
}
244220

245221
seq_impl! {
246222
#[cfg(feature = "std")]
247223
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
248-
HashSet<T: Eq + Hash, H: BuildHasher>
224+
HashSet<T, H: BuildHasher>
249225
}
250226

251227
seq_impl! {
@@ -445,7 +421,6 @@ tuple_impls! {
445421

446422
////////////////////////////////////////////////////////////////////////////////
447423

448-
#[cfg(not(no_relaxed_trait_bounds))]
449424
macro_rules! map_impl {
450425
(
451426
$(#[$attr:meta])*
@@ -468,30 +443,6 @@ macro_rules! map_impl {
468443
}
469444
}
470445

471-
#[cfg(no_relaxed_trait_bounds)]
472-
macro_rules! map_impl {
473-
(
474-
$(#[$attr:meta])*
475-
$ty:ident <K $(: $kbound1:ident $(+ $kbound2:ident)*)*, V $(, $typaram:ident : $bound:ident)*>
476-
) => {
477-
$(#[$attr])*
478-
impl<K, V $(, $typaram)*> Serialize for $ty<K, V $(, $typaram)*>
479-
where
480-
K: Serialize $(+ $kbound1 $(+ $kbound2)*)*,
481-
V: Serialize,
482-
$($typaram: $bound,)*
483-
{
484-
#[inline]
485-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
486-
where
487-
S: Serializer,
488-
{
489-
serializer.collect_map(self)
490-
}
491-
}
492-
}
493-
}
494-
495446
map_impl! {
496447
#[cfg(any(feature = "std", feature = "alloc"))]
497448
#[cfg_attr(docsrs, doc(cfg(any(feature = "std", feature = "alloc"))))]
@@ -640,7 +591,6 @@ nonzero_integers! {
640591
NonZeroUsize,
641592
}
642593

643-
#[cfg(not(no_num_nonzero_signed))]
644594
nonzero_integers! {
645595
NonZeroI8,
646596
NonZeroI16,

serde/src/std_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use crate::lib::{Debug, Display};
4242
/// ```
4343
pub trait Error: Debug + Display {
4444
/// The underlying cause of this error, if any.
45-
fn source(&self) -> Option<&(Error + 'static)> {
45+
fn source(&self) -> Option<&(dyn Error + 'static)> {
4646
None
4747
}
4848
}

0 commit comments

Comments
 (0)