Skip to content

Commit 785c2d9

Browse files
committed
Stabilize no-std StdError trait
1 parent d549f04 commit 785c2d9

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

serde/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() {
1515

1616
if minor >= 77 {
1717
println!("cargo:rustc-check-cfg=cfg(no_core_cstr)");
18+
println!("cargo:rustc-check-cfg=cfg(no_core_error)");
1819
println!("cargo:rustc-check-cfg=cfg(no_core_net)");
1920
println!("cargo:rustc-check-cfg=cfg(no_core_num_saturating)");
2021
println!("cargo:rustc-check-cfg=cfg(no_core_try_from)");
@@ -98,6 +99,12 @@ fn main() {
9899
if minor < 78 {
99100
println!("cargo:rustc-cfg=no_diagnostic_namespace");
100101
}
102+
103+
// The Error trait became available in core in 1.81.
104+
// https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html#coreerrorerror
105+
if minor < 81 {
106+
println!("cargo:rustc-cfg=no_core_error");
107+
}
101108
}
102109

103110
fn rustc_minor_version() -> Option<u32> {

serde/src/de/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ pub(crate) mod size_hint;
124124

125125
pub use self::ignored_any::IgnoredAny;
126126

127-
#[cfg(not(any(feature = "std", feature = "unstable")))]
127+
#[cfg(all(not(feature = "std"), no_core_error))]
128128
#[doc(no_inline)]
129129
pub use crate::std_error::Error as StdError;
130-
#[cfg(all(feature = "unstable", not(feature = "std")))]
130+
#[cfg(not(any(feature = "std", no_core_error)))]
131131
#[doc(no_inline)]
132132
pub use core::error::Error as StdError;
133133
#[cfg(feature = "std")]

serde/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub mod __private;
325325
#[path = "de/seed.rs"]
326326
mod seed;
327327

328-
#[cfg(not(any(feature = "std", feature = "unstable")))]
328+
#[cfg(all(not(feature = "std"), no_core_error))]
329329
mod std_error;
330330

331331
// Re-export #[derive(Serialize, Deserialize)].

serde/src/ser/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ mod impossible;
115115

116116
pub use self::impossible::Impossible;
117117

118-
#[cfg(not(any(feature = "std", feature = "unstable")))]
118+
#[cfg(all(not(feature = "std"), no_core_error))]
119119
#[doc(no_inline)]
120120
pub use crate::std_error::Error as StdError;
121-
#[cfg(all(feature = "unstable", not(feature = "std")))]
121+
#[cfg(not(any(feature = "std", no_core_error)))]
122122
#[doc(no_inline)]
123123
pub use core::error::Error as StdError;
124124
#[cfg(feature = "std")]

0 commit comments

Comments
 (0)